Lithium metal anodes offer high theoretical capacities (3,860 milliampere-hours per gram)1, but rechargeable batteries built with such anodes suffer from dendrite growth and low Coulombic efficiency (the ratio of charge output to charge input), preventing their commercial adoption2,3. The formation of inactive (‘dead’) lithium— which consists of both (electro)chemically formed Li+ compounds in the solid electrolyte interphase and electrically isolated unreacted metallic Li0 (refs 4,5)—causes capacity loss and safety hazards. Quantitatively distinguishing between Li+ in components of the solid electrolyte interphase and unreacted metallic Li0 has not been possible, owing to the lack of effective diagnostic tools. Optical microscopy6, in situ environmental transmission electron microscopy7,8, X-ray microtomography9 and magnetic resonance imaging10 provide a morphological perspective with little chemical information. Nuclear magnetic resonance11, X-ray photoelectron spectroscopy12 and cryogenic transmission electron microscopy13,14 can distinguish between Li+ in the solid electrolyte interphase and metallic Li0, but their detection ranges are limited to surfaces or local regions. Here we establish the analytical method of titration gas chromatography to quantify the contribution of unreacted metallic Li0 to the total amount of inactive lithium. We identify the unreacted metallic Li0, not the (electro)chemically formed Li+ in the solid electrolyte interphase, as the dominant source of inactive lithium and capacity loss. By coupling the unreacted metallic Li0 content to observations of its local microstructure and nanostructure by cryogenic electron microscopy (both scanning and transmission), we also establish the formation mechanism of inactive lithium in different types of electrolytes and determine the underlying cause of low Coulombic efficiency in plating and stripping (the charge and discharge processes, respectively, in a full cell) of lithium metal anodes. We propose strategies for making lithium plating and stripping more efficient so that lithium metal anodes can be used for next-generation high-energy batteries.