Indigo is an ancient dye uniquely capable of producing the signature tones in blue denim; however, the dyeing process requires chemical steps that are environmentally damaging. We describe a sustainable dyeing strategy that not only circumvents the use of toxic reagents for indigo chemical synthesis but also removes the need for a reducing agent for dye solubilization. This strategy utilizes a glucose moiety as a biochemical protecting group to stabilize the reactive indigo precursor indoxyl to form indican, preventing spontaneous oxidation to crystalline indigo during microbial fermentation. Application of a β-glucosidase removes the protecting group from indican, resulting in indigo crystal formation in the cotton fibers. We identified the gene coding for the glucosyltransferase PtUGT1 from the indigo plant Polygonum tinctorium and solved the structure of PtUGT1. Heterologous expression of PtUGT1 in Escherichia coli supported high indican conversion, and biosynthesized indican was used to dye cotton swatches and a garment.