Coca-Cola was named back in 1885 for its two “medicinal” ingredients: extract of coca leaves and kola nuts. Just how much cocaine was originally in the formulation is hard to determine, but the drink undeniably contained some cocaine in its early days. Frederick Allen describes the public attitude towards cocaine that existed as Coca-Cola’s developers worked on perfecting their formula in 1891:

The first stirrings of a national debate had begun over the negative aspects of cocaine, and manufacturers were growing defensive over charges that use of their products might lead to “cocainism” or the “cocaine habit”. The full-throated fury against cocaine was still a few years off, and Candler and Robinson were anxious to continue promoting the supposed benefits of the coca leaf, but there was no reason to risk putting more than a tiny bit of coca extract in their syrup. They cut the amount to a mere trace.

Allen also explains that cocaine continued to be an ingredient in the syrup in order to protect the trade name “Coca-Cola”:

But neither could Candler take the simple step of eliminating the fluid extract of coca leaves from the formula. Candler believed that his product’s name had to be descriptive, and that he must have at least some by-product of the coca leaf in the syrup (along with some kola) to protect his right to the name Coca-Cola. Protecting the name was critical. Candler had no patent on the syrup itself. Anyone could make an imitation. But no one could put the label “Coca-Cola” on an imitation so long as Candler owned the name. The name was the thing of real value, and the registered trademark was its only safeguard. Coca leaves had to stay in the syrup.

How much cocaine was in that “mere trace” is impossible to say, but we do know that by 1902 it was as little as 1/400 of a grain of cocaine per ounce of syrup. Coca-Cola didn’t become completely cocaine-free until 1929, but there was scarcely any of the drug left in the drink by then:

By Heath’s calculation, the amount of ecgonine [an alkaloid in the coca leaf that could be synthesized to create cocaine] was infinitesimal: no more than one part in 50 million. In an entire year’s supply of 25-odd million gallons of Coca-Cola syrup, Heath figured, there might be six-hundredths of an ounce of cocaine.

So, yes, at one time there was cocaine in Coca-Cola. But before you’re tempted to run off claiming Coca-Cola turned generations of drinkers into dope addicts, consider the following: back in 1885 it was far from uncommon to use cocaine in patent medicines (which is what Coca-Cola was originally marketed as) and other medical potions. When it first became general knowledge that cocaine could be harmful, the backroom chemists who comprised Coca-Cola at the time (long before it became the huge company we now know) did everything they could with the technology they had available at the time to remove every trace of cocaine from the beverage. What was left behind (until the technology improved enough for it all to be removed) wasn’t enough to give a fly a buzz.