We present measurements of the differential cross sections of inclusive $J/psi$ meson production as a function of transverse momentum ($p_{T}^{J/psi}$) using the $mu^{+}mu^{-}$ and $e^{+}e^{-}$ decay channels in proton+proton collisions at center-of-mass energies of 510 and 500 GeV, respectively, recorded by the STAR detector at the Relativistic Heavy Ion Collider. The measurement from the $mu^{+}mu^{-}$ channel is for 0 $< p_{T}^{J/psi} <$ 9 GeV/$c$ and rapidity range $|y^{J/psi}| < $ 0.4, and that from the $e^{+}e^{-}$ channel is for 4 $< p_{T}^{J/psi} <$ 20 GeV/$c$ and $|y^{J/psi}| < $ 1.0. The $psi(2S)$ to $J/psi$ ratio is also measured for 4 $< p_{T}^{rm meson} <$ 12 GeV/$c$ through the $e^{+}e^{-}$ decay channel. Model calculations, which incorporate different approaches toward the $J/psi$ production mechanism, are compared with experimental results and show reasonable agreement within uncertainties.