Carpet foam is an adhesive that carpet layers use to attach carpet to a hardwood floor. If you want to remove the carpet, or an area of the carpet, you will have to pull up the carpet and remove the foam adhesive residue from the hardwood and possibly also from the old carpet. Be careful whenever working with hardwood floors to not apply too much water or water-based liquids, as these could seep into the hardwood and cause it to warp and buckle.
Put on gloves and goggles to protect your hands eyes from harsh chemical solvents. Open the windows to ventilate the room.
Soak a clean cloth in mineral spirit and wring it out so that it is wet but not dripping.
Lay the cloth over the foam residue and let it sit for several minutes. The longer you let it sit the more the white spirit will work into the foam residue and the easier it will be to remove.
Remove the cloth once the foam is soft enough to scrape.
Scrape off the foam residue with a plastic putty knife. Do not use a metal knife unless you are also plan to sand and refinish the floors. Metal knives can easily scratch the wood floor.
Rinse the area with a cloth soaked in clear water. Dry it completely. Do not leave standing water on wood floors as this can cause it to buckle.
Repeat the process with the rest of the foam residue.
Mix 1 cup lukewarm water with ¼ tsp mild liquid dish soap. Do not use soap that contains bleach.
Apply the soapy solution to the adhesive residue on the carpet with a clean cloth.
Brush the adhesive residue gently with a toothbrush to remove as much of it as possible.
Dab nail polish remover on any adhesive residue that is left with a clean cloth.
Repeat the process until you remove all of the adhesive on the carpet.