Step 1: Figure the gain (adjusted basis)
Your gain is not the sale price minus the purchase price. Both sides get adjusted:
- Amount realized. Sale price $900,000 − selling costs (commissions, title, transfer taxes; 5% here) $45,000 = $855,000.
- Adjusted basis. Purchase price $300,000 + purchase closing costs $5,000 + improvements $60,000 − depreciation $0 = $365,000.
- Gain. $855,000 − $365,000 = $490,000.
Every dollar of documented improvements and selling costs lowers the gain. Without them, the same sale would show a $600,000 gain. Repairs and routine maintenance are not improvements, so keep receipts for projects that add value or extend the home's life.
Step 2: Apply the §121 exclusion
Publication 523 lets you exclude up to $250,000 of gain ($500,000 married filing jointly) if you pass three tests:
- Ownership: you owned the home for at least 2 years (24 months) during the 5 years before the sale.
- Use: you lived in it as your main home for at least 2 years during those 5 years. The two years do not have to be continuous or the same years as ownership.
- Look-back: you did not exclude gain on another home sold in the 2 years before this sale.
For the $500,000 joint limit, either spouse can meet the ownership test, but both must meet the use test and neither can fail the look-back test. In the example, the single seller excludes $250,000 and has $240,000 taxable; the married couple's $490,000 gain is under $500,000, so it is fully excluded. If the couple sold for $1,100,000, the gain would be $680,000 and $180,000 would be taxable.
Step 3: Tax on the excess
The taxable part is a long-term capital gain (the home was owned more than a year), stacked on top of your other taxable income at the 0% / 15% / 20% rates. For the single seller with $120,000 of other taxable income in 2026, the whole $240,000 falls in the 15% bracket: $36,000.
The Net Investment Income Tax applies to the taxable gain too (excluded gain is not income). $120,000 + $240,000 is $160,000 over the $200,000 single threshold, so NIIT is 3.8% × $160,000 = $6,080. The joint threshold is $250,000; neither is indexed for inflation.
With $400,000 of other income, part of the gain crosses into the 20% bracket, which starts at $545,500 in 2026 and $563,200 in 2027. That is why the second row of the table is lower in 2027: $49,845 vs. $48,960.
State tax on the taxable gain
States generally start from federal income, so they follow the exclusion and tax only the $240,000. Single seller, $120,000 of other income:
| State | 2026 state tax | 2026 total tax | 2027 state tax | 2027 total tax |
|---|---|---|---|---|
| California | $22,320 | $64,400 | $22,320 | $64,400 |
| New York | $15,534 | $57,614 | $15,438 | $57,518 |
| New Jersey | $15,288 | $57,368 | $15,288 | $57,368 |
| Oregon | $23,703 | $65,783 | $23,703 | $65,783 |
| Minnesota | $21,977 | $64,057 | $21,977 | $64,057 |
| Massachusetts | $12,000 | $54,080 | $12,000 | $54,080 |
| Texas | $0 | $42,080 | $0 | $42,080 |
| Florida | $0 | $42,080 | $0 | $42,080 |
| Washington | $0 | $42,080 | $0 | $42,080 |
Washington's capital gains excise tax exempts real estate, and Texas and Florida have no income tax. State figures exclude local income taxes. See capital gains tax by state for the rules in every state.
Edge cases
Depreciation from a home office or rental use
Depreciation you took (or could have taken) after May 6, 1997 can never be excluded. If the single seller had claimed $20,000 of depreciation, the adjusted basis falls by that much, the gain rises to $510,000, and the $20,000 is taxed as unrecaptured §1250 gain at ordinary rates capped at 25% (24% here): $4,800. Total federal tax and NIIT rise from $42,080 to $47,640. For a property that was a rental for years, use the rental property sale tax calculator.
Selling early: the partial exclusion
A single owner who bought for $400,000 and sells for $520,000 after 18 months misses the 2-year tests. If the move is for a new job (or health, or certain unforeseeable events), the limit is 18/24 × $250,000 = $187,500, which covers the whole $120,000 gain. Without a qualifying reason, the full gain is taxable: $19,520 in federal tax and NIIT at $120,000 of other income.
Other situations that change the math, all covered in Publication 523: periods of nonqualified use (for example, years the home was a rental before you moved in) reduce the excludable share; a surviving spouse can use the joint limit for a sale within two years of the spouse’s death; and military and some government employees can suspend the 5-year window.
Frequently asked questions
How much tax do I pay if my home sale gain is over $250,000?
Only the gain above the exclusion is taxed, as a long-term capital gain if you owned the home more than a year. A single filer with a $490,000 gain and $120,000 of other taxable income has $240,000 taxable and owes $36,000 in federal tax plus $6,080 of Net Investment Income Tax in 2026, before state tax.
What counts toward the cost basis of my home?
The purchase price, certain settlement or closing costs you paid when you bought, and the cost of improvements that add value or extend the home’s life, such as a new roof, an addition or a kitchen remodel. Repairs and maintenance do not count. Depreciation you took or could have taken for business or rental use reduces the basis.
Do both spouses have to live in the home to get the $500,000 exclusion?
Yes. On a joint return the $500,000 limit applies when either spouse meets the ownership test, both meet the 2-year residence test, and neither excluded gain on another home in the 2 years before the sale. Otherwise each spouse's exclusion is figured separately and added together.
Can I get a partial exclusion if I sell before 2 years?
Yes, if the main reason is a change in place of work, health, or certain unforeseeable events. The limit is prorated: after 18 months a single filer gets 18/24 of $250,000, which is $187,500.
Do I owe state tax on a home sale?
Most states start from federal income, so the excluded gain is also excluded from state tax, and the taxable part is taxed at state rates. On the single example's $240,000 taxable gain, California adds $22,320; Texas, Florida and Washington add nothing.