Every paint can prints its coverage in square feet per gallon, so the entire project starts with knowing your total wall area. Clear the walls as best you can, grab a tape measure and a notepad, and work through the room one wall at a time.
Measure the length of each wall and multiply it by the ceiling height to get that wall's area, then add all the walls together. Doors and windows don't need paint, so measure each opening and subtract it from the total — a standard interior door is about 21 square feet. If you want a second opinion on the math, a room size calculator can confirm your figures before you head to the paint store.
Most rooms need two coats for even coverage, so double the net wall area before dividing by the coverage listed on the can. If you are painting the ceiling too, add its area — simply length times width. Buy a little more than the calculation says; an unopened can go back to the store, but a visible color mismatch halfway across a wall cannot be fixed cheaply.
A quick example: a 12 by 14 foot room with 8-foot ceilings has 416 square feet of wall. Subtract a door and a window (about 36 square feet combined) to get 380, double it for two coats to reach 760, and divide by 350 square feet per gallon — you need about 2.2 gallons, so buy two gallons and a quart for touch-ups.
— Inshal