The structural, elastic, electronic and optical properties of the cubic M3N4 (M = Zr, and Hf) have been studied for different pressure. The computational method is based on the Pseudo-Potential Plane-Wave method (PP-PW). The exchange correlation has been treated using the Generalized Gradient Approximation (GGA). We have evaluated the ground-state quantities such as lattice parameter, bulk modulus and its pressure derivative as well as the elastic constants. The elastic constants and their pressure dependence are calculated using the static finite strain technique. We derived the bulk and shear moduli, Young’s modulus and Poisson’s ratio for ideal polycrystalline Zr3N4 and Hf3N4 aggregate. Also, we have presented the results of the band structure and densities of states. Furthermore, in order to understand the optical properties, the dielectric function, optical reflectivity, refractive index, extinction coefficient, and absorption coefficient are calculated for radiation up to 20 eV. We predicted the elastic, electronic and optical properties of Zr3N4 and Hf3N4 compounds.