Epitaxial titanium nitride (TiN) and titanium oxynitride (TiON) thin films have been grown on sapphire substrates using a pulsed laser deposition (PLD) method in high-vacuum conditions (base pressure <3 × 10 −6 T). This vacuum contains enough residual oxygen to allow a time-independent gas phase oxidation of the ablated species as well as a time-dependent regulated surface oxidation of TiN to TiON films. The time-dependent surface oxidation is controlled by means of film deposition time that, in turn, is controlled by changing the number of laser pulses impinging on the polycrystalline TiN target at a constant repetition rate. By changing the number of laser pulses from 150 to 5000, unoxidized (or negligibly oxidized) and oxidized TiN films have been obtained with the thickness in the range of four unit cells to 70 unit cells of TiN/TiON. X-ray photoelectron spectroscopy (XPS) investigations reveal higher oxygen content in TiON films prepared with a larger number of laser pulses. The oxidation of TiN films is achieved by precisely controlling the time of deposition, which affects the surface diffusion of oxygen to the TiN film lattice. The lattice constants of the TiON films obtained by x-ray diffraction (XRD) increase with the oxygen content in the film, as predicted by molecular dynamics (MD) simulations. The lattice constant increase is explained based on a larger electrostatic repulsive force due to unbalanced local charges in the vicinity of Ti vacancies and substitutional O. The bandgap of TiN and TiON films, measured using UV−visible spectroscopy, has an asymmetric V-shaped variation as a function of the number of pulses. The bandgap variation following the lower number of laser pulses (150−750) of the V-shaped curve is explained using the quantum confinement effect, while the bandgap variation following the higher number of laser pulses (1000−5000) is associated with the modification in the band structure due to hybridization of O 2p and N 2p energy levels.