When you sell your main home, federal law lets you exclude up to $250,000 of gain, or $500,000 for most married couples filing jointly, if you pass the IRS ownership, residence and look-back tests. Enter your sale, your purchase and your dates to see which tests you meet, your gain, how much of it can be excluded and what may be taxable.
Your sale
Runs in your browser. Nothing you type is saved or sent. The figures shown are an example; replace them with yours.
The IRS eligibility test
IRS Publication 523 sets out the test for the full exclusion. Months do not have to be in one stretch, and the ownership and residence months do not have to be the same ones, as long as both fall in the 5 years before the sale (Treasury Regulation 1.121-1(c)). The date of sale is the closing date, shown in box 1 of Form 1099-S.
| Requirement | Single or married filing separately ($250,000) | Married filing jointly ($500,000) |
|---|---|---|
| Ownership | You owned the home at least 24 months in the 5 years before the sale | Either spouse meets it |
| Residence | You lived in it as your main home at least 24 months (730 days) in those 5 years | Both spouses must meet it |
| Look-back | You did not exclude gain on another home sold in the 2 years before this sale | Neither spouse did |
| Automatic disqualification | No exclusion if you got the home in a like-kind (1031) exchange within the past 5 years, or you are subject to the expatriate tax | |
If a married couple filing jointly falls short of the $500,000 conditions, the limit becomes the sum of what each spouse would get if unmarried, with each treated as owning the home for as long as either spouse did, under 26 U.S.C. 121(b)(2). A surviving spouse who sells within 2 years of the death and has not remarried can still use the $500,000 limit if the other conditions are met, counting the late spouse’s ownership and residence.
How the gain is figured
Your gain is the amount realized minus your adjusted basis. The amount realized is the sale price minus selling expenses such as commission, advertising and legal fees; transfer taxes you pay as the seller count as selling expenses too. Your basis starts with the purchase price, adds certain closing costs from your purchase, such as title, recording and survey fees, transfer taxes and owner’s title insurance, and adds improvements that are still part of the home. Loan costs like points and mortgage insurance do not count, and neither do repairs. If you inherited the home, your starting basis is generally its fair market value on the date of death, which our guide to selling an inherited house explains. A loss on the sale of your main home cannot be deducted. The capital gains guide covers record keeping and examples.
When a partial exclusion may apply
If you do not pass the 2-year test, you may still exclude part of the gain when the main reason for the sale was one of these, as Publication 523 lists them:
- Work-related move: a new job at least 50 miles farther from the home than your old work location, or a first job at least 50 miles away.
- Health-related move: to get or provide diagnosis, treatment or care for yourself or a family member, or on a doctor’s recommendation.
- Unforeseeable event: the home was destroyed or condemned, a disaster casualty, a death, divorce or legal separation, multiple births from one pregnancy, becoming eligible for unemployment compensation, or a change in employment that leaves you unable to pay basic living expenses.
- Other facts and circumstances showing the primary reason was work, health or an unforeseeable event.
The reduced limit comes from Worksheet 1 in Publication 523: take the shortest of your residence in the last 5 years, your ownership, and the time since you last sold a home with the exclusion; divide it by 24 months; multiply by $250,000. Married couples filing jointly do this for each spouse and add the results. The calculator follows those steps in whole months. Divorce brings its own ownership and residence rules, covered in our guide to selling a house during divorce.
What the result leaves out
- Business or rental use and depreciation. Depreciation claimed after May 6, 1997 cannot be excluded, and a separate business or rental part of the property needs its own calculation.
- Nonqualified use after 2008. Gain tied to periods when the home was not your main home, such as years as a rental or second home, can be taxable even when you pass the test.
- The tax itself. The result shows taxable gain, not the tax. The IRS taxes a gain on property held more than a year at long-term capital gain rates that depend on your taxable income (Topic 409).
- Special timing rules. Service members and some federal employees can suspend the 5-year period for up to 10 years, and time in a licensed care facility can count as residence if you lived in the home at least 12 months. Enter months that already reflect those rules.
- State tax. States set their own rules for taxing a home sale gain.
Frequently asked questions
Do I have to live in the house for two full years in a row?
No. You need a total of 24 months, or 730 days, of living there as your main home during the 5 years before the sale. Short absences such as vacations still count as time you lived there.
Can my spouse and I exclude $500,000 if only one of us is on the deed?
Yes, if you file jointly, either of you meets the ownership test, both of you meet the residence test, and neither of you excluded gain on another home sold in the 2 years before.
What counts as an improvement?
Work that adds value, prolongs the home’s life or adapts it to new uses, such as an addition, a new roof, central air or a new driveway. Repairs and upkeep do not count, and improvements you later removed or replaced drop out of the basis.
Do I have to report the sale if all of the gain is excluded?
Only if you received a Form 1099-S, or you choose to report the gain as taxable. If you received a 1099-S, report the sale on Form 8949 even when nothing is taxable.
I sold after 18 months because of a new job. Do I owe tax on all of it?
Not necessarily. If the new job is at least 50 miles farther away, you may qualify for a partial exclusion: 18 ÷ 24 of $250,000, or $187,500, if 18 months is the shortest of your periods.
Are my numbers saved?
No. The calculator runs in your browser and does not save or send what you type.
How this calculator works: method and sources
Amount realized is the sale price minus selling expenses; adjusted basis is the purchase price plus basis closing costs plus improvements; gain is the difference. The ownership, residence and look-back tests use 24 months as the threshold. A joint return gets $500,000 when either spouse owns, both meet residence and look-back; otherwise each spouse is figured as if unmarried, sharing the ownership period, and the two limits are added. When the test is not met and you choose a qualifying reason, the limit follows Publication 523 Worksheet 1, part B, in whole months, capped at $250,000 per person. Taxable gain is the gain minus the exclusion, never below zero. Depreciation, nonqualified use and state tax are flagged, not computed.
- Internal Revenue Service, Publication 523 (2025), Selling Your Home: the $250,000 and $500,000 limits, the eligibility test and automatic disqualifications, the exceptions, partial exclusion reasons and Worksheet 1, figuring gain, basis and selling expenses, the inherited-home basis, nondeductible losses and when to report a sale.
- 26 U.S.C. 121, Exclusion of gain from sale of principal residence (govinfo): the joint-return conditions in (b)(2)(A), the sum of separate limits in (b)(2)(B) with shared ownership, and the once-every-2-years rule in (b)(3).
- 26 CFR 1.121-1, Exclusion of gain from sale or exchange of a principal residence (eCFR): ownership and use may be met in nonconcurrent periods within the 5 years, as 24 full months or 730 days.
- Internal Revenue Service, Topic no. 409, Capital gains and losses: gain on property held more than one year is long-term, and net capital gain rates depend on taxable income.
Related calculators
Or browse every home buying and selling calculator.
Results are estimates from the figures you enter, not tax or legal advice. The rules come from IRS Publication 523 and the Internal Revenue Code; a tax professional can apply them to your full situation, including depreciation, rental use and state tax.