High-entropy alloy nanoparticles (HEA-NPs) show exceptional properties and great potential as a new generation of functional materials, yet a universal and facile synthetic strategy in air toward nonoxidized and precisely controlled composition remains a huge challenge. Here we provide a laser scribing method to prepare single-phase solid solution HEA-NPs libraries in air with tunable composition at the atomic level, taking advantage of the laser-induced metastable thermodynamics and substrate-assisted confinement effect. The three-dimensional porous graphene substrate functions as a microreactor during the fast heating/cooling process, which is conductive to the generation of the pure alloy phase by effectively blocking the binding of oxygen and metals, but is also beneficial for realizing accurate composition control via microstructure confinement-endowed favorable vapor pressure. Furthermore, by combining an active learning approach based on an adaptive design strategy, we discover an optimal composition of quinary HEA-NP catalysts with an ultralow overpotential for Li-CO2 batteries. This method provides a simple, fast, and universal in-air route toward the controllable synthesis of HEA-NPs, potentially integrated with machine learning to accelerate the research on HEAs.