Computational simulations using density functional theory (DFT) were performed to show that biaxial strain engineering within the range of −8% to +8% is an effective method for modifying the fundamental properties of two-dimensional (2D) transition metal carbides (MXenes). In this work, we computationally explored the effect of both compressive (0 to −8%) and tensile (0 to +8%) strain on the structural, electronic, and optical properties of M2CO2 MXenes (M = Ti, Zr, Sc and Hf) nanolayers. When compressive strains are applied, the charge transfer between layers increases because of decreased interlayer coupling. Conversely, tensile strains result in the opposite behavior. The strain-tunable band gap effect in Mo2CO2 nanolayers is revealed by investigating the valence band maximum (VBM) and conduction band minimum (CBM) in the band structure under biaxial strain. It is observed that the indirect-to-direct band gap transition occurs when the tensile strain is applied to Sc2CO2 and Ti2CO2 nanolayers. In most samples, the energy gap increases with an increase in tensile strain and decreases with an increase in compressive strain. The optical absorption coefficient indicates considerable absorption in the visible to ultraviolet (UV) region. Additionally, the absorption can be influenced by biaxial strains. In particular, under compressive strains (−8%) and Z-polarized light, the UV absorption peak in Hf2CO2, Ti2CO2, and Zr2CO2 reaches 68 %, 78 %, and 113 % respectively. The results indicate that these M2CO2 MXenes nanolayers will have significant potential for applications in tunable optoelectronic devices.