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