Context. Early observations of comet C/2016 R2 (PanSTARRS) have shown that the composition of this comet is very peculiar. Radio observations have revealed a CO-rich and HCN-poor comet and an optical coma dominated by strong emission bands of CO + and, more surprisingly, N + 2 . Aims. The strong detection of N + 2 in the coma of C/2016 R2 provided an ideal opportunity to measure the 14 N/ 15 N isotopic ratio directly from N + 2 for the first time, and to estimate the N 2 /CO ratio, which is an important diagnostic to constrain formation models of planetesimals, in addition to the more general study of coma composition. Methods. We obtained high resolution spectra of the comet in February when it was at 2.8 au from the Sun. We used the UVES spectrograph of the ESO VLT, complemented with narrow-band images obtained with the TRAPPIST telescopes. Results. We detect strong emissions from the ions N + 2 and CO + , but also CO + 2 , emission from the CH radical, and much fainter emissions of the CN, C 2 , and C 3 radicals which were not detected in previous observations of this comet. We do not detect OH or H 2 O + , and derive an upper limit of the H 2 O + /CO + ratio of 0.4, implying that the comet has a low water abundance. We measure a N + 2 /CO + ratio of 0.06 ± 0.01. The non-detection of NH 2 indicates that most of the nitrogen content of the comet lies within N 2 . Together with the high N + 2 /CO + ratio, this could indicate a low formation temperature of the comet, or that the comet is a fragment of a large differentiated Kuiper Belt object. The CO + 2 /CO + ratio is 1.1 ± 0.3. We do not detect 14 N 15 N + lines, and can only put a lower limit on the 14 N/ 15 N ratio measured from N + 2 of about 100, compatible with measurements of the same isotopic ratio for NH 2 and CN in other comets. Finally, in addition to the [OI] and [CI] forbidden lines, we detect for the first time the forbidden nitrogen lines [NI] doublet at 519.79 and 520.04 nm in the coma of a comet.