Many years ago, the Samsung Galaxy Note 7 gained notoriety when its batteries caught fire in a series of incidents. There’s been a steady stream of similar, though isolated, incidents ever since. However, despite the high-profile coverage of batteries gone wrong, the vast majority of Li-ion batteries are safe.
The chemical reaction that occurs inside a lithium-ion cell is complex, but as in any battery there’s a negative and a positive electrode. In lithium batteries the negative is a lithium-carbon compound, and the positive is cobalt oxide (though many battery makers are moving away from cobalt). These two compounds cause a reaction that is safe when controlled and delivers energy to your devices. When the reaction gets out of control, though, you end up with earbuds melting in your ears.
What changes a safe reaction to an uncontrolled reaction can be any number of things: excess heat, physical damage during use, physical damage during manufacture, or using the wrong charger.
The three basic rules that have kept me safe (thus far) through testing dozens and dozens of batteries are:
Avoiding cheap wall outlet adapters, cords, and chargers is most important. These are your most likely source of problems. Those chargers you see on Amazon for $20 cheaper than the competition? Not worth it. They probably got the price down by skimping on insulation, leaving out power-management tools, and ignoring the basics of electrical safety. Price alone is no guarantee of safety, either. Buy from reputable companies and brands.
Then there’s heat. Too much of it can cause all manner of problems, both in terms of discharge and in terms of safety. Avoid heat, and pay attention to your batteries when they’re charging. If your device gets overly hot when charging, this can be a sign of problems.
Similarly, beware any swollen, bulging, or otherwise misshapen batteries.