Skip to content
Passbion

Search calculators

Section 121 Exclusion Calculator

Use this Section 121 exclusion calculator to see how much of the gain on selling a home you can exclude when it was also a rental: it checks the ownership and use tests, takes out the depreciation and the gain from nonqualified use, applies the $250,000 or $500,000 limit and estimates the tax on the rest.

Updated October 6, 2026. Every formula on this page is published below and tested against an independent implementation. Embed on your site

Embed on your site

Add the Section 121 Exclusion Calculator to your website for free. It resizes itself to fit and links back here.

How the Section 121 exclusion calculator splits the gain

Section 121 of the Internal Revenue Code lets you exclude up to $250,000 of gain on the sale of your main home, or up to $500,000 on a joint return. You qualify if you owned the home and lived in it as your main home for at least 2 years (730 days) of the 5 years ending on the date of sale. The 2 years don't have to be continuous, and a vacation or other short absence counts as time you lived there.

When the home was also a rental, two parts of the gain can't be excluded even if you qualify. The first is depreciation: the depreciation allowed or allowable for periods after May 6, 1997 is taxed, as unrecaptured section 1250 gain at up to 25%. The second is gain from nonqualified use: for periods after 2008 when the home wasn't your main home, a share of the rest of the gain is taxable, in proportion to those days.

Excluded=min⁡ ⁣((G−D)(1−NT), L)\text{Excluded} = \min\!\Big(\big(G - D\big)\big(1 - \tfrac{N}{T}\big),\ L\Big)
The gain you can exclude, once the depreciation and the nonqualified use are taken out
G
Gain: sale price less selling costs and the adjusted basis (cost and improvements less depreciation)
D
Depreciation after May 6, 1997, up to the gain
N
Days of nonqualified use: after 2008, not lived in, and not covered by an exception
T
Days you owned the home
L
$250,000, or $500,000 on a joint return when both spouses meet the use test

The calculator counts days, as IRS Publication 523 does, from the dates you enter. Everything that isn't excluded is taxed through the same engine as the rental property capital gains tax calculator, depreciation first, with your other income, the net investment income tax and, if you choose one, your state.

Worked example: a rental you moved into

A single filer buys a house on June 1, 2016 for a cost basis of $400,000, rents it out for five years and moves in on June 1, 2021. Depreciation over the rental years comes to $55,000. The house sells for $720,000 on June 15, 2026, with $43,200 of selling costs, for a gain of $331,800.00.

The owner lived there for 1,826 days of the last five years, so both tests are met. The $55,000.00 of depreciation is taxable whatever happens. Of the 3,666 days owned, 1,826 were rental days after 2008, or 49.8%, so $137,871.47 of the remaining gain is nonqualified use. That leaves $138,928.53 excluded and $192,871.47 taxable, for $36,683.84 of federal tax with $95,000 of other income.

The order of the years matters. Here is the same house, gain and depreciation with the rental years placed differently:

The same $720,000 sale with different years of use
How it was usedNonqualified daysExcludedTaxable gainFederal tax
Rented 5 years, then lived in 51,826$138,928.53$192,871.47$36,683.84
Rented 8 years, then lived in 22,922$56,175.45$275,624.55$52,241.41
Lived in 8 years, then rented 20$250,000.00$81,800.00$16,684.00
Lived in 5 years, then rented 514$0.00$331,800.00$62,802.40

Moving in for just over two years still qualifies, but $220,624.55 of the gain is nonqualified use. Living there first and renting it out afterwards counts no nonqualified use at all, because days after you move out that fall within the five years before the sale are excepted. The exclusion then reaches the $250,000.00 limit, and only the depreciation and the $26,800.00 over the limit are taxed. Rent it out for too long after moving out, though, and the use test fails: with five years of rental before the sale, nothing is excluded.

Nonqualified use and its exceptions

A period of nonqualified use is any time after December 31, 2008 when neither you nor your spouse (or former spouse) used the home as your main home: rented out, vacant or used as a second home. Three kinds of time aren't counted:

  • Time after you move out that falls within the 5 years ending on the sale date. This is why renting out a former home for up to three years before selling doesn't reduce the exclusion.
  • Qualified official extended duty for members of the uniformed services or the Foreign Service, employees of the intelligence community and Peace Corps workers, up to 10 years in total.
  • A temporary absence because of a change of employment, a health condition or other unforeseen circumstances, up to 2 years in total. This estimate excepts the first 2 years of a longer absence and counts the rest.

Time before 2009 is never nonqualified use, so a rental you bought long ago and moved into later keeps more of its exclusion than one bought recently. The days before 2009 still count in the total days owned.

Who can't use the home sale exclusion

The exclusion isn't available, and the calculator shows none, if you fail the ownership or the use test, if you excluded gain on another home you sold in the 2 years before this sale, or if you acquired the home in a like-kind exchange and sell it within 5 years of acquiring it.

Some sellers who fail the tests can still claim a reduced exclusion, when the main reason for the sale was a change of place of employment, health or unforeseen circumstances. Members of the uniformed services or the Foreign Service, intelligence community employees and Peace Corps workers on qualified official extended duty can also choose to suspend the 5-year period for up to 10 years. The calculator doesn't figure either; Publication 523 explains both.

On a joint return the $500,000 limit needs either spouse to meet the ownership test and both to meet the use test. When only one spouse meets the use test, the calculator uses the $250,000 limit.

The bottom line

A home that was a rental can still qualify for the exclusion, but the depreciation and the share of the gain from nonqualified use stay taxable. In the example, $138,928.53 of a $331,800.00 gain is excluded and $192,871.47 is taxed.

Enter your own dates in the Section 121 exclusion calculator, and use the rental property depreciation calculator to work out the depreciation from your rental years. This estimate uses the day counts and limits described above; a tax professional can confirm how they apply to your sale.

Frequently asked questions

How does the 2-out-of-5-year rule work?

Under the 2-out-of-5-year rule you must have owned the home, and lived in it as your main home, for at least 2 years (730 days) each during the 5 years ending on the date of sale. The 2 years of use don't have to be continuous, and short absences such as vacations count as time lived there.

What is nonqualified use?

Nonqualified use is any time after 2008 when the home wasn't your main home, such as years it was rented out or used as a second home. The share of the gain (after depreciation) equal to nonqualified days over days owned can't be excluded. Time after you move out within the 5 years before the sale, qualified official extended duty and up to 2 years of temporary absence don't count.

Can I convert a rental to a primary residence and exclude the gain?

Yes, if you then live in it as your main home for at least 2 years before selling, but converting a rental to a primary residence doesn't make all of the gain excludable. The rental years after 2008 are nonqualified use, so part of the gain stays taxable, and all of the depreciation from the rental years is taxed.

How much is the home sale exclusion?

The home sale exclusion is up to $250,000 of gain, or up to $500,000 on a joint return when either spouse meets the ownership test, both meet the use test and neither excluded gain on another home sold in the 2 years before. Gain above the limit is taxed as a capital gain.

Who gets the $500,000 exclusion?

A married couple filing jointly gets the $500,000 exclusion when at least one spouse owned the home for 2 of the 5 years, both lived in it as their main home for 2 of the 5 years, and neither used the exclusion on another sale in the previous 2 years. Otherwise the limit is generally $250,000.

Is there depreciation recapture on a home sale?

Yes, if you claimed (or could have claimed) depreciation after May 6, 1997, because the home was rented or used for business. That part of the gain can't be excluded; it's taxed as unrecaptured section 1250 gain at up to 25%. Depreciation recapture on a home sale applies even when the rest of the gain is fully excluded.

What if I rented out my home after moving out?

Renting out your former home after you move out isn't nonqualified use if you sell within the 5 years that count for the use test. You keep the full exclusion as long as you lived there 2 of the 5 years before the sale, which means selling within 3 years of moving out if you lived there at least 2 years. The depreciation from the rental years is still taxed.

Sources and further reading

Guides