Plants and bacteria synthesize the essential human micronutrient riboflavin (vitamin B2) via the same multi-step pathway. The early intermediates of this pathway are notoriously reactive and may be overproduced in vivo because riboflavin biosynthesis enzymes lack feedback controls. In the present paper, we demonstrate disposal of riboflavin intermediates by COG3236 (DUF1768), a protein of previously unknown function that is fused to two different riboflavin pathway enzymes in plants and bacteria (RIBR and RibA respectively). We present cheminformatic, biochemical, genetic and genomic evidence to show that: (i) plant and bacterial COG3236 proteins cleave the N-glycosidic bond of the first two intermediates of riboflavin biosynthesis, yielding relatively innocuous products; (ii) certain COG3236 proteins are in a multi-enzyme riboflavin biosynthesis complex that gives them privileged access to riboflavin intermediates; and (iii) COG3236 action in Arabidopsis thaliana and Escherichia coli helps maintain flavin levels. COG3236 proteins thus illustrate two emerging principles in chemical biology: directed overflow metabolism, in which excess flux is diverted out of a pathway, and the pre-emption of damage from reactive metabolites.