The stopping of baryons in heavy ion collisions at beam momenta of p lab = 20 − 160A GeV is lacking a quantitative description within theoretical calculations. Heavy ion reactions at these energies are experimentally explored at the Super Proton Synchrotron (SPS) and the Relativistic Heavy Ion Collider (RHIC) and will be studied at future facilities such as FAIR and NICA. Since the net baryon density is determined by the amount of stopping, this is the pre-requisiste for any investigation of other observables related to structures in the QCD phase diagram such as a first-order phase transition or a critical endpoint. In this work we employ a string model for treating hadron-hadron interactions within a hadronic transport approach (SMASH, Simulating Many Accelerated Strongly-interacting Hadrons). Free parameters of the string excitation and decay are tuned to match experimental measurements in elementary proton-proton collisions. Afterwards, the model is applied to heavy ion collisions, where the experimentally observed change of the shape of the proton rapidity spectrum from a single peak structure to a double peak structure with increasing beam energy is reproduced. Heavy ion collisions provide the opportunity to study the formation process of string fragments in terms of formation times and reduced interaction cross-sections for pre-formed hadrons. A good agreement with the measured rapidity spectra of protons and pions is achieved while insights on the fragmentation process are obtained. In the future, the presented approach can be used to create event-by-event initial conditions for hybrid calculations.