In this study, MgFe2O4 nanoparticles were successfully prepared through one-pot synthesis using Cajanus cajan (L.) Millsp. Leaf extract (CLE) as a source of weak bases and stabilizing agents. The optical property, structure, morphology, and particle size of the nanoparticles were analyzed. Several characterizations were performed to investigate the formation of nanoparticles. The absorption peaks at 576 cm−1 and 427 cm−1 were attributed to Mg–O vibration stretching at the tetrahedral (8a) site and Fe–O vibration stretching at the octahedral site (16d) of MgFe2O4 spinel structure, respectively. The most prominent diffraction pattern of MgFe2O4 with a spinel structure was found at 2θ = 35.55 in the crystal plane (311). The optical bandgap of MgFe2O4 was obtained to be 2.12 eV. The values of Hc, Mr, and Ms were 110.38 Oe; 1.4 emu/g; and 13.74 emu/g, respectively. All characterizations are in good agreement that MgFe2O4 nanoparticles were formed with a spherical shape with a particle size distribution of approximately 12–20 nm. Importantly, we designed a simple, cost-effective, and eco-friendly approach for synthesizing MgFe2O4 nanoparticles.