The production rates of prompt and non-prompt J/ψ and ψ(2S) mesons in their dimuon decay modes are measured using 2.1 fb−1 and 11.4 fb−1 of data collected with the ATLAS experiment at the Large Hadron Collider, in proton–proton collisions at √s = 7 and 8 TeV respectively. Production cross-sections for prompt as well as non-prompt sources, ratios of ψ(2S) to J/ψ production, and the fractions of non-prompt production for J/ψ and ψ(2S) are measured as a function of meson transverse momentum and rapidity. The measurements are compared to theoretical predictions.