Blot or extract as much of the liquid as possible with a dry, clean towel. Use a steam cleaner with plain cold water or a washrag and attempt to remove as much of the coffee as possible from the carpet fibers. If the stain remains, mix a spray bottle with 50/50 water and plain white vinegar and blot carefully in the carpet fibers. Let it sit for approximately 15 minutes. Coffee is an acid which settles in the actual carpet fibers, and the vinegar is a stronger acid which will displace the coffee stain. Blot carefully to remove moisture. If it looks ok, steam clean to extract the vinegar with plain cold water, or use a clean rag with cold water.
If a stain remains after the carpet has dried, go to your medicine cabinet and grab the bottle of hydrogen peroxide. Pour it directly on the stain and massage in and around the stained fibers. Let it dry, and repeat if needed. You do not need to steam clean as the hydrogen peroxide will turn to water when exposed to sunlight. You may need to apply the hydrogen peroxide a few times to completely remove the stain.
A couple points to remember.
- Always use COLD water as heat will set the stain.
- Be gentle. Blot do not rub as you risk fraying the carpet fibers.
- Never use soap on the carpet as a residue will remain which will attract dirt in the future.