The polarizations of prompt J/psi and psi(2S) mesons are measured in proton-proton collisions at sqrt(s) = 7 TeV, using a dimuon data sample collected by the CMS experiment at the LHC, corresponding to an integrated luminosity of 4.9 inverse femtobarns. The prompt J/psi and psi(2S) polarization parameters lambda[theta], lambda[phi], and lambda[theta,phi], as well as the frame-invariant quantity lambda(tilde), are measured from the dimuon decay angular distributions in three different polarization frames. The J/psi results are obtained in the transverse momentum range 14 < pt < 70 GeV, in the rapidity intervals abs(y) < 0.6 and 0.6 < abs(y) < 1.2. The corresponding psi(2S) results cover 14 < pt < 50 GeV and include a third rapidity bin, 1.2 < abs(y) < 1.5. No evidence of large transverse or longitudinal polarizations is seen in these kinematic regions, which extend much beyond those previously explored.