The production of J/ψ is measured as a function of charged-particle multiplicity at forward rapidity in proton-proton (pp) collisions at center-of-mass energies √s = 5.02 and 13 TeV. The J/ψ mesons are reconstructed via their decay into dimuons in the ra- pidity interval (2.5 < y < 4.0), whereas the charged-particle multiplicity density (dNch/dη) is measured at midrapidity (|η| < 1). The production rate as a function of multiplicity is reported as the ratio of the yield in a given multiplicity interval to the multiplicity- integrated one. This observable shows a linear increase with charged-particle multiplicity normalized to the corresponding average value for inelastic events (dNch/dη/⟨dNch/dη⟩), at both the colliding energies. Measurements are compared with available ALICE results at midrapidity and theoretical model calculations. First measurement of the mean trans- verse momentum (⟨pT⟩) of J/ψ in pp collisions exhibits an increasing trend as a function
of dNch/dη/⟨dNch/dη⟩ showing a saturation towards high charged-particle multiplicities.