Most people who sell a home they've lived in for years owe no federal tax on the profit. The rules that decide whether you're one of them come down to a few dates and a little arithmetic.
How much home sale profit can you exclude from tax?
If you owned your main home and lived in it for at least 2 of the 5 years before selling, you can generally exclude up to $250,000 of the gain from income. Married couples filing jointly can exclude up to $500,000 if both spouses meet the residence test and one meets the ownership test.
That rule comes from section 121 of the tax code, and the IRS explains it in Publication 523, Selling Your Home. The exclusion isn't a deduction. It means the excluded part of your profit simply isn't counted as income. Unlike many tax figures, the $250,000 and $500,000 amounts are written into the law itself, so they don't change from year to year.
The three tests: ownership, residence and look-back
Publication 523 checks eligibility with three requirements.
The ownership test asks whether you owned the home for at least 24 months (2 years) out of the 5 years leading up to the date of sale, which is usually the closing date.
The residence test asks whether you lived in the home as your main home for a total of 24 months (730 days) during that same 5-year period. The IRS says those 24 months can fall anywhere within the 5 years and don't have to be a single block of time. A vacation or other short absence counts as time you lived there, even if you rented the place out while you were gone.
The look-back test asks whether you excluded gain on another home sale during the 2 years before this one. You may take the exclusion only once in a 2-year period.
You can meet the ownership and residence tests during different 2-year stretches, as long as both happen within the 5-year period ending on the sale date, according to IRS Topic 701, Sale of Your Home. Publication 523 also lists situations that rule the exclusion out entirely, such as getting the home through a like-kind (section 1031) exchange during the past 5 years.
The married-couple rules, in plain English
For a married couple filing jointly, the full $500,000 exclusion requires three things. At least one spouse has to meet the ownership test. Both spouses have to meet the residence test on their own. And neither spouse can have used the exclusion on another home sale in the prior 2 years.
If a couple filing jointly doesn't meet all three, the law doesn't simply drop them to zero. Under section 121, their limit becomes the total of what each spouse could have excluded if they were single. That often works out to $250,000, as one of the examples below shows.
A surviving spouse can also keep the $500,000 limit in some cases. Publication 523 says it applies if you sell within 2 years of your spouse's death, you haven't remarried at the time of the sale, and the joint-return requirements were met right before your spouse died.
How to figure your gain
The exclusion applies to your gain, not to the sale price. Publication 523 lays out the math in three steps.
- Start with the selling price and subtract your selling expenses. The result is the amount realized.
- Figure your adjusted basis. That's generally what you paid for the home, plus certain closing costs from your purchase, plus the cost of improvements.
- Subtract the adjusted basis from the amount realized. The result is your gain or loss.
Basis is where many sellers leave money on the table. Publication 523 says purchase closing costs you can include in basis are abstract fees, utility installation charges, legal fees, recording fees, survey fees, transfer or stamp taxes, and owner's title insurance. Costs you can't add include fire and casualty insurance premiums, rent or utilities you paid before closing, and mortgage-related charges such as points and loan origination fees. Improvements are projects that add to your home's value, prolong its useful life or adapt it to new uses, like a new roof or an addition. Routine repairs generally don't count.
Worked example 1: a single seller well under the limit
Dana is single. She bought her house for $280,000 and paid $5,000 in closing costs that belong in basis, such as owner's title insurance and recording fees. Over the years she spent $40,000 on improvements, including a new roof and a kitchen remodel. She lived there the whole time she owned it, more than 5 years, and sells for $600,000 with $36,000 in selling expenses.
- Amount realized: $600,000 − $36,000 = $564,000.
- Adjusted basis: $280,000 + $5,000 + $40,000 = $325,000.
- Gain: $564,000 − $325,000 = $239,000.
Dana's $239,000 gain is below the $250,000 limit, so all of it can be excluded. If she had lost her improvement receipts and used only her $280,000 purchase price as basis, her gain would have been $284,000, and $34,000 of it would have been taxable. Good records changed the result.
Worked example 2: a married couple over the limit
Marcus and Priya file jointly. They've owned and lived in their home for 9 years. They sell for $1,100,000 with $60,000 in selling expenses, and their adjusted basis is $420,000.
- Amount realized: $1,100,000 − $60,000 = $1,040,000.
- Gain: $1,040,000 − $420,000 = $620,000.
- Excluded: $500,000.
- Taxable gain: $620,000 − $500,000 = $120,000.
They report the $120,000 as a capital gain. Because they owned the home for more than a year, it's a long-term gain, which is generally taxed at lower rates than wages. Our guide to capital gains taxes explains how those rates work.
Worked example 3: one spouse hasn't lived there long enough
Tom has owned and lived in his house for 6 years. He marries Ana, and she moves in. One year later they sell, filing a joint return. Their gain is $380,000.
Tom meets the ownership and residence tests, but Ana has lived there only 12 months, so the couple doesn't qualify for the $500,000 limit. Instead, their limit is what each could have excluded as a single person: $250,000 for Tom and nothing for Ana, assuming her short stay didn't come from a qualifying reason like a job move.
- Excluded: $250,000.
- Taxable gain: $380,000 − $250,000 = $130,000.
If they could wait until Ana reaches 24 months of residence, and neither has used the exclusion in the past 2 years, the full $380,000 gain could fall under the $500,000 limit. Timing can change the tax bill, though it's only one factor in when to sell.
The partial exclusion: when you sell early for a good reason
Selling before you hit 2 years doesn't always mean losing the exclusion. Publication 523 allows a partial exclusion if the main reason for the sale was a change in workplace location, a health issue or an unforeseeable event.
For a work move, the IRS test is whether your new job is at least 50 miles farther from the home than your old one was. Its example: an old job 15 miles from the home and a new job 65 miles away. Health reasons include a doctor recommending a change in residence because of a health problem. Unforeseeable events include a home being destroyed or condemned, or a casualty loss from a natural or man-made disaster.
The math uses the shortest of three periods: how long you lived there in the 5 years before the sale, how long you owned it, and, if it applies, how long since you last used the exclusion. You divide that number by 24 (in months) or 730 (in days), then multiply by $250,000, or by the joint limit if you qualify for it.
Worked example 4: a job transfer after 15 months
Leah is single. She bought a condo and lived in it for 15 months before her employer moved her to an office 80 miles farther from the condo than her old one. That passes the 50-mile test.
- Her fraction: 15 ÷ 24 = 0.625.
- Her maximum exclusion: 0.625 × $250,000 = $156,250.
If Leah's gain is $90,000, all of it is excluded. If her gain were $200,000, she could exclude $156,250, and $43,750 would be taxable.
Rentals, home offices and depreciation
Many homes aren't used only as a main home for their whole life. Two rules matter here.
The first is depreciation. Section 121 says the exclusion doesn't cover gain equal to depreciation claimed for periods after May 6, 1997, such as depreciation on a rental period or a home office. Say Sam's total gain is $150,000, and he claimed $12,000 of depreciation on a home office. Even though $150,000 is under his $250,000 limit, the $12,000 tied to depreciation isn't excludable. Publication 523 says Form 4797 is used to report the recapture amount.
The second is what the IRS calls nonqualified use. Publication 523 says any period after 2008 when the home isn't used as your main home is, with certain exceptions, nonqualified use, and the part of the gain allocated to that time can't be excluded. One important exception in the law: time after the last date you lived in the home doesn't count as nonqualified use. So if you live in a house for 3 years, then rent it out for 2 years and sell, you can still meet the 2-out-of-5 test, and the rental years at the end don't cut your exclusion. Only the depreciation from those rental years would be taxable. The law also carves out certain military and Foreign Service duty and some temporary absences.
Members of the uniformed services, the Foreign Service, the intelligence community and the Peace Corps on qualified extended duty can choose to suspend the 5-year test period for up to 10 years, according to Publication 523.
Do you have to report the sale?
Sometimes, even when you owe nothing. Topic 701 says you must report the sale if you received Form 1099-S, Proceeds From Real Estate Transactions, even if the gain is excludable. You also must report it if you can't exclude all of your gain. When reporting is required, you use Form 8949 and Schedule D (Form 1040).
Common mistakes to avoid
The first mistake is forgetting improvements and purchase closing costs. Every dollar of basis you can document lowers your gain. Our guide to closing costs explains what usually shows up on a settlement statement.
The second is counting months wrong. The 24 months must fall within the 5 years ending on the closing date, not the date you list the home or sign the contract.
The third is assuming marriage automatically doubles the limit. Both spouses must meet the residence test for $500,000.
The fourth is overlooking depreciation from a rental or home office. That portion of the gain is taxable even when the rest is excluded.
The fifth is skipping the return when you receive a Form 1099-S. The sale still needs to be reported.
What to do next
Gather your purchase closing statement, your improvement receipts and the dates you moved in and out. Run the three-step gain math above, then check the ownership, residence and look-back tests against your actual dates. If you're selling to move somewhere smaller, our guide to downsizing in retirement covers the other costs to plan for. If your gain is close to the limit, or a rental, home office or recent marriage is involved, a CPA or enrolled agent can check the numbers before you set a closing date.
Frequently asked questions
Do I have to buy another house to avoid capital gains tax on my home sale?
No. The home sale exclusion doesn't require you to buy another home. It depends on meeting the ownership, residence and look-back tests for the home you sold.
Do the 2 years of living in the home have to be in a row?
No. The IRS says the 24 months of residence can fall anywhere within the 5-year period before the sale and don't have to be a single block of time.
How often can I use the home sale exclusion?
Generally once every 2 years. You can't exclude gain if you excluded gain on another home sale during the 2-year period before this sale.
Is the $250,000 exclusion adjusted for inflation?
No. The $250,000 and $500,000 limits are set in section 121 of the tax code and aren't indexed for inflation.
Content on The Evergreen Edit is for educational and informational purposes only and is not individualized financial, investment, tax or legal advice. Learn more.
Which money-saving habit will you focus on next?
This article is for educational purposes only and isn't personalized financial, tax or legal advice. Consider talking with a qualified professional about your situation.

Kiara Miller — Founder & Editor
Kiara Miller is the founder and editor of The Evergreen Edit. He has been doing independent finance research for two decades, is a tax preparer, and reviews every article before it's published.
More about Kiara →Get smarter about your money.
Join readers who get money stories on their chosen topics, daily or as new articles post.



