If you sell a house you lived in, federal law can leave part of the gain out of your income. The rule is Internal Revenue Code section 121. If you qualify, you may exclude up to $250,000 of gain, or up to $500,000 if you file a joint return. It does not apply to a loss. It does not change the sale price. It does not cover depreciation you took while the house was a rental.
This is the same rule behind the “primary-residence home-sale exclusion” checkbox on OwnerDelta. Check it only if you would meet the tests below. The calculators do not check those tests for you.
The IRS summary is Topic 701, Sale of your home. The full write-up, with worksheets, is Publication 523 (2025), Selling Your Home (PDF). Read those before you treat any number on this site as a tax result.
What it changes
Gain is, in broad terms, what you sell for minus selling costs, minus your basis (usually what you paid, plus improvements, minus depreciation). The exclusion then reduces the part of that gain that is taxed as a long-term capital gain. The sale still happens. State tax can still apply.
Depreciation taken after May 6, 1997 cannot be excluded. The IRS taxes that amount as recapture, at a rate of up to 25%, even if the rest of the gain fits under the $250,000 or $500,000 cap (Publication 523). That slice only shows up if the house was a rental. The yearly deduction and that later tax are in What is depreciation recapture when you sell a rental.
Who qualifies
Publication 523 and Topic 701 use two tests, plus a look-back.
- Ownership. You owned the home for at least 24 months of the 5 years ending on the sale date. For a joint return, only one spouse has to meet this.
- Use. You used it as your main home for at least 24 months of those same 5 years. The 24 months do not have to be one block. For the $500,000 amount, both spouses must meet the use test.
- Look-back. You generally cannot have excluded gain on another home sale in the two years before this sale.
Publication 523 also lists automatic disqualifications, including a home acquired in a like-kind exchange during the past 5 years, and some expatriate cases.
Leave the box off if the house would not be your main home, if you already used the exclusion on another sale in the last two years, or if you would not meet ownership or use. A vacation home or an investment property you never live in does not qualify.
A short example
You buy a house, live in it as your main home, and later sell. You are single, you qualify, you have $180,000 of gain, and you never rented it. The $250,000 cap covers the gain. Federal tax on that gain is $0 under this rule, before any other items on your return.
Same person, $320,000 of gain, still no rental use. The exclusion covers $250,000. $70,000 remains as taxable long-term gain.
Now the same $320,000 of gain, but $40,000 of depreciation was taken while the house was rented. The $40,000 comes off the top as recapture and cannot be excluded. That leaves $280,000. The exclusion can cover $250,000 of it. $30,000 remains as taxable long-term gain, plus tax on the recapture.
If you sell before two years
The full exclusion generally needs 24 months of ownership and 24 months of use. Selling sooner usually means the gain is taxed. Publication 523 describes a reduced exclusion in some job, health, or unforeseen-circumstance cases. The calculators on this site do not model that reduced amount.
If you move out and later rent
The 2-of-5 clock keeps running after you move. If you lived in the house long enough, you can still meet the use test after a stretch as a rental, as long as you sell before you drop under 24 months of use in the last 5 years. That is why a rent-then-sell path can still use this rule for a few years, and why it can be lost if you wait too long.
Publication 523 is the source for the tests and for the special rules on periods after you last used the home as your main home.
Where this sits on OwnerDelta
Both calculators have a checkbox for this rule. They do not run the IRS tests. Checking the box is an educational estimate: the model subtracts a $250,000 or $500,000-style amount from gain. The separate yearly estimate (mortgage interest, SALT, and the standard deduction) is in When mortgage interest and property tax lower a federal return.
- Rent vs Buy assumes you buy a house to live in, then sell at the end of the years you would stay. It applies the exclusion only if the box is on and the hold is at least 2 years. Filing status sets $250,000 or $500,000. There is no depreciation in that model. See the Rent vs Buy methodology.
- Rent vs Sell is for a house you already own. If you check the box, it subtracts the amount you pick from gain after recapture. It does not check the 2-of-5 clock for you. See the Rent vs Sell methodology.
This is an educational estimate, not tax, legal, or financial advice. Confirm your facts against Publication 523 and talk to a licensed tax professional before you buy, sell, or rent.
← Articles · Rent vs Buy Calculator · Rent vs Sell Calculator