A measurement of the groomed jet mass in PbPb and pp collisions at a nucleon-nucleon center-of-mass energy of 5.02 TeV with the CMS detector at the LHC is presented. Jet grooming is a recursive procedure which sequentially removes soft constituents of a jet until a pair of hard subjets is found. The resulting groomed jets can be used to study modifications to the parton shower evolution in the presence of the hot and dense medium created in heavy ion collisions. Predictions of groomed jet properties from the pythia and herwig++ event generators agree with the measurements in pp collisions. When comparing the results from the most central PbPb collisions to pp data, a hint of an increase of jets with large jet mass is observed, which could originate from additional medium-induced radiation at a large angle from the jet axis. However, no modification of the groomed mass of the core of the jet is observed for all PbPb centrality classes. The PbPb results are also compared to predictions from the jewel and q-pythia event generators, which predict a large modification of the groomed mass not observed in the data.