Severe safety concerns are impeding the large-scale employment of lithium/sodium batteries. Conventional electrolytes are highly flammable and volatile, which may cause catastrophic fires or explosions. Efforts to introduce flame-retardant solvents into the electrolytes have generally resulted in compromised battery performance because those solvents do not suitably passivate carbonaceous anodes. Here we report a salt-concentrated electrolyte design to resolve this dilemma via the spontaneous formation of a robust inorganic passivation film on the anode. We demonstrate that a concentrated electrolyte using a salt and a popular flame-retardant solvent (trimethyl phosphate), without any additives or soft binders, allows stable charge–discharge cycling of both hard-carbon and graphite anodes for more than 1,000 cycles (over one year) with negligible degradation; this performance is comparable or superior to that of conventional flammable carbonate electrolytes. The unusual passivation character of the concentrated electrolyte coupled with its fire-extinguishing property contributes to developing safe and long-lasting batteries, unlocking the limit toward development of much higher energy-density batteries.