[en] Our aim is to determine the isotopic ratios [SUP]12[/SUP]C/[SUP]13[/SUP]C and [SUP]14[/SUP]N/[SUP]15[/SUP]N in a variety of comets and link these measurements to the formation and evolution of the solar system. The [SUP]12[/SUP]C/[SUP]13[/SUP]C and [SUP]14[/SUP]N/[SUP]15[/SUP]N isotopic ratios are measured for the CN radical by means of high-resolution optical spectra of the R branch of the B-X (0, 0) violet band. 23 comets from different dynamical classes have been observed, sometimes at various heliocentric and nucleocentric distances, in order to estimate possible variations of the isotopic ratios in parent molecules. The [SUP]12[/SUP]C/[SUP]13[/SUP]C and [SUP]14[/SUP]N/[SUP]15[/SUP]N isotopic ratios in CN are remarkably constant (average values of, respectively, 91.0 Â± 3.6 and 147.8 Â± 5.7) within our measurement errors, for all comets whatever their origin or heliocentric distance. While the carbon isotopic ratio does agree with the terrestrial value (89), the nitrogen ratio is a factor of two lower than the terrestrial value (272), indicating a fractionation in the early solar system, or in the protosolar nebula, common to all the comets of our sample. This points towards a common origin of the comets independently of their birthplaces, and a relationship between HCN and CN. Appendices and Table [see full textsee full textsee full text] are only available in electronic form at http://www.aanda.org Based on observations made with ESO Telescopes at the La Silla Paranal Observatory under programmes ID 268.C-5570, 270.C-5043, 073.C-0525, 274.C-5015 and 075.C-0355(A).