Glycosyltransferases are a superfamily of enzymes that are notoriously difficult to inhibit. Here we apply an mRNA display technology integrated with genetic code reprogramming, referred to as the RaPID (random non-standard peptides integrated discovery) system, to identify macrocyclic peptides with high binding affinities for O-GlcNAc transferase (OGT). These macrocycles inhibit OGT activity through an allosteric mechanism that is driven by their binding to the tetratricopeptide repeats of OGT. Saturation mutagenesis in a maturation screen using 39 amino acids, including 22 non-canonical residues, led to an improved unnatural macrocycle that is � 40 times more potent than the parent compound (K i app = 1.5 nM). Subsequent derivatization delivered a biotinylated derivative that enabled one-step affinity purification of OGT from complex samples. The high potency and novel mechanism of action of these OGT ligands should enable new approaches to elucidate the specificity and regulation of OGT.