Ab initio band structure calculations were performed for MgSiN2 and Mg3N2. Calculations show that both nitrides are semiconductors with direct energy gaps at . The valence bands are composed mainly of N 2p states hybridized with s and p characters of the metals. The bottom of the conduction band consists of the s characters of Mg and N for Mg3N2, as well as for MgSiN2, while the characters of Si are higher in energy. The optical diffuse spectra show an energy gap of about 2.8 eV for Mg3N2 and 4.8 eV for MgSiN2, in agreement with the calculated values.