The spectral lines of the CH molecule are a key carbon (C) abundance diagnostic in FGKM-type stars. These lines are detectable in metal-rich and, in contrast to atomic C lines, also in metal-poor late-type stars. However, only 3D LTE analyses of the CH lines have been performed so far. We test the formation of CH lines in the solar spectrum, using for the first time, 3D Non-LTE (NLTE) models. We also aim to derive the solar photospheric abundance of C, using the diagnostic transitions in the optical (4218) and infrared (33025 $4356 \,\rm{\mathring{\rm A}}$ ). We use the updated NLTE model molecule from S. A. Popa et al. (2023) and different solar 3D radiation-hydrodynamics model atmospheres. The models are contrasted against new spatially resolved optical solar spectra, and the centre-to-limb variation (CLV) of CH lines is studied. We find generally small ( $37944 \,\rm{\mathring{\rm A}}$ 0.01 dex) NLTE effects in the optical and IR diagnostic CH AX lines in the solar atmosphere. Both 3D NLTE and 3D LTE spectral modelling yield an excellent fit to the solar intensity observations at all viewing angles. The 1D LTE and 1D NLTE models fail to describe the line CLV, and lead to underestimated solar C abundances. The 3D NLTE modelling of diagnostic lines in the optical and IR yields a carbon abundance of A(C) = $\sim$ dex. The estimate is in agreement with recent results based on neutrino fluxes measured by Borexino. 3D NLTE modelling and tests on spatially resolved solar data are essential to derive robust solar abundances. The analysis presented here focuses on CH, but we expect that similar effects will be present for other molecules of astrophysical interest. $8.52\pm 0.07$