The Euclid mission will conduct an extragalactic survey over 15 000 deg2 of the extragalactic sky. The spectroscopic channel of the Near-Infrared Spectrometer and Photometer (NISP) has a resolution of R ~ 450 for its blue and red grisms that collectively cover the 0.93–1.89 µm range. NISP will obtain spectroscopic redshifts for 3 × 107 galaxies for the experiments on galaxy clustering, baryonic acoustic oscillations, and redshift space distortion. The wavelength calibration must be accurate within 5 Å to avoid systematics in the redshifts and downstream cosmological parameters. The NISP pre-flight dispersion laws for the grisms were obtained on the ground using a Fabry-Perot etalon. Launch vibrations, zero gravity conditions, and thermal stabilisation may alter these dispersion laws, requiring an in-flight recalibration. To this end, we use the emission lines in the spectra of compact planetary nebulae (PNe), which were selected from a PN database. To ensure completeness of the PN sample, we developed a novel technique to identify compact and strong line emitters in Gaia spectroscopic data using the Gaia spectra shape coefficients. We obtained VLT/X-shooter spectra from 0.3 to 2.5 µm for 19 PNe in excellent seeing conditions and a wide slit, mimicking Euclid’s slitless spectroscopy mode but with a ten times higher spectral resolution. Additional observations of one northern PN were obtained in the 0.80–1.90 µm range with the GMOS and GNIRS instruments at the Gemini North Observatory. The collected spectra were combined into an atlas of heliocentric vacuum wavelengths with a joint statistical and systematic accuracy of 0.1 Å in the optical and 0.3 Å in the near-infrared. The wavelength atlas and the related 1D and 2D spectra are made publicly available.