The primary sequence of a biopolymer encodes the essential information for folding, permitting to carry out sophisticated functions. Inspired by natural biopolymers, peptide and nucleic acid sequences have been designed to adopt particular three-dimensional (3D) shapes and programmed to exert specific functions. In contrast, synthetic glycans capable of autonomously folding into defined 3D conformations have so far not been explored owing to their structural complexity and lack of design rules. Here we generate a glycan that adopts a stable secondary structure not present in nature, a glycan hairpin, by combining natural glycan motifs, stabilized by a non-conventional hydrogen bond and hydrophobic interactions. Automated glycan assembly enabled rapid access to synthetic analogues, including site-specific 13C-labelled ones, for nuclear magnetic resonance conformational analysis. Long-range inter-residue nuclear Overhauser effects unequivocally confirmed the folded conformation of the synthetic glycan hairpin. The capacity to control the 3D shape across the pool of available monosaccharides has the potential to afford more foldamer scaffolds with programmable properties and functions.