Angular correlations of heavy-flavour and charged particles in high-energy proton–proton collisions are sensitive to the production mechanisms of heavy quarks and to their fragmentation as well as hadronisation processes. The measurement of the azimuthal-correlation function of prompt D mesons with charged particles in proton–proton collisions at a centre-of-mass energy of sqrt{s} = 13 TeV with the ALICE detector is reported, considering mathrm D^{0} , mathrm D^{+} , and mathrm D^{*+} mesons in the transverse-momentum interval 3< p_{mathrm{T}} < 36 GeV/c at midrapidity (|y| < 0.5), and charged particles with p_{mathrm{T}} > 0.3 GeV/c and pseudorapidity |eta | < 0.8. This measurement has an improved precision and provides an extended transverse-momentum coverage compared to previous ALICE measurements at lower energies. The study is also performed as a function of the charged-particle multiplicity, showing no modifications of the correlation function with multiplicity within uncertainties. The properties and the transverse-momentum evolution of the near- and away-side correlation peaks are studied and compared with predictions from various Monte Carlo event generators. Among those considered, PYTHIA8 and POWHEG+PYTHIA8 provide the best description of the measured observables. The obtained results can provide guidance on tuning the generators.