Electron microscopy (EM) achieves the highest spatial resolution in protein localization, but specific protein EM labeling has lacked generally applicable genetically encoded tags for in situ visualization in cells and tissues. Here we introduce “miniSOG” (for mini Singlet Oxygen Generator), a fluorescent flavoprotein engineered from Arabidopsis phototropin 2. MiniSOG contains 106 amino acids, less than half the size of Green Fluorescent Protein. Illumination of miniSOG generates sufficient singlet oxygen to locally catalyze the polymerization of diaminobenzidine into an osmiophilic reaction product resolvable by EM. MiniSOG fusions to many well-characterized proteins localize correctly in mammalian cells, intact nematodes, and rodents, enabling correlated fluorescence and EM from large volumes of tissue after strong aldehyde fixation, without the need for exogenous ligands, probes, or destructive permeabilizing detergents. MiniSOG permits high quality ultrastructural preservation and 3-dimensional protein localization via electron tomography or serial section block face scanning electron microscopy. EM shows that miniSOG-tagged SynCAM1 is presynaptic in cultured cortical neurons, whereas miniSOG-tagged SynCAM2 is postsynaptic in culture and in intact mice. Thus SynCAM1 and SynCAM2 could be heterophilic partners. MiniSOG may do for EM what Green Fluorescent Protein did for fluorescence microscopy.