Chitosan (CS) is one of the most abundant biopolymers in nature, with superior properties including biocompatibility, biodegradability, lack of toxicity, antimicrobial activity, acceleration of wound healing, and stimulation of the immune system. In this study, chitosan was extracted from the exoskeletons of the beetle (Pimelia Payraudi Latreille) and then used for the biosynthesis of MgO NPs and ZnO NPs. The extracted chitosan exhibited excellent physicochemical properties, including high extraction yield (39%), high degree of deacetylation (90%), low ash content (1%), high fat-binding capacity (366%), and odd crystallinity index (51%). The MgO NPs and ZnO NPs exhibited spherical morphology with crystallite sizes of 17 nm and 29 nm, particle sizes of about 20-70 nm and 30-60 nm, and bandgap energy of 4.43 and 3.34 eV, respectively. Antibacterial assays showed that the extracted chitosan showed high antibacterial activity against Gram-(+/-) bacteria, while ZnO NPs showed much stronger antibacterial activity against Gram-(+) bacteria than against Gram(-) bacteria. For MgO NPs, the antibacterial activity against Gram-(+) bacteria was lower than that against Gram-(-) bacteria. The results suggest that the synthesized MgO NPs and ZnO NPs are excellent antibacterial agents for therapeutic applications.