Cavities form when bacteria in your mouth feed on sugars and produce acid that dissolves the minerals in your teeth. This process isn’t instant. It’s a slow, back-and-forth chemical battle between acid attacks and your saliva’s natural repair system, and a cavity only develops when the damage side wins over weeks or months.
What Happens Inside Your Mouth
Your mouth is home to hundreds of species of bacteria, but a few are especially good at causing decay. The main culprit is a bacterium called Streptococcus mutans, which thrives on sugars from the food you eat. When you consume something sweet or starchy, these bacteria ferment the sugars and produce lactic acid as a waste product. That acid gets trapped between the sticky film of bacteria on your teeth (plaque) and the tooth surface, creating a highly acidic microenvironment that can drop as low as pH 3.0, which is roughly as acidic as vinegar.
Your tooth enamel is made of a mineral called hydroxyapatite, a crystalline structure built from calcium and phosphate. This mineral is strong, but it has a breaking point. When the pH at the tooth surface drops below about 5.5, the acid begins to pull calcium and phosphate ions out of the enamel crystals, dissolving them. This process is called demineralization. Every time you eat something sugary, your teeth undergo a mini acid attack that lasts until your saliva can wash away the acid and bring the pH back up.
Your Saliva Fights Back
Saliva is your body’s primary defense against cavities. It does three things: it physically rinses acid and food particles off your teeth, it contains buffering compounds that neutralize acid and raise the pH back to safe levels, and it carries dissolved calcium and phosphate ions that can redeposit onto damaged enamel. This repair process, called remineralization, is essentially the reverse of the acid attack. Above pH 5.5, saliva is supersaturated with the minerals teeth are made of, meaning those minerals naturally settle back onto the enamel surface.
Specialized proteins in saliva also play a role. Some bind to calcium ions to prevent minerals from clumping in the wrong places, while others coat the tooth surface and act as a protective barrier. This is why dry mouth, whether caused by medication, medical conditions, or simply not drinking enough water, significantly increases your risk of cavities. Without adequate saliva flow, acid lingers longer and the repair process stalls.
When Damage Outpaces Repair
A cavity doesn’t appear overnight. It forms when acid attacks happen more frequently or last longer than your saliva can keep up with. If you sip a sugary drink over three hours, for instance, your teeth are under nearly constant acid exposure with no recovery window. The same goes for frequent snacking on carbohydrate-rich foods. Each exposure restarts the acid clock.
Poor oral hygiene compounds the problem. When plaque isn’t removed by brushing, it thickens into a dense bacterial film that traps acid right against the enamel. The acid produced underneath this film can’t be neutralized by saliva because saliva can’t penetrate the plaque layer effectively. Over time, this one-sided battle tips toward mineral loss.
Research estimates that visible white spot lesions, the earliest sign of enamel damage, can appear in as little as three weeks under conditions of poor hygiene and frequent sugar exposure. From that initial white spot to a fully cavitated hole in a smooth tooth surface takes roughly 18 months, give or take about 6 months depending on individual factors like diet, saliva flow, and fluoride exposure.
The Five Stages of Decay
Cavities progress through distinct stages as they eat deeper into the tooth’s structure.
The first stage is a white spot on the enamel surface. This chalky patch means minerals have been lost from the subsurface enamel, but the outer layer is still intact. No hole exists yet, and at this point, the damage is fully reversible with improved hygiene and fluoride.
In the second stage, the enamel breaks down further. The white spot may darken to brown, and small holes begin to form in the enamel. This is what most people think of as a cavity. Once a physical hole exists, the damage can no longer heal on its own and needs to be filled.
The third stage is when decay reaches the dentin, the softer tissue beneath the enamel. Dentin contains tiny fluid-filled tubes that connect to the nerve-rich pulp at the tooth’s center. Because dentin is softer and more porous than enamel, decay accelerates once it gets past the enamel barrier. This is also where you start to notice sensitivity or pain. The critical pH for dentin dissolution is around 6.0, meaning it starts breaking down at a lower level of acidity than enamel does.
In the fourth stage, bacteria reach the pulp, the innermost part of the tooth containing nerves and blood vessels. This causes inflammation and often intense, throbbing pain. The fifth stage involves abscess formation, where infection spreads beyond the tooth root into the surrounding bone and tissue.
Why Cavities Hurt
Enamel has no nerve endings, which is why early cavities are painless. You can lose significant mineral from your enamel without feeling a thing. The trouble starts when decay reaches the dentin layer. Those tiny fluid-filled tubes running through the dentin act like hydraulic sensors. When something cold, hot, sweet, or acidic touches exposed dentin, it causes the fluid inside the tubes to shift rapidly. That fluid movement triggers nerve fibers at the base of the tubes, producing a short, sharp pain.
This is the classic “zing” you feel when ice cream hits a sensitive tooth. The nerve fibers responsible react quickly and produce that immediate, well-localized sting. If decay reaches the pulp, a different type of nerve fiber takes over, one that produces a deeper, duller, harder-to-pinpoint ache that can linger for hours.
How Fluoride Changes the Chemistry
Fluoride works by swapping into the mineral structure of your teeth. When fluoride is present during remineralization, it replaces part of the original hydroxyapatite with a modified mineral called fluorapatite. This matters because fluorapatite is harder to dissolve. Regular enamel starts breaking down at pH 5.5, but fluorapatite holds up until the pH drops to about 4.5. That difference of one full pH unit is significant in practice, because it means your teeth can withstand more frequent or more severe acid attacks before mineral loss begins.
Fluoride also encourages remineralization to happen faster. When calcium and phosphate from saliva encounter fluoride at the tooth surface, they’re more likely to crystallize into new mineral. This is why fluoride toothpaste and fluoridated water are effective even though they deliver relatively small amounts of fluoride. The benefit comes from having fluoride present at the tooth surface repeatedly throughout the day, tipping the balance back toward repair during the constant cycle of acid attacks.
What Makes Some People More Prone
The demineralization-remineralization cycle is influenced by several factors, which is why some people get cavities more easily than others even with similar brushing habits. Saliva composition varies between individuals. Some people naturally produce saliva with higher concentrations of calcium and phosphate, giving them a stronger repair system. Others have saliva that’s less effective at buffering acid.
Diet plays an outsized role. Frequency of sugar exposure matters more than total amount. Eating a candy bar in five minutes causes one acid attack lasting roughly 20 to 30 minutes. Nursing a soda over an afternoon keeps the pH below 5.5 almost continuously. The shape of your teeth matters too. Deep grooves and pits on molars trap bacteria and food in spots a toothbrush can’t easily reach, which is why the chewing surfaces of back teeth are the most common site for cavities in children and teenagers.
The mineral composition of enamel itself varies. Enamel with higher carbonate content is weaker because carbonate reacts with acid more readily than phosphate does, dissolving at lower acid concentrations. This is partly genetic and partly influenced by nutrition during the years when teeth are developing.

