Most couches and chairs have two kinds of cushions: removable ones and attached ones. Removable cushions often have a zipper on the back, making foam replacement easy. Attached cushions do not have zippers, however, meaning that you must cut them open to replace the foam. This is not a complicated process, and your work will be hidden from view when the cushion is put back in place.
Lift each cushion to expose the seam on its underside. Some cushions are only attached along the top edge, and can be lifted quite easily. Others are attached all the way around, and can only be shifted a small amount.
Cut the seam open with a seam ripper, slicing through one or two stitches at a time until the entire seam has been opened.
Pull the old foam out of the cushion.
Measure the height, width and depth of the foam with a fabric tape measure.
Select a block of replacement upholstery foam that is as close as possible to the measurements of the original. If in doubt, purchase a block that is slightly too large.
Use an electric carving knife to shave portions off of the new foam block, reducing it to the size and shape of the original foam.
Insert the new foam into the empty cushion fabric, squashing it as needed to get it in place. Make sure the foam fills the fabric completely before moving on to the next step.
Pin the seam closed with straight pins.
Sew the seam closed using a needle and strong thread that matches the color of the cushion fabric. Remove the pins as you sew, and keep your stitches as small as possible.
Push the cushion back in place. As the seam is on the underside, your repair will be hidden.