We leverage ultrahigh-speed synchrotron x-ray imaging and high-fidelity multiphysics modeling to identify strikingly simple yet universal scaling laws for keyhole stability and porosity in metal three-dimensional (3D) printing. The laws apply broadly and remain accurate for different materials, processing conditions, and printing machines. We define a new dimensionless number, the Keyhole number, to predict aspect ratio of a keyhole and the morphological transition from stable at low Keyhole number to chaotic at high Keyhole number. Furthermore, we discover inherent correlation between keyhole stability and porosity formation in metal 3D printing. By reducing the dimensions of the formulation of these challenging problems, the compact scaling laws will aid process optimization and defect elimination during metal 3D printing, and potentially lead to a quantitative predictive framework.