How it works
When you sell your main home, up to $250,000 of the gain is free of federal tax, or $500,000 on a joint return, if you owned it and lived in it for 2 of the last 5 years. The gain is the sale price, less selling costs, less what the home cost you. Depreciation and any gain above the limit are taxed.
Improvements add to what you paid for the home, and that includes wiring for a car charger, which you can size with the EV charger circuit calculator. Property tax paid in the year of the sale may be deductible, within the limit the SALT deduction calculator works out.
If you are buying again, work out the payment on the next mortgage before you commit the proceeds. The mortgage calculator also shows how a larger deposit changes the interest.
The formula
gain = sale price − selling costs − (purchase price + closing costs + improvements − depreciation)
excluded = the smaller of the maximum exclusion and (gain − depreciation − gain not excludable)
maximum exclusion = $250,000 ($500,000 joint) when owned and used 24 months or more
reduced maximum = $250,000 × months (up to 24) ÷ 24, for a job, health or unforeseen reason
tax = depreciation at up to 25% + remaining gain at 0%, 15% or 20% + 3.8% net investment income tax
What each input means
- Sale price, selling costs, purchase price, closing costs and improvements. Together these give the gain. The closing statements from your purchase and your sale list most of them.
- Months owned and months you lived in it. Decide whether you meet the 2-of-5-years test.
- Your other income. Sets which capital gains rate applies.
- Depreciation claimed, months not your main home and why you sold early. Leave these alone unless you rented the home out, claimed a home office or sold before 2 years were up.
A worked example
A single owner sold a home for $850,000 after 10 years, living there the whole time, with $100,000 of other income.
- Gain: $850,000 − $50,000 selling costs − ($350,000 + $5,000 + $45,000) = $400,000.00
- Excluded: $250,000.00, leaving $150,000 taxable
- Taxable income before the gain is $100,000 − $16,100 = $83,900, above the 0% ceiling of $49,450, so all $150,000 is taxed at 15%: $22,500.00
- Net investment income tax: income of $250,000 is $50,000 over $200,000, so 3.8% × $50,000 = $1,900.00
- Total federal tax: $24,400.00
How the figures are rounded
Amounts are worked out to the cent. The gain is the sale price less selling costs, less the adjusted cost basis.
What it leaves out
State tax, the military and disability extensions, homes used partly for business, homes acquired in a like-kind exchange, the qualified opportunity zone rules and the surviving spouse rules. The net investment income tax uses your other income as given, without adjustments.
Common questions
Who qualifies for the exclusion?
You must have owned the home and used it as your main home for at least 2 of the 5 years before the sale. The 2 years do not have to be in a row. You cannot have excluded the gain on another home in the 2 years before.
What if I lived there less than 2 years?
You may get a reduced exclusion if you sold because of a job change, a health reason or an unforeseen event. The limit is cut in proportion, so 12 months gives half of $250,000, or $125,000.
Is depreciation taxed?
Yes. Depreciation you claimed or could have claimed since 6 May 1997, for example for a home office or a rental, cannot be excluded. It is taxed at your ordinary rate, up to 25%.
What if I rented the home before moving in?
The part of the gain for time it was not your main home before you lived in it cannot be excluded. It is the gain after depreciation, multiplied by the share of ownership that was non-qualifying use after 2008.
How is the rest of the gain taxed?
As a long-term capital gain at 0%, 15% or 20%, on top of your other income. A 3.8% net investment income tax can also apply if your income is over $200,000, or $250,000 on a joint return.
Sources and review
The method and any rates on this page come from:
- Publication 523: Selling Your Home (2025), Internal Revenue Service
- Topic no. 701: Sale of your home, Internal Revenue Service
- Treasury Regulation 1.121-3: reduced maximum exclusion, Legal Information Institute, Cornell Law School
- Revenue Procedure 2025-32: 2026 capital gains thresholds, Internal Revenue Service