Home Sale Gain Exclusion
Updated June 29, 2022

Home Sale Gain Exclusion Rules Under Section 121: How Does the Primary Residence Tax Exemption Work?

Personal Taxes

The $250,000 (single) / $500,000 (married) home sale gain exclusion is a major benefit of homeownership, but the rules can be confusing if you’re not familiar with them.

How do you calculate your gain in the first place?

What if you owned your house before you got married?  Can you exclude $500,000 of gain or only $250,000?

What about if you rented out your home at some point?

These questions are more are what we’re going to dig into in this article.

How to Calculate Your Gain

Typically, when you sell a piece of property, you have to pay taxes on your gain from the sale.

Your gain is the difference between what you sold the property for (your “proceeds”) less selling expenses less your “basis” in the property.

Your “basis” is what you originally paid for the property plus various closing costs plus various improvements you’ve made over the years less depreciation.  However, people don’t depreciate their primary home unless it’s used for business or rental, so we’ll leave the depreciation talk out for now.

So let’s say you bought a property for $100,000, paid $2,000 in capitalizable closing costs on it, and made $13,000 in capitalizable improvements on it.  Your basis is $115,000.

Now you go and sell the property for $200,000 and incur $10,000 of selling costs.

Your gain is $75,000, and you would typically have to pay tax on this gain.

How the Home Sale Gain Exclusion Works

Now, there is an exception to the general rule of paying tax on your gain when it comes to your primary residence.

This exception is known as the Home Sale Gain Exclusion, and it’s found in Section 121 of the Internal Revenue Code.

This Home Sale Gain Exclusion lets you exclude (i.e., not pay tax on) up to $250,000 of gain on the sale of your primary residence if you are single or $500,000 of gain on the sale of your primary residence if you are married filing jointly with your spouse.

You have to have owned and lived in the house for 2 out of the last 5 years ending on the date of the sale of the home (2 years being defined here as 730 days or 24 full months).

Also, you can only take advantage of this exclusion once every 2 years.  So if you plan on selling two primary residences in the near future, it would be wise to use the exclusion on the one that will result in the most gain.

However, keep in mind that the exclusion defaults to the first residence sold, so if you want to exclude the gain on the second residence sold, you must make a specific election to be taxed on the first so you can use the exclusion on the second.

Note that the ownership and use requirements need not be concurrent, so if you simply lived in the home (say on a lease) in Years 1 and 2, and then purchased it in Year 3 but moved somewhere else in Years 4 and 5 (while still keeping the home), you would still qualify.

Also, this exclusion is only available on your primary residence.  If you own multiple residences, the home you use for the majority of time during the year is considered your primary residence.

I Bought Our House Before I Got Married.  Can We Exclude $250,000 or $500,000?

Oftentimes, a married couple will sell a home that one spouse purchased before marriage, and the question becomes, “Can we exclude $500,000 or only $250,000?”

In order to take advantage of the $500,000 gain exclusion in a situation like this,  the following requirements must be met:

  • One spouse needs to meet the ownership requirement, meaning that only one spouse needs to have actually owned the home for 2 out of the last 5 years.
  • However, both spouses must meet the use requirement, meaning that both spouses must have lived in the home for 2 out of the last 5 years.
  • Also, neither spouse can have used the Home Sale Gain Exclusion (on another residence) in the 2-year period ending on the date of the sale of the home.

If all of these requirements are met, then the couple may exclude $500,000 of gain on the sale of the home that one spouse purchased before marriage.

If these requirements are not met, then the couple may only exclude $250,000 of gain on the sale of this home insofar as one spouse meets all requirements.

Obviously, if no spouse meets the requirements, then no gain may be excluded.

Are There Any Exceptions to the 2-Year Rule?

Believe it or not, the IRS is merciful at times, and they do allow for some (limited) exceptions to the requirement that a taxpayer live in a home for 2 out of 5 years in order to take advantage of the Home Sale Gain Exclusion.

Reduced Exclusion

The exclusion will be reduced, but it is still possible to exclude some gain on the sale of a primary residence if you:

  • Changed your place of employment
  • Had a sudden health issue
  • Underwent some other unforeseen circumstance or hardship

These exceptions also apply to the rule that one may only take advantage of the Home Sale Gain Exclusion once every 2 years.

As qualifying for these exclusions can be tricky, it’s recommended that you speak with a tax professional about your particular situation.

What If I Don’t Qualify for an Exception?

Many people sell a home less than two years after purchasing it and do not qualify for a reduced exclusion described above.

If this is your situation, then unfortunately you will likely have to pay capital gains tax on the sale of your home, assuming that you are selling it at a gain.

However, you may reduce you taxable gain by certain closing costs you paid (both on the acquisition and the sale of your home) as well as by capital improvements you’ve made to your house over the years.  I’ll explain these below based on IRS Publication 523.

Closing Costs

Here are some examples of closing costs you may have paid that could potentially increase your basis:

  • Abstract fees
  • Legal fees
  • Recording fees
  • Survey fees
  • Transfer taxes
  • Owner’s title insurance

That said, your basis is not increased by closing costs such as normal insurance premiums as well as any fees incurred in getting a loan.

Capital Improvements

Here are some examples of capital improvements that increase basis:

  • Putting in additions such as a new bedroom, bathroom, deck, garage, porch, or patio.
  • Landscaping, including installing a sprinkler system
  • Installing a driveway, walkway, fence, retaining wall, or swimming pool
  • Installing storm windows or doors
  • Installing a satellite dish
  • Putting on a new roof or new siding
  • Installing insulation
  • Installing new HVAC systems, including a heating system, central air conditioning, a furnace, duct work, central humidifier, and central vacuum
  • Installing an air or water filtration system
  • Installing new electrical wiring
  • Installing a security system
  • Installing a new plumbing system, including a septic system, water heater, and soft water or filtration system
  • Installing built-in appliances
  • Installing new flooring
  • Installing a fireplace
  • Remodels

Note that if you made an improvement, but then later removed or replaced it, you can’t apply its cost to your basis.  An example would be if you installed a new security system and then later replaced it with a superior one.  You could include the cost of the new security system but not the old one that you replaced.

Repairs

What about repairs, that is, work you did that is necessary to keep your house in good condition but doesn’t add to its value or prolong its life?  Unfortunately, you can’t include repair costs in your home’s basis.

Examples of repair costs include painting, fixing leaks, filling holes or cracks, replacing a broken window, etc.

That said, if something that would otherwise be considered a repair is done as part of a larger project, you may include it in your basis.  For example, let’s say a neighborhood kid breaks your window with his ball.  If you replaced that window, it would merely be a repair.  But what if in addition to replacing that window you decide to replace all the windows in your house with better windows?  This would count as an improvement and could be added to your basis.

Note that in the window example if you take a tax credit for energy-efficient windows, you can’t “double dip” by likewise including their cost in the basis of your home.

What If My Home Is Unique?

The term “residence” is fairly broad for purposes of the Home Sale Gain Exclusion and includes such living arrangements as houseboats, trailers, and stock held in a cooperative housing corporation.

However, if you live in personal property that is not considered a fixture under local law, this property will not count as a residence, and you cannot exclude your gain on it.

So if you live in a mobile home, be sure to speak with a tax professional about whether or not your home qualifies as a “residence” for purposes of the Home Sale Gain Exclusion.

What If My Spouse Dies?

If your spouse dies, and you have not remarried as of the date you sell the home, you will be considered to have used the home as a principal residence for the same period that your deceased spouse used the home as their primary residence.  So if you need to us this rule to maximize your exclusion, be sure to sell the home before you remarry!

What If I Rent Out the House and Then Live In It?

If you use a house first as rental property and then use it as a primary residence, then unfortunately you lose a part of your exclusion.

Let’s walk through an example to show you what we mean.

  • January 1, 2013: you buy a house for $100,000 and begin renting it out immediately.
  • January 1, 2015: you kick out the tenant and begin living in the house.
  • January 1, 2017: you sell the house for $300,000.

For example’s sake, let’s say your cost basis is that $100,000 and the $300,000 has already taken into account selling expenses, so your gain is $200,000.

Well, I have some bad news for you.  You can only exclude 50% of your gain, i.e., $100,000, because 50% of the years before the sale are considered “nonqualified” for the exclusion since during those years* the home was not used as a primary residence.

And to top it all off, you will have to pay depreciation recapture for the depreciation you took (or were entitled to take) when the house was a rental.

However, a 1031 exchange, which we discuss below, can be very useful in this situation.

* Note that years before 2009 do not count for purposes of this calculation.

What If I Rent Out the House and then Live in It and then Rent It Out and then Live In it Again?

Some situations, of course, are more complicated.

What if you first buy a house, rent it out, live in it, then rent it out, and then live in it again?

Here’s another example.

Let’s walk through an example to show you what we mean.

  • January 1, 2003: you buy a house for $600,000 and rent it out.
  • January 1, 2005: you move into the house and live in it.
  • January 1, 2007: you move out of the house and rent it out.
  • January 1, 2019: you move into the house and live in it.
  • January 1, 2021: you sell the house for $1,300,000.

For example’s sake, we’ll assume that there were no renovation expenses over the years and the $1,300,000 is net of selling expenses.

Let’s also assume that you took $200,000 of depreciation over the years.

What Does the Tax Code Say?

Oh boy, this is a doozy.

Let’s look at what the tax code says.

Section 121(b)(5)(A) says that you may not exclude gain allocated to periods of nonqualified use.

Section 121(b)(5)(B) says that gain allocated to periods of nonqualified use is your total gain multiplied by the ratio of the period of nonqualified use divided by the total period the property was owned by the property.

Section 121(b)(5)(C) says that the period of nonqualified use includes any period (not including periods before 2009) during which the property is not used as your or your spouse’s or former spouse’s principal residence.

Section 121(b)(5)(C) also says that the period of nonqualified use would not include:

  • Any time within the 5-year window before you sold the house that is after the last date you lived in the house.  This would not apply in this situation since there is no rental period after January 1, 2021 (the last date you lived in the house) since you sold it on that date.
  • Any time during which you or your spouse served on qualified official extended duty.  Let’s assume that isn’t applicable here.
  • Any time of temporary absence (not to exceed 2 years) due to change of employment, health conditions, or such other unforeseen circumstances.  Let’s assume that doesn’t apply here.

So How Much Non-Qualified Use Do I Have?

So putting it all together, given the situation above, all periods before 2009 are qualified use.

But you have 10 years of non-qualified use from 2009-2018, i.e., the periods beginning in 2009 when you didn’t use the property as your primary residence.

And since you owned the house for 18 years (from 2003-2020), your non-qualified use ratio is 10/18 = 55.55%.

So 55.55% of your gain not attributable to depreciation recapture is ineligible for the home sale gain exclusion.

Your total gain on sale not including depreciation recapture is $1,300,000 net selling price – $600,000 original cost = $700,000.

So you multiply $700,000 by 55.55% = $388,850.  This is your gain allocated to non-qualified use.  You have to include this gain in income and may not exclude it.

So How Much Do I Owe If I Move Back In for 2 Years?

Because the remaining gain of $311,150 ($700,000 – $388,850) is less than the maximum gain of $500,000 (let’s assume you are married and file jointly with your spouse), this $311,150 may be excluded from income.

But you still have to pay capital gains tax on the $388,850.  Assuming you’re in the 20% capital gains rate, you’re looking at a $77,770 federal capital gains tax bill, assuming 2018 rates.

And of course you have depreciation recapture under Section 1250 on the $200,000 of depreciation you took at 25% (assuming you’re in the top tax bracket).  So you’re looking at $50,000 of depreciation recapture tax, assuming 2018 rates.

So if you move back in for 2 years, your total federal tax bill is still $127,770.  And this doesn’t even take into account state taxes!  If you’re in California like me, you’ll be paying as much as $61,500 (depending on your tax bracket) of state taxes as well!

So How Much Did I Really Save By Moving Back In?

Now let’s look at your tax bill if you didn’t move in for two years.

Instead of only paying capital gains tax on 55.55% of your gain not attributable to depreciation recapture, you will now pay capital gains tax on the entire $700,000.

$700,000 x 20% = $140,000 capital gains tax.

And the depreciation recapture tax is the same at $50,000.

So if you don’t move back in, your total federal tax bill is $190,000.  And you could be looking at a 6-figure state tax bill as well (up to $110,700 if you live in California like me!).  So if you’re a California resident in the highest tax bracket, you’re looking at an over $300,000 combined federal and state tax bill!  The same would go for other high income tax states like New York.

Subtracting $127,770 from $190,000, you would save $62,230 in federal taxes by moving back in for 2 years.  And of course you would also potentially save tens of thousands of dollars in state taxes.

In a situation like this, it may actually be more advisable from a tax perspective to simply 1031 the property while it is a rental (see below) where you can potentially defer all taxes (including depreciation recapture) rather than taking a partial, albeit tax-free, home sale gain exclusion under Section 121.

What If I Rent Out a Part of the House or Take the Home Office Deduction?

Now, let’s say you rent out only a part of your home (say, a room) or take the home office deduction on part of it.  Let’s call this part of your home, whether the rental portion or the home office or both the “business use portion” of your home.

Whether or not you can apply the Home Sale Gain Exclusion to the business use portion of your home depends on whether or not the business use portion is within the walls of your dwelling unit (e.g., a room in the house you live in) or outside the walls of your dwelling unit (e.g., a guest house in the backyard).

Business Use Portion Is Within the Walls

If the business use portion of your home is within the walls, you can apply the Home Sale Gain Exclusion to the amount of gain allocated to the business use portion.

So let’s say your business use portion occupies 10% of your home.  You otherwise qualify for the Home Sale Gain Exclusion, and you have a $100,000 gain on your home.

Congratulations!  $90,000 of gain is tax-free on the sale of the personal residence portion of your home, and $10,000 of gain is tax-free on the business use portion of your home!

However, any depreciation deduction you historically claimed on your business use portion is subject to recapture as unrecaptured Section 1250 gain, though this can be deferred through a 1031 exchange (we talk about this later).

Business Use Portion Is Outside the Walls

If the business use portion of your home is outside the walls, you cannot apply the Home Sale Gain Exclusion to the amount of gain allocated to the business use portion.

So let’s say your business use portion occupies 10% of your home.  You otherwise qualify for the Home Sale Gain Exclusion, and you have a $100,000 gain on your home.

Well, only $90,000 of gain is tax-free on the sale of the personal residence portion of your home, but you have to recognize $10,000 of gain is tax-free on the business use portion of your home.

And any depreciation deduction you historically claimed on the business use portion is subject to recapture as unrecaptured Section 1250 gain.

But here’s the deal.  The 1031 exchange discussed below can defer taxes on both the $10,000 gain and the unrecaptured Section 1250 gain for your depreciation recapture!

Can I Use a 1031 Exchange in Conjunction with the Home Sale Gain Exclusion?

The answer is yes, you can use a 1031 exchange along with the home sale gain exclusion under Rev. Proc. 2005-14.

Doing so can help you avoid paying taxes this year on any gains or depreciation recapture attributable to your home office, a rental of part of your home, or the nonqualified use periods of your entire home.

Author:

Logan Allec, CPA

Logan is a practicing CPA and founder of Choice Tax Relief and Money Done Right. After spending nearly a decade in the corporate world helping big businesses save money, he launched his blog with the goal of helping everyday Americans earn, save, and invest more money. Learn more about Logan.

Back to top  
Subscribe
Notify of
guest

16 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Damn Millennial
5 years ago

Nice write up. I think the cap gains exclusion on your primary residence is an awesome part of the tax code.

Jim
Jim
5 years ago

What if you live in and own the house for only three or four years? Can you still take advantage of the exclusion? If not, what is the purpose of the rule that says you can do it once every two years?

Jay
Jay
5 years ago

Why do you say 10 years of non-qualification? He moved in and lived there for 2 years before the sale. that means last five years before the sale should take away 3 more years from his non qualification and make it 7 years instead of 10 years.
“But you have 10 years of non-qualified use from 2009-2018, i.e., the periods beginning in 2009 when you didn’t use the property as your primary residence”.

Lynn
Lynn
5 years ago

I had lived in my first home for 8 years since 2007. I rented it out when I moved out in 2015. I also own an LLC that owns a few rental properties. Would I still qualify the tax exclusion if sell the house to my LLC?

Steve
Steve
5 years ago

Did the requirement that a taxpayer live in a home for 2 out of 5 years in order to take advantage of the Home Sale Gain Exclusion change for the new 2018 tax law, compared to that rule in 2017 and prior years?

Someone told me that the “new” requirement for 2018 is now something like 5 of 8 years.

Nina
Nina
5 years ago

We used the gain exclusion on October of 2016 and thinking about selling our now primary property again this year in October. However this time our capital gain is over $500k but plan to use it on acquiring another property without borrowing loan. Is there any implications with 121 exchange? Or Can we exclude the $500k then anything above use 121 exchange? Thanks

Mohammad Ashraf
Mohammad Ashraf
5 years ago

Can you clarify the date of sale. Is this contract date when buyer and seller signed the contract or is it the close of escrow date. COE.
I lived in first three years and was renting out last two years. At the end of the two year we had a contract that
he will be buying my home but the home didn’t close 4 months after signing the contract (loan conditions)
so actually he has been living the home for little more than 2 years i.e. 2 years and 4 months. Can I still qualify?

Thanks

Valerie Pickens
Reply to  Mohammad Ashraf
5 years ago

I had the same question and called NATP (National Association of Tax Professionals)

This is the response

One Sale in Two Years. The taxpayer must not have used the $250,000 (or $500,000) exclusion for any residence sold or exchanged during the two-year period ending on the date of the current sale or exchange [IRC Sec. 121(b)(3)]. The date of sale is generally the earlier of the date the deed passes (is conveyed) or the time possession and the burdens and benefits of ownership are (from a practical standpoint) transferred to the buyer (Rev. Rul. 69-93). This will usually be the date of the closing statement.

Josh
Josh
5 years ago

Thanks for the article. Regarding a situation where you have rented out your home, does that always become “non-qualified” time if you move back in (or only if started the properties’ use as a rental like in the example you described)? For example, I own and live in primary residence for 10 years, then rent out for 2.5, then move back in – is there now 2.5 years of un-qualified use whenever I sell? If so, it seems like this is a huge hidden trap in the “live/own for 2 out of 5 years prior to sale” (which would really be “live/own for 2 out of 5 years prior to sale and never move back in if you ever rent out” exclusion. Thanks for the clarification.

Cate
Cate
5 years ago

Hello, thanks for sharing this super helpful and complex information! I am facing some big decisions for a property I’ve owned since 2000 that has been mostly a primary residence and more recently an intermittent rental property. I was wondering if there is an online resource/calculator available somewhere to help run these scenarios?

Rose Girard
Rose Girard
4 years ago

I’ve lived in my home overv,20 years. My partner has lived with me here 10+ years. If we marry will we be able to use the 500,000 exemption? would title in the house have to be in both our names? Thanks

Thomas
Thomas
3 years ago

Very interesting thank you. What if you owned for 20 years, lived in it for over 5 years, but have rented it out for the last 13 years. Could you purchase a primary residence and exclude 500K in gains for a married couple?

Steven C
Steven C
2 years ago

What if you marry and you both own a home. Over the past 5 years you have lived between both homes. You now want to sell both homes and buy one new shared home. Can you each spouse use the exclusion ($250,000) on each home? So spouse 1 sells his house and only uses his exclusion of $250k and then the other spouse sells her house and only uses $250k. Is this allowable?