As a single-phase alloy, CrFeCoNi is a face centered cubic (fcc) material related to the archetypical high-entropy Cantor alloy CrFeCoNiMn. For thin films, CrFeCoNi of approximately equimolar composition tends to assume an fcc structure when grown at room temperature by magnetron sputtering. However, the single-phase solid solution state is typically not achieved for thin films grown at higher temperatures. The same holds true for Cantor alloy-based ceramics (nitrides and oxides), where phase formation is extremely sensitive to process parameters such as the amount of reactive gas. This study combines theoretical and experimental methods to understand the phase formation in nitrogen-containing CrFeCoNi thin films. Density functional theory calculations considering three competing phases (CrN, Fe-Ni and Co) show that the free energy of mixing, delta G of (CrFeCoNi)1-xNx solid solutions has a maximum at x = 0.20-0.25, and delta G becomes lower when x less than 0.20, greater than 0.25. Thin films of (CrFeCoNi)1-xNx (x = 0.14-0.41) grown by magnetron sputtering show stabilization of the metallic fcc when x lesser than or equal to 0.22 and the stabilization of the NaCl B1 structure when x is greater than 0.33, consistent with the theoretical prediction. In contrast, films with intermediate amounts of nitrogen (x = 0.22) grown at higher temperatures show segregation into multiple phases of CrN, Fe-Ni-rich and Co. These results offer an explanation for the requirement of kinetically limited growth conditions at low temperature for obtaining single-phase CrFeCoNi Cantor-like nitrogen-containing thin films and are of importance for understanding the phase-formation mechanisms in multicomponent ceramics.