Context. During the transition from the asymptotic giant branch (AGB) to planetary nebulae (PN), the circumstellar geometry and morphology change dramatically. Another characteristic of this transition is the high mass-loss rate, that can be partially explained by radiation pressure and a combination of various factors, such as the stellar pulsation, the dust grain condensation, and opacity in the upper atmosphere. The magnetic field can also be one of the main ingredients that shapes the stellar upper atmosphere and envelope. Aims. Our main goal is to investigate for the first time the spatial distribution of the magnetic field in the envelope of IRC+10216. More generally we intend to determine the magnetic field strength in the circumstellar envelope (CSE) of C-rich evolved stars, compare this field with previous studies for O-rich stars, and constrain the variation of the magnetic field with r the distance to the star's centre. Methods. We use spectropolarimetric observations of the Stokes V parameter, collected with Xpol on the IRAM-30 m radiotelescope, observing the Zeeman effect in seven hyperfine components of the CN J = 1-0 line. We use the Crutcher et al. (1996, ApJ, 456, 217) method to estimate the magnetic field. For the first time, the instrumental contamination is investigated, through dedicated studies of the power patterns in Stokes V and I in detail.Results. For C-rich evolved stars, we derive a magnetic field strength (B) between 1.6 and 14.2 mG while B is estimated to be 6 mG for the proto-PN (PPN) AFGL618, and an upper value of 8 mG is found for the PN NGC 7027. These results are consistent with a decrease of B as 1/r in the environment of AGB objects, that is, with the presence of a toroidal field. But this is not the case for PPN and PN stars. Our map of IRC+10216 suggests that the magnetic field is not homogeneously strong throughout or aligned with the envelope and that the morphology of the CN emission might have changed with time.