Jet fragmentation transverse momentum (jT) distributions are measured in proton-proton (pp) and proton-lead (p-Pb) collisions at sNN = 5.02 TeV with the ALICE experiment at the LHC. Jets are reconstructed with the ALICE tracking detectors and electromagnetic calorimeter using the anti-kT algorithm with resolution parameter R = 0.4 in the pseudorapidity range |η| < 0.25. The jT values are calculated for charged particles inside a fixed cone with a radius R = 0.4 around the reconstructed jet axis. The measured jT distributions are compared with a variety of parton-shower models. Herwig and Pythia 8 based models describe the data well for the higher jT region, while they underestimate the lower jT region. The jT distributions are further characterised by fitting them with a function composed of an inverse gamma function for higher jT values (called the “wide component”), related to the perturbative component of the fragmentation process, and with a Gaussian for lower jT values (called the “narrow component”), predominantly connected to the hadronisation process. The width of the Gaussian has only a weak dependence on jet transverse momentum, while that of the inverse gamma function increases with increasing jet transverse momentum. For the narrow component, the measured trends are successfully described by all models except for Herwig. For the wide component, Herwig and PYTHIA 8 based models slightly underestimate the data for the higher jet transverse momentum region. These measurements set constraints on models of jet fragmentation and hadronisation. [Figure not available: see fulltext.]