Coffee has different effects on different types of carpets, but the best way to avoid permanent staining is to clean the area as soon as possible. If coffee sits for a few days it may never come out completely.
Plan A: Tonic Water
Step 1: Start by blotting up as much of the liquid as you possibly can, using a white towel or paper towels. If you have a wet or shop vacuum that works even better.
Step 2: Once the excess liquid has been absorbed, sprinkle the stain with your choice of tonic water, 7-Up, or club soda. Make sure you use a liberal amount and let it stand for about five minutes.
Step 3: Next, blot with a towel or extract with the shop vac to remove the liquid. Repeat the cleaning process as many times as necessary to remove the moisture. Finally, rinse the area with clean water and go through the blotting/extracting process a final time to remove excess liquid.
Plan B: Hydrogen Peroxide
Step 1: Sprinkle the coffee stain with hydrogen peroxide, letting it stand for four to six hours.
Step 2: Blot up as much of the peroxide as you can and then reapply more
Step 3: This time let it stand overnight. In the morning, blot off any excess peroxide. Sometimes hydrogen peroxide has a “bleaching effect” so be sure to first test on an inconspicuous area such as the inside corner of a closet.
If all else fails call your local carpet cleaning professional, but don’t wait too long because the difference between a spot and a stain is how long its been sitting on the carpet.