The thermodynamic stability and mechanical properties of titanium carbonitrides TiC x N1−x (0 ⩽ x ⩽ 1) are investigated by a combination of the universal cluster expansion method and the first-principles calculations. By considering the ordering of the N/C distributions on the anion sublattice sites of TiC x N1−x , a binary diagram of the heat of formation is constructed, and seven kinds of ground-state structures are predicted in the whole range of 0 ⩽ x ⩽ 1. These predicted ground-state TiC x N1−x structures are further proved to be dynamically and mechanically stable by examining their phonon dispersion spectra and elastic constants. Further studies indicate that the mechanical and thermodynamic properties of the ternary TiC x N1−x structures are generally better than those of the binary TiC or TiN, while the differences within the ternary systems are insignificant. The possible origin of the enhancement of the mechanical and thermodynamic properties of the predicted ground-state TiC x N1−x are discussed together with the electronic structures.