The structures and nonlinear optical properties of a novel class of alkali metals doped electrides B12N12-M (M=Li, Na, K) were investigated by ab initio quantum chemistry method. The doping of alkali atoms was found to narrow the energy gap values of B12N12 in the range 3.96-6.70 eV. Furthermore, these alkali metals doped compounds with diffuse excess electron exhibited significantly large first hyperpolarizabilities ((0)) as follows: 5571-9157 au for B12N12-Li, 1537-18,889 au for B12N12-Na, and 2803-11,396 au for B12N12-K. Clearly, doping of the alkali atoms could dramatically increase the (0) value of B12N12 ((0)=0). Furthermore, their transition energies (E) were also calculated. The results showed that these compounds had low E values in the range 1.407-2.363 eV, which was attributed to large (0) values of alkali metals doped B12N12 nanocage. (c) 2016 Wiley Periodicals, Inc.