You pay capital gains tax only on the profit that exceeds the home sale exclusion, and long-term gains are taxed at 0%, 15%, or 20% depending on your taxable income, with a possible 3.8% surtax for high earners. Subtract your basis and improvements from the sale price first. Here is how the calculation works.
The Simple Version First
For most homeowners the answer is zero: if the home was your principal residence for two of the past five years, the home sale exclusion wipes out up to $250,000 of profit, or $500,000 for joint filers, before any tax rate is applied. Tax is only calculated on the portion of your profit above that exclusion, and only for sellers whose gains are unusually large.
The rate you would pay on that excess is the long-term capital gains rate, which is generally 0%, 15%, or 20% depending on your taxable income, plus a possible 3.8% net investment income surtax for high earners. Rates and thresholds can change with tax law, so treat the exact bracket figures as something to confirm with a tax professional.
Steps in order: calculate your profit, subtract the exclusion, apply your rate to whatever remains. Most sellers never reach step three.
Step 1: Calculate Your Profit Correctly
Your taxable profit is the sale price minus the costs of selling and minus your adjusted basis, and your basis is what you paid plus improvements, not the mortgage balance. Here is the formula in plain terms:
Sale price minus selling costs (commissions, transfer tax, title costs) equals your net sale amount. Then add up your original purchase price, closing costs from that purchase, and money spent on capital improvements over the years: a roof, a remodel, an addition, a new HVAC system. That sum is your adjusted basis. Subtract the basis from the net sale amount and you have your profit.
Notice what does not count: routine maintenance, like painting or repairs that merely keep the home in condition, does not raise your basis the way a capital improvement does. This is exactly why keeping improvement receipts matters, because every documented improvement lowers the tax you would owe.
Step 2: Apply the Home Sale Exclusion
Subtract the exclusion from your profit before any rate applies. Sell your primary home after meeting the two-year occupancy test and the first $250,000 of profit is excluded, or the first $500,000 for married couples filing jointly, and this exclusion can be used once every two years as long as you keep meeting the test.
If you do not fully meet the two-year test, you may still qualify for a partial exclusion when the sale is tied to a change in employment, a health reason, or an unforeseen circumstance. The IRS rules for partial exclusions are specific, so they are a conversation for your tax professional rather than a guess.
The exclusion applies per sale, not per lifetime: sell, exclude, buy again, live there two years, sell, and exclude again. That is why so many homeowners move through a series of homes over a career and never pay capital gains on any of them.
Step 3: The Rate You Would Pay
Only the profit left after the exclusion is subject to tax, at long-term capital gains rates that rise with your income. In recent years the structure has been 0% for taxpayers in the lowest brackets, 15% for the middle brackets, and 20% for the highest earners, with an additional 3.8% surtax on investment income for individuals above the income thresholds, which affects some high-income sellers.
Short-term gains, from a home owned less than one year, generally face ordinary income tax rates rather than the capital gains schedule, so ownership length matters for investors who never lived in the property. Owner-occupied sellers almost never hit this.
States matter too: Pennsylvania does not add a separate capital gains tax layer for most home sellers, but your total picture depends on your state and local situation, and the tax treatment of your specific sale should be confirmed with a professional who sees your full return.
Capital Gains vs. The Transfer Tax: Two Different Bills
Sellers often confuse the capital gains tax with the transfer tax, but they are completely separate bills: the transfer tax is a closing cost paid at settlement, while capital gains is an income tax paid with your tax return on whatever profit exceeds the exclusion. The transfer tax, about 1% state plus the local share in most of Pennsylvania, is calculated on the full sale price and paid at the closing table, and it is the same whether your profit is zero or enormous.
The capital gains calculation, by contrast, starts with your profit, subtracts the exclusion, and applies your rate only to what remains, and for most sellers that remainder is nothing. Knowing which bill you are looking at prevents both surprise and false comfort.
Both numbers appear in different places: the transfer tax on your settlement statement, the capital gain on your tax return. Keep both pieces of paper, because the settlement statement documents the sale price and the closing costs, both of which feed the capital gains math.
If either number is significant in your situation, run both through your tax professional before you set expectations, since the planning moves, like timing the closing or deferring a 1031 exchange for an investment property, are only available before the deal is done.
Smarty's Advice Expert Insight
John Smart (Smarty) · Smarty Home Solutions / eXp Realty Agent, AI Certified Agent
Your Next Step for Capital Gains
Do the math in order: profit minus exclusion, then the rate on what remains. Good recordkeeping and the two-year occupancy rule are the two levers that keep most Pennsylvania sellers at zero.
John Smart, AI-Certified Agent with eXp Realty helps sellers across Greater Philadelphia project their closing numbers. Call 215-598-6848 or schedule a free consultation, and bring your unique situation to a qualified tax advisor for exact figures.
Related reading: The home sale exclusion | Reading your net sheet