The Home Sale Capital Gains Exclusion (Section 121)

Ultimate Real Estate Investor Tax Guide »

When you sell your home, up to $500,000 of the profit from the sale can be completely untaxed. This special tax exclusion is defined in section 121 of the US tax code.

This can result in a massive tax savings if you qualify.  But there are many exceptions and nuances of the section of the tax code that are often overlooked or misunderstood.

The Tax Benefit

If the sale of your home meets all the qualifications, you don’t have to pay income tax on some or all of the profit you make from selling your home.  Up to $500,000 of profit can be excluded from your taxable income if you’re married and filing a joint tax return, or up to $250,000 for other filing statuses.  

So for example, if you purchase the house originally for $300,000, and you later sell it for $1 million, Your profit is $700,000.  If you are married filing jointly, and you meet the qualifications, then only $200,000 of the profit from that sale would be taxable as capital gains.  Note that the capital gains tax rates are lower than other types of income, but that’s still going to add up to a massive tax savings.  

How to Qualify

To qualify, you must have lived in the property as your primary residence for at least 2 of the previous 5 years before you sold it, and you (or your spouse) must have owned it for at least 2 of the previous 5 years. It can’t just be a second home or vacation home, it must be your primary residence. The two years can be non-consecutive, you just need a total of 24 full months (or 730 days) of ownership and use of the property as your primary residence. Time spent on vacation or other periods of short temporary absence don’t have to be excluded.

If the taxpayer becomes mentally or physically disabled, and they had lived in the home for at least 1 year, then time spend in a nursing home or licensed facility counts towards their occupancy time. Or if the taxpayer is on “official extended duty” in the military, Peace Corps, Foreign Service, or employee of the intelligence community, then the time to qualify the 5-year period is extended while on duty for up to 10 years.

If you are married and filing a joint return, in order to qualify for the $500,000 exclusion, either spouse can be the owner (it doesn’t have to be jointly owned). But both spouses must live in the property to qualify for the $500,000 exclusion amount. If either spouse filing jointly fails to meet the requirements, the maximum exclusion amount for the couple is the sum of each spouse’s exclusion as if they had not been married (except that both spouses are considered owners if either spouse owned it). If one of the spouses died before the house was sold, the period the deceased spouse owned/used the house is included in the calculation of time of ownership/use for the surviving spouse. 

The property can’t be just undeveloped land, there must be a dwelling unit. But a dwelling unit can be almost anything that can be used as a livable space, including a houseboat or a trailer.

Additional requirements:

  • The sale must be to an unrelated person (as defined in tax code section 267(b) or 707(b)).
  • You can’t have used this section 121 exclusion in another property sale in the previous 2 years (this applies to both spouses).

Partial Exclusion for Less Than 2 Years

Normally, the section 121 exclusion is all or nothing. If you are even a day short of the two years of occupancy required, that may mean you don’t qualify for any of the tax exclusion at all. But there are exceptions (defined in Treasury reg. 1.121-3) if there were qualifying circumstances that made it necessary for you to move or sell the house when you did.

Qualifying circumstances include:

  • Change of employment to a new job at least 50 miles further from the home.
  • Loss of a job or other circumstances resulting in financial strain.
  • Divorce or legal separation.
  • Multiple births from a single pregnancy (twins, etc.).
  • Treatment related to medical care for the taxpayer or a qualified relative or a member of the household.
  • “Involuntary conversion” (such as eminent domain seizure of the property by the government).
  • “Unforeseen circumstances” such as a disaster resulting in damage or loss of the residence.

In addition to those “safe harbor” qualifications, other situations that can be considered to necessitate moving or selling the house may also qualify for the partial exclusion.

If you qualify for a partial exclusion, the amount of the exclusion is a fraction of the full amount based on the number of days that you owned or lived in the property using this formula:

Exclusion Amount = Full ExclusionAmount * { Actual Days \over  730 }

The “FullExclusionAmount” is $250,000 if you are a single filer, or $500,000 if you are married filing jointly. The “ActualDays” is the number of days you owned the property or lived in the property (whichever is fewer) during the previous 5 years.

Past Use as a Rental Property (or Non-primary Residence)

This is the most commonly overlooked part of section 121, so read this part carefully if the house was used as a rental property (or if it was your vacation home, second home, or otherwise was not your primary residence) for any part of the time that you owned it.

If you bought the property and lived in it as your primary residence BEFORE converting it to a rental property (or a vacation home, etc.), and you didn’t use it as your primary residence again after that period, then the good news is in that case you may still fully qualify for this exclusion if you meet the qualifications explained above.

However, if you bought the property and used it as a rental property or vacation home, and then AFTERWARD used it as your primary residence, unfortunately the tax code isn’t going to let you take full advantage of this tax benefit. They don’t want rental property (or vacation home) owners to decide to move into their rentals for a couple of years before selling and get the full benefit of the section 121 exclusion. You can still qualify to exclude some of the capital gain, but the amount may be more limited. We’ll dive into those calculations below.

Nonqualified Use

If there was “nonqualified use” of the property while you owned it, then your capital gains exclusion is reduced by the proportion of time that it had nonqualified use while you owned it. This is defined in the tax code section 121(b)(5).

Qualified use is any period of time during the ownership of the property that was used as the taxpayer’s principal residence (or of the taxpayer’s spouse or former spouse). Nonqualified use is any other time that you owned it and it didn’t qualify as your principal residence (so it was a second home, rental, etc.). But the tax code definition of nonqualified use excludes any time that is after the last time you (or your spouse) lived at the house as your primary residence.

So if you buy a property and initially use it as a rental property, and then later convert it to your primary residence, the period of time it was a rental property is called a period of nonqualified use. In that case, your section 121 exclusion is limited to a fraction of the capital gain based on the portion of the time it was a rental.

This equation is used to calculate this limitation on your maximum exclusion amount:

MaximumExclusion  = Capital Gains * { Qualified Use Time \over Total Ownership Time }

A “Nonqualified Use Loophole”?

There’s an interesting quirk about that particular math equation used to calculate the maximum exclusion when you have nonqualified use. The maximum exclusion is calculated based on a fraction of the total capital gains (rather than a fraction of the $250,000 or $500,000 exclusion amount). That means that if your capital gains were large enough, the period of nonqualified use may not actually make any difference in the amount of tax savings if the calculation is larger than the $250,000 or $500,000 that you’re eligible for anyway.

For example, if a single taxpayer sells a property with a gain of $600,000, and the property was used for nonqualified use for half of the time they owned it, the equation above would reduce their maximum exclusion to $300,000. But a single taxpayer’s maximum section 121 exclusion is only $250,000, so the period of nonqualified use in this situation ends up not making any difference in their actual tax savings.

Some have speculated that defining the calculation this way in the tax law may have been an unintentional mistake, and so this may arguably be considered a loophole.

There are some other specifics to be aware of. The tax law only counts periods of nonqualified use that occurred after January 1st, 2009 because that was when the law can into effect.

Example Scenarios

So note that the timing of when it was a primary residence makes a big difference, because you don’t have to count any nonqualified use that happened after the last time you lived in it as your primary residence.

Your rental property converted to your home: If you bought a house and used it as a rental property for 4 years, and then converted to your home for 3 years, then the rental period is nonqualified use. So in this case, your section 121 capital gain exclusion would be limited to a maximum of 3/7 of your total capital gains.

Your home converted to a rental: If you first lived in the house for 4 years, then converted it to a rental property for 1 year, and sold it, then you don’t have any period of nonqualified use and you can take the full section 121 exclusion. The rental period isn’t nonqualified use because it was after the last time it was your home.

Your home converted to a rental, and then a home again: Just like in the previous example, you lived in the house for 4 years, then converted it to a rental property for 1 year. But then lived in as your home again as your primary residence for a brief period of time before you sold it. Then the rental period of time is nonqualified use because it wasn’t after the last time it was your primary residence! Yes, it doesn’t make logical sense, but living in the home again after renting it, that can reduce the amount of exclusion you qualify for!

Partially Rented Properties (House-Hacking, Duplexes, etc.)

Treasury reg. 1.121-1(e) says, “If a portion of the property was used for residential purposes and a portion of the property (separate from the dwelling unit) was used for non-residential purposes, only the gain allocable to the residential portion is excludable under section 121.”

This means that if your property consists of multiple units (if it is a duplex, triplex, apartment building, etc.), then you must calculate the portion of the gain that is from only your unit that you use as a residence, and only that portion is excludable. The method of allocating what percent is your residence must be the same method you used to calculate depreciation for the business/rental portion. There are situations where it can be difficult to determine if there are separate units or not, but in general, it would be considered to have separate units if there is a rented portion of the house with a separate kitchen, separate entrance, etc.

If you rent out part of your home (such as by having roommates), and the rented portion isn’t a separate unit, then the capital gain from the entire house is still allowed to be excluded, and you don’t have to proportion it. There will be depreciation recapture to pay back (see below).

Depreciation Recapture on Rentals

If the property was used as a rental or business property for a period of time, or because you rented out part of your home, you will have taken depreciation on it during those years. If you later sell a property that had depreciation for a profit, you have to pay taxes on the depreciation that you previously benefited from in those past years. This is “depreciation recapture” (actually in this case it’s “section 1250 unrecaptured gain” specifically). Any depreciation recapture for depreciation from after May 6, 1997, is not eligible for section 121 exclusion. So even if you qualify to exclude your capital gains, there will still be some taxable depreciation recapture resulting in some taxes due if it was a rental for some period of time. This topic is also covered by Rev. Rul. 2014–2.

Combining With a 1031 Exchange

When you qualify to use both strategies, combining 1031 and 121 can result in a substantial tax benefits. This is one of the areas where understanding these qualifications, or working with a real estate tax advisor, can be very valuable to strategize how to best plan ahead to maximize your tax savings.

Property Acquired in a 1031 Exchange

Within certain limitations, it is possible to acquire a property with a 1031 exchange, and then later use that property as your personal residence and qualify for a section 121 exclusion when you sell it.

To qualify for section 121 with a 1031 acquired property, you must wait at least 5 years before selling it. IRC code 121(d)(10) specifies that a property acquired in a 1031 exchange can’t qualify for section 121 if it is sold within 5 years of the date it was acquired.

At the time you buy the property using a 1031, you must be doing it with the intent to use it for business/rental purposes. The tax code doesn’t define a specific period of time that it must remain a business property before you can convert it to personal use. But the IRS rev. proc. 2008-16 created a “safe harbor” that the IRS will not challenge if you at least meet the specific guidelines. The safe harbor requirements specify that during the 2 years after the exchange, there are two 12 month periods of time, and in each of those 12 month periods the property must be rented out at least 14 days at fair market rent prices, and your personal use of the property in each of those period must be less than 14 days. Ideally, you should try to qualify that that safe harbor, or otherwise clearly demonstrate that you had the intent to use it for business/rental use. By the way, that also means you will have a period of “nonqualified use” during the time it is a rental (as explained in a previous section of this article).

Combining section 121 and a 1031 Exchange When Selling a Property

You can qualify for both if a portion of the property is your residence and a portion is rented out.

You can also qualify for both if a property was used as your home for a period of time that qualifies it for section 121, but then it was used as a rental property at the time you sell it. In that scenario, you have to clearly demonstrate that you did have the intent to use it as a legitimate rental property before the exchange. The tax code doesn’t define a specific period of time that it must remain a business property before you can use it for a 1031 exchange. But the IRS rev. proc. 2008-16 created a “safe harbor” that will prevent them from challenging the change of use if you meet their guidelines. The safe harbor requirements specify that during the 24 months before the exchange, there are two 12 month periods of time, and in each of those 12 month periods the property must be rented out at least 14 days at fair market rent prices, and your personal use of the property in each of those period must be less than 14 days. You can still do a 1031 even if you don’t meet that safe harbor, but it’s best if you do in order to avoid the risk of an IRS challenge.

Section 121 is applied first before calculating the basis and deferred gains for the 1031 exchange. Note that section 121 can’t be used to reduce gains resulting from depreciation recapture, but 1031 can be used to defer those depreciation gains. So you would first get to exclude a portion of the capital gains using section 121, and then the 1031 exchange would defer the rest of the gains, including any depreciation recapture. IRS rev. proc. 2005-14 details the specifics, including the calculation of basis for the exchange.


What if the property is owned in the name of an LLC or trust? You still qualify as the owner of the property if the property is in the name of a single-member LLC that you own, or if the property is in the name of a trust that you own.

This article is part of The Ultimate Real Estate Investor Tax Guide.

Photo of author

David Orr

I am a credentialed tax professional with a primary focus on tax preparation and advising for real estate investors. Have tax questions or want me to do your taxes? Contact us.

This article was written or updated in 2023 or 2024 and is current for the 2023 and 2024 tax years.

The information presented here is meant for guidance purposes only, and not as personal legal or tax advice.