With exceptional electrical and mechanical properties and at the same time air-stability, layered MoSi2N4 has recently drawn great attention. However, band structure engineering via strain and electric field, which is vital for practical applications, has not yet been explored. In this work, we show that the biaxial strain and external electric field are effective ways for the bandgap engineering of bilayer MoSi2N4 and WSi2N4. It is found that strain can lead to indirect bandgap to direct bandgap transition. On the other hand, electric field can result in semiconductor to metal transition. Our...