Core-level binding energies (BEs) and valence-band structures of VNy and Ti1−xVxNy films (0⩽x⩽1, 0.4⩽y⩽1.1), deposited by rf magnetron sputtering, have been investigated by x-ray photoemission spectroscopy. The core level BEs and valence-band spectra are discussed in relation to the microhardness (Knoop microindentation). The binding energy values and the shape of the core level peaks are representative of the chemical bonding between the elements, and are thus related to the microhardness. Comparison of the experimental spectra with various theoretical density of states calculations as a function of x and y shows evidence of the influence of nitrogen vacancies and of the vanadium content on the mechanical properties.