Most townhouses need between 6 and 14 solar panels to offset 100% of their electricity use — a system ranging from roughly 2.5 kW to 5 kW, costing $7,500–$18,000 before the 30% federal Investment Tax Credit (ITC). The exact number of solar panels for a townhouse depends on three variables: your annual kWh consumption, the peak sun hours at your address, and the watt rating of the panels you choose.
Those three factors explain why two identical townhouses on the same street can end up with different system sizes. A townhouse in Arizona averaging 5.5 peak sun hours per day needs fewer panels than the same floorplan in Massachusetts with only 4.0 peak sun hours. Panel efficiency matters too — a 400W panel produces 14% more power than a 350W panel from the same roof area, which is limited on a townhouse to begin with.