Coffee is a dye. That's the whole problem — the same tannins that stain a mug brown over months will stain carpet in hours, and heat-set tannins are among the hardest stains in the house. The clock matters more than the technique: fresh, this is a five-minute fix; next week, it's a professional conversation.
The five steps, in order
1. Blot everything you can, immediately. Clean white cloth or paper towels, pressed hard — stand on them. Swap for dry ones until nothing more transfers. Never rub: rubbing spreads the dye outward and drives it down into the pile.
2. Mix the solution. One tablespoon of dish soap, one tablespoon of white vinegar, two cups of warm water. The vinegar breaks down tannins; the soap carries them out. Test it first on a hidden corner of the carpet — thirty seconds of caution against a bleached spot you'd own forever.
3. Work outside-in. Apply the solution with a clean cloth, starting at the stain's edge and working toward the center so you don't spread the ring. Blot with a fresh section of cloth as the brown lifts, and keep going as long as color keeps transferring.
4. Rinse and dry. Mist the area with cold water and blot dry. Skipping the rinse leaves soap in the fibers, and soap residue collects dirt — the ghost stain that shows up gray a month later is usually detergent, not coffee.
5. Baking soda for the stubborn remainder. Thick paste of baking soda and water, spread over what's left, 10–15 minutes to dry, then vacuum. It lifts residual discoloration and takes the stale-coffee smell with it.
The latte exception
Black coffee is tannin only. Coffee with milk or cream adds protein and fat — and protein sets with heat. For any milky spill, keep everything cold (cold water rinse, no steam, no hot water) and finish with an enzymatic cleaner after step 4, the same kind sold for pet stains. Treat a latte like a food stain that happens to be brown.
When to stop DIYing
Two full rounds of the above is the limit. A stain that survives them has bonded with the fiber, and a third round of home scrubbing mostly damages the pile and sets the remainder. Set-in tannins respond to professional hot-water extraction with tannin-specific pre-treatment — for our crews it's a routine spot job, usually gone in one pass, and honestly priced as one → Carpet cleaning service
Not spilling it twice
The realistic preventions: a lidded mug for the commute path between the kitchen and the desk (the hallway carpet takes more coffee than the kitchen floor does), a stain-protector treatment on the carpet after any deep clean, and keeping the pour-and-stir zone over hard flooring. And when a spill happens anyway — they all do — the answer is already in your cabinet: soap, vinegar, and speed.
More carpet care from the same playbook → Carpet Cleaning in San Jose: The Complete Owner's Guide