In order to identify the mechanism responsible for the formation of charge-density waves (CDW) in cuprate superconductors, it is important to understand which aspects of the CDW’s microscopic structure are generic and which are material-dependent. Here, we show that, at the local scale probed by NMR, long-range CDW order in YBa2Cu3Oy is unidirectional with a commensurate period of three unit cells (λ = 3b), implying that the incommensurability found in X-ray scattering is ensured by phase slips (discommensurations). Furthermore, NMR spectra reveal a predominant oxygen character of the CDW with an out-of-phase relationship between certain lattice sites but no specific signature of a secondary CDW with λ = 6b associated with a putative pair-density wave. These results shed light on universal aspects of the cuprate CDW. In particular, its spatial profile appears to generically result from the interplay between an incommensurate tendency at long length scales, possibly related to properties of the Fermi surface, and local commensuration effects, due to electron-electron interactions or lock-in to the lattice.