When you sell your main home, the capital gains tax exclusion for a primary residence lets you keep up to $250,000 of profit tax-free if you file singly, or up to $500,000 if you’re married filing jointly. To qualify, you have to have owned the home and lived in it as your principal residence for at least two of the five years before the sale.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence Anything above the cap is taxable, and a few situations — rental history, a home office, or a sale before you hit the two-year mark — can shrink the exclusion or carve out a piece that doesn’t qualify.
How to Calculate the Gain
Your taxable gain is not the sale price minus what you paid. It’s the sale price, minus selling expenses, minus your adjusted basis in the property.2Internal Revenue Service. Publication 523 – Selling Your Home
Adjusted basis starts with your purchase price, including the amount you borrowed. Add qualifying closing costs from the purchase: title search and title insurance, legal fees, recording fees, transfer and stamp taxes, survey fees, and utility hookup charges.3Internal Revenue Service. Publication 551 – Basis of Assets Then add the cost of capital improvements — projects that add value, extend the home’s life, or adapt it to a new use. A new roof, an addition, a full kitchen renovation, or a central HVAC install all count. Routine repairs do not.
Two adjustments cut your basis back down. If you claimed energy-related credits or subsidies for improvements like solar panels, subtract the credit amount from your basis.2Internal Revenue Service. Publication 523 – Selling Your Home And if you ever rented the property or used part of it as a home office, subtract the depreciation that was claimed — or that could have been claimed, whether you took it or not.4Internal Revenue Service. Property (Basis, Sale of Home, Etc.) 5
On the sale side, subtract your selling expenses from the sale price before comparing to basis. Real estate commissions are usually the biggest item. Legal fees at closing, advertising costs if you sold the home yourself, and any mortgage points you paid on the buyer’s behalf also count.5Internal Revenue Service. Topic No. 504 – Home Mortgage Points The result — sale price minus selling expenses minus adjusted basis — is your realized gain.
Keep documentation. The IRS says to hold records supporting your basis until at least three years after the return for the sale year is due,2Internal Revenue Service. Publication 523 – Selling Your Home which in practice means saving improvement receipts for the entire time you own the home. Lose the paperwork and you lose the basis increase that goes with it.
The Ownership and Use Tests
The exclusion has two tests, both measured against the five-year window ending on the sale date. Ownership: you owned the home for at least 24 months out of that five years. Use: it was your principal residence for at least 24 months out of that same five years.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence The two years don’t have to be consecutive, and the ownership and use windows don’t have to overlap. Short absences for vacations or seasonal travel don’t break the use clock, even if you rented the place out while you were away.2Internal Revenue Service. Publication 523 – Selling Your Home
You can only claim the exclusion once every two years. If you used it on a different home sale within the prior 24 months, you’re out for this one.
How Much You Can Exclude
Single filers who pass both tests can exclude up to $250,000 of gain. Married couples filing jointly can exclude up to $500,000, but the joint cap has stricter rules: only one spouse needs to meet the ownership test, both spouses must meet the use test, and neither spouse can have used the exclusion in the past two years.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence If only one spouse meets the use test, the couple is capped at $250,000.
Surviving Spouses
If your spouse died and you sell the home within two years of the date of death, you can still claim the full $500,000 exclusion, provided the couple would have qualified for the joint exclusion immediately before the death.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence After two years, you’re back to the $250,000 single-filer limit.
Divorce
If you received the home from a spouse or former spouse in a divorce or separation, you can tack their ownership period onto yours. You still need to satisfy the use test personally, unless the divorce agreement lets your ex live there and they actually use it as their main home — in that case, their use can count for you.2Internal Revenue Service. Publication 523 – Selling Your Home
Selling Before You Hit Two Years
If you sell before completing 24 months of ownership or use, you may still get a reduced exclusion when the sale is driven by a qualifying life event. The IRS recognizes three categories:
- A change in employment where the new workplace is at least 50 miles farther from the home than the old one was
- Health reasons, with a physician’s recommendation to move
- Unforeseen circumstances, including natural disasters, involuntary conversion, job loss triggering unemployment eligibility, death of a household member, divorce, or an inability to cover basic living expenses after a change in employment
The partial exclusion is calculated by multiplying the full cap by the fraction of 24 months you actually satisfied. A single filer who owned and used the home for 12 months before a qualifying job move gets 12/24 of $250,000, or $125,000.2Internal Revenue Service. Publication 523 – Selling Your Home
When Part of the Gain Can’t Be Excluded
Two rules limit the exclusion when the home wasn’t always your primary residence. They apply in a specific order.
Depreciation Recapture
Any depreciation you claimed (or could have claimed) on the home — because it was a rental or you used it for a home office — is stripped out of your gain first and cannot be excluded under Section 121. That amount is taxed as unrecaptured Section 1250 gain at a federal rate of up to 25%.4Internal Revenue Service. Property (Basis, Sale of Home, Etc.) 5
Non-Qualified Use
After depreciation is set aside, look at whether the home had any periods of non-qualified use — time after December 31, 2008, when it wasn’t your (or your spouse’s) principal residence.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence The gain allocated to those months can’t be excluded. Divide non-qualified months by total months of ownership, then apply that fraction to the remaining gain.
Here’s how the two rules stack. Say you owned a home for 10 years, rented it for the first 3 (all after 2008), then moved in for 7 years. You claimed $50,000 in depreciation, and your total gain is $300,000. First, $50,000 is pulled out for depreciation recapture, taxed at up to 25%. Of the remaining $250,000, 30% (36 non-qualified months divided by 120 total months) is $75,000 taxed at regular capital gains rates. The last $175,000 qualifies for the Section 121 exclusion.
Tax Rates on the Gain You Can’t Exclude
Gain that exceeds the exclusion, falls into a non-qualified use period, or represents depreciation recapture is taxable. Long-term capital gains — for a home owned more than a year — are taxed at 0%, 15%, or 20% federally, depending on your taxable income and filing status.6Internal Revenue Service. Topic No. 409 – Capital Gains and Losses For 2026, the 15% rate starts at $49,450 of taxable income for single filers and $98,900 for joint filers. The 20% rate applies above $545,500 (single) and $613,700 (joint).
The 3.8% Net Investment Income Tax
Higher-income sellers may owe an additional 3.8% Net Investment Income Tax on any recognized gain — meaning gain that wasn’t excluded under Section 121.7Internal Revenue Service. Questions and Answers on the Net Investment Income Tax The thresholds are $200,000 for single filers, $250,000 for joint filers, and $125,000 for married filing separately, and they aren’t adjusted for inflation.8Internal Revenue Service. Topic No. 559 – Net Investment Income Tax The tax applies to the lesser of your net investment income or the amount by which your modified AGI exceeds the threshold. A joint-filing couple with $300,000 in modified AGI and $100,000 of recognized home sale gain would owe 3.8% on $50,000, adding $1,900 on top of the capital gains tax.
Inherited Homes Work Differently
If you inherited the home rather than buying it, your basis isn’t what the prior owner paid. Inherited property gets a stepped-up basis equal to its fair market value on the date of the prior owner’s death.9Office of the Law Revision Counsel. 26 USC 1014 – Basis of Property Acquired From a Decedent If your parent bought the house for $150,000 and it was worth $400,000 when they died, your basis is $400,000, and only appreciation from that point forward is taxable.
In community property states — Arizona, California, Idaho, Louisiana, Nevada, New Mexico, Texas, Washington, and Wisconsin — a surviving spouse gets a full step-up on both halves of jointly owned community property, not just the decedent’s half.9Office of the Law Revision Counsel. 26 USC 1014 – Basis of Property Acquired From a Decedent In other states, only the deceased spouse’s share steps up.
The Section 121 exclusion is still available on an inherited home, but the same ownership and use tests apply to you. If a parent lived there and you never did, you own the property but can’t satisfy the use test, and the exclusion won’t apply.
Reporting the Sale
If your entire gain falls within the exclusion and the closing agent doesn’t issue a Form 1099-S, you generally don’t need to report the sale on your return.10Internal Revenue Service. Instructions for Form 1099-S (04/2025)
Otherwise, report the sale on Form 8949, listing purchase date, sale date, proceeds, and adjusted basis.11Internal Revenue Service. About Form 8949 – Sales and Other Dispositions of Capital Assets The gain flows to Schedule D and then to your Form 1040.12Internal Revenue Service. About Schedule D (Form 1040) – Capital Gains and Losses Most states follow the federal exclusion, but a few do not fully conform and may require you to add the excluded gain back on the state return, so check your state’s rules before you file.