Aluminum nitride nanocages (Al12N12) doped with alkaline earth metals (Be, Mg, and Ca) are theoretically designed and their geometrical structures, electronic properties, and nonlinear optical responses are explored using density functional theory (DFT) calculations. The results revealed that the doped complexes are thermodynamically quite stable, and alkaline earth metals effectively narrow the highest occupied molecular orbital (HOMO)–lowest unoccupied molecular orbital (LUMO) energy gaps (EH-L) of the complexes. More importantly, the adsorption of alkaline earth metal significantly increased the first hyperpolarizability (βo) values from 0 au of the pristine aluminum nitride nanocage up to 7769 au for the doped complexes. This study successfully demonstrates that the doping of alkaline earth metal on aluminum nitride nanocage is an effective approach to enhance electronic properties and NLO response of the system. In future these complexes can act as promising candidates to be used as high-performance nonlinear optical (NLO) materials for optoelectronic devices.