5-Hydroxymethyluracil ( 5hmU ) is found in the genomes of a diverse range of organisms as another kind of 5-hydroxymethylpyrimidine, with the exception of 5-hydroxymethylcytosine ( 5hmC ). The biological function of 5hmU has not been well explored due to lacking both specific 5hmU recognition and single-cell analysis methods. Here we report differentiated visualization of single-cell 5hmU and 5hmC with microfluidic hydrogel encoding (sc 5hmU / 5hmC -microgel). Single cells and their genomic DNA after cell lysis can be encapsulated in individual agarose microgels. The 5hmU sites are then specifically labeled with thiophosphate for the first time, followed by labeling 5hmC with azide glucose. These labeled bases are each encoded into respective DNA barcode primers by chemical cross-linking. In situ amplification is triggered for single-molecule fluorescence visualization of single-cell 5hmU and 5hmC . On the basis of the sc 5hmU / 5hmC -microgel, we reveal cell type-specific molecular signatures of these two bases with remarkable single-cell heterogeneity. Utilizing machine learning algorithms to decode four-dimensional signatures of 5hmU / 5hmC , we visualize the discrimination of nontumorigenic, carcinoma and highly invasive breast cell lines. This strategy provides a new route to analyze and decode single-cell DNA epigenetic modifications.