What You Need to Know When Selling Your House from a Tax Perspective

13 min read
November 15, 2021

Since the pandemic hit, more and more companies are allowing remote work, giving people the opportunity to move around and live places they normally wouldn’t have been able to because of their job. Moving can be both exciting and stressful at the same time, but how does packing things up, selling your house, and moving away affect your tax return? Well, just like all things tax, that really depends on your situation. You may be eligible to exclude the full gain from the sale, or you may be eligible to exclude part of the gain from the sale. So, let’s go over it and find out!

What are we talking about?

The IRS likes to encourage certain behaviors and homeownership is one of them. That’s why there are certain credits and deductions focused around owning a home, such as deductible mortgage interest, deductible real estate taxes, and various home improvement credits. Selling a home is no different, the IRS allows up to $250,000 for individuals ($500,000 for married couples) of gain to be excluded from their gross income on the sale of their primary residence.

The keyword here is “principal residence.” This can get a little tricky if you own and live-in multiple homes because you can only have one principal residence. Generally, the most important factor is where you spend the most time. Just for informational purposes, additional factors include, but are not limited to, the address on your driver’s license, the address on your voter registration card or where you work, where you bank, etc.

So, let’s say you own and live-in multiple houses during the year, maybe one in Montana and another in Florida. You love the spring, summer, and fall in Montana but cannot stand the brutal winters, so you live in Florida for those 4-ish months. The home in Montana would be considered your principal residence and could qualify for this exclusion. Before we talk too much about the exclusion let's figure out how to calculate this gain.

How is this gain calculated?

A lot goes into this calculation, more than you would think, but in the simplest terms, the gain/loss is calculated like every other gain/loss situation: proceeds minus cost basis. We will review with more detail regarding the line items in this calculation, which is as follows:

Selling Price

-Selling Expenses

Amount Realized

-Adjusted Basis

Gain or Loss

Amount Realized

Calculating the amount realized is as simple as it sounds. Subtract any expenses associated with selling the home from the proceeds you received from the sale. These expenses can include legal fees, escrow fees, advertising, commissions, etc. Being able to deduct these expenses can be very beneficial for the seller. Sometimes they can be substantial, which in the end reduces any possible gain by that much.

Adjusted Basis: Increases

Figuring your adjusted basis can be a task. We start with the original cost basis of your home, which is simply the amount you paid to purchase your home, including a couple of settlement costs (appraisal fees, inspection fees, settlement fees, title fees, etc. Loan-related fees are not included in the basis of your home, rather they can be deducted on the Sch A as “points”) You may then include any increases to your basis. Generally, these increases are improvements you have made to the property since the purchase date. A couple of examples could be adding on to your house, remodeling your house, replacing the roof, etc. Improvements to the land could include paving your driveway, adding a fence, landscaping, etc. All these improvements increase your basis because they add value to the property, prolong its useful life, or adapt it to a new use.

Let’s say you purchased a home in 2015, and since then you’ve made the following improvements:

  • In 2015: Added a patio to the house for $15,000
  • In 2016: Remodeled the kitchen for $25,000
  • In 2016: Painted the bedroom for $200
  • In 2017: Paved the driveway for $10,000
  • 2015-2020: $3,000 in general home repairs.

From all these improvements to the property, the basis of the house would increase by $50,000. Painting a bedroom and general home repairs are not included in the basis of the home because they do not increase the value of the home, prolong its life, nor do they change the purpose of the property. These are simply expenses.

Adjusted Basis: Decreases

Another factor in calculating your adjusted basis is decreases to your basis. This isn’t as common as increases, but the most common decrease to your basis is depreciation. The only time you generally would see depreciation on a principal residence is if it was converted to/from a rental, or if you are self-employed with a home office using the actual method of the business use of home deduction. An additional decrease to your home’s basis would be if you received credit for an energy-efficient improvement to your home that was included as an increase in basis. The amount of credit received would be deducted from your basis.

For example, let’s say you paid $5,000 to replace your existing windows with Energy Star-rated windows. If eligible you may have received a $200 credit in the year they were installed. In this case, there would be a $5,000 increase to your basis, and a $200 decrease to your basis: Net $4,800 increase to your basis.

Now that we understand how to calculate the gain, let’s move on and see the requirements to be eligible for this exclusion.

You like benefits and perks, right? Our Membership Guide showcases all of the  value and savings you can get from an XYPN membership. Download today and do  the math!

How Do You Qualify for the Exclusion?

In general, there are two main Eligibility Tests that must be met to qualify for the full exclusion: the ownership test and the use test. There are also many exceptions to these requirements, and you may be eligible for a partial exclusion, depending on the situation.

Ownership Test: If you owned the home for at least 24 months out of the last five years leading up to the date of the sale. (For married filing jointly couples, this must be true for only one of the spouses.)

Use test: If you lived in the home as your principal residence for at least 24 months out of the last five years leading up to the date of sale. The 24 months does not have to be in a single block of time. The only requirement is a total of 24 months (730 days) during the 5-year period. (This must be true for both spouses if married filing jointly.)

In addition to these two tests, there is a look-back requirement that says you cannot take this exclusion if you have sold another home during the past 2 years, before the date of this sale, and took the exclusion on that, previous, sale of a home. This means that you can only take this exclusion once during a two-year period.

Exceptions to the Eligibility Tests:

As mentioned above there are a couple of exceptions to these requirements, we will go over a few, but the exhaustive list can be found In IRS Publication 523, Selling Your Home. page 4: Exceptions to the Eligibility Test.

When a separation or divorce occurred during the ownership of the home.

This is directly from the IRS publication named above:

If you were separated or divorced prior to the sale of the home, you can treat the home as your residence if:

  • You are a sole or joint owner, and
  • Your spouse or former spouse is allowed to live in the home under a divorce or separation agreement and uses the home as his or her main home.

If your home was transferred to you by a spouse or ex-spouse (whether in connection with a divorce or not), you can count any time when your spouse owned the home as time when you owned it. However, you must meet the residence requirement on your own.

In the simplest of terms, this is saying if you were divorced before the sale of your home and you either solely owned or jointly owned the property with your (ex) spouse and your (ex) spouse is allowed to live in the house after the divorce, but instead you sell the home, it is still considered your principal residence. Now on the other hand, If the house is transferred to you, you can count any time your (ex) spouse owned the home as time you have owned it to satisfy the ownership test, but you, individually, must satisfy the use requirement of 24 months.

When the death of a spouse occurred during the ownership of the home.

If you are a widowed spouse and do not meet the ownership or use test, you may include any time your late spouse owned and lived in the home, that is if you haven’t remarried at the time of the sale. Additionally, you may be eligible to still claim $500,000 rather than $250,000 if the following conditions apply:

  1. You sell the home within two years of the death of your spouse.
  2. You haven’t remarried at the time of sale.
  3. You haven’t taken the exclusion on another home less than two years before this current sale. (This includes your late spouse)
  4. You meet the ownership and use requirements (including your late spouse’s ownership and use)

These two exceptions above are sadly the more common exceptions you see when it comes to the sale of a home. The rest can be found in the publication I noted above.

  • The sale of the home involved a vacant lot.
  • You owned a remainder interest (the right to own the home in the future) and sold that right.
  • Your previous home was destroyed or condemned.
  • You were a service member during the ownership of the home.
  • You acquired or are relinquishing the home in a like-kind exchange.

Business or Rental Use of home:

If you have ever used a portion of your home for business or rental purposes, this may affect your gain calculation. This would apply if you had a storefront with living quarters above or rented out an apartment in a duplex. If the business/rental use was within the living area, such as a spare room used as a home office or a rental of a spare bedroom, then the usage does not affect the overall gain calculation. If you had a space that was formerly used for business or rental purposes, but ALL the following are met, the space will be considered residence space:

  • you weren’t using the space for those purposes at the time you sold the property,
  • you didn’t earn any business or rental income from the space in the year you sold the home,
  • and you used the space as residence space for two years out of five years leading up to the sale.

All the above are exceptions to the business/rental use of property and there will not be any effect on the gain/loss calculation; However special considerations apply if you had a home office or rental use of your home for which you were allowed depreciation deductions. This business or rental use of your home will make you subject to depreciation recapture, which is an entirely separate subject. But to keep things simple the realized gain from the sale of the home is compared to the depreciation taken on the home, the smaller of these two would be considered the depreciation recapture and be treated as ordinary income on the tax return (capped at a top rate of 25%), regardless of the exclusion.

Comprehensive Example:

Let’s say you are single and purchased your first home in January 2015 for $500,000 (included in this amount are settlement fees, title fees, etc.) Your basis in the property is $500,000. Throughout the years you’ve made various improvements costing $150,000 all of which added value to the property and extended its useful life. It is now 2021 and you are looking to sell your house. You received and accepted an offer for $885,000. You spent $20,000 on advertising, a real estate agent, and commissions. What is your gain/loss and how much is excluded?

The basis of the property is adjusted for the improvements made over the years leading to an adjusted basis of 650,000. The entire gain of 215,000 is excluded from gross income because both the ownership and use tests are met, the exclusion wasn’t taken in the past two years, and it is under the 250,000-maximum exclusion.



Selling Expenses


Amount Realized


Adjusted Basis




Exclusion Amount


Now let’s say we sold the house for 985,000 rather than $885,000.

The gain realized on the sale of the house is now over the exclusion limit. The remaining $65,000 is going to be reported on Sch D as long-term capital gains and will be included in the gross income in the year of sale.



Selling Expenses


Amount Realized


Adjusted Basis




Exclusion Amount


Taxable Gain


Now let’s say you’ve had a home office for the past 2 years; this is a dedicated space that is solely used for your Schedule C business. You are using the actual method to determine your home office deduction and you have depreciated your home $12,000 over the years. Let’s calculate the gain/loss.



Selling Expenses


Amount Realized


Adjusted Basis






Gain Eligible for Exclusion


Taxable Gain


The gain is calculated the same way, by subtracting the selling expenses and adjusted basis, which is reduced by the depreciation taken on the home. In this example, we see depreciation recapture. As mentioned above, depreciation recapture is the lesser of the realized gain or the depreciation taken or allowed to be taken. In this case, the $12,000 of depreciation taken is going to be included in the gross income.

Everything we have been talking about above has been for the full exclusion. Like I mentioned the IRS tends to encourage certain behaviors, and if moving is out of your control you may still be eligible for an exclusion, just not the full amount.

Partial Exclusions

If you do not meet the two Eligibility Tests, Ownership test, or use test, you may be eligible for the partial exclusion. There are three buckets you may fall in to qualify for a partial exclusion: a work-related move, a health issue, or an unforeseeable event. The following requirements are taken directly from the IRS Publication 523, Selling Your Home.

Work-Related Move:

You meet the requirements for a partial exclusion if any of the following events occurred during your time of ownership and residence in the home.

  • You took or were transferred to a new job in a work location at least 50 miles farther from the home than your old work location. For example, your old work location was 15 miles from the home and your new work location is 65 miles from the home.
  • You had no previous work location, and you began a new job at least 50 miles from the home.
  • Either of the above is true of your spouse, a co-owner of the home, or anyone else for whom the home was his or her residence.

Health-Related Move:

You meet the requirements for a partial exclusion if any of the following health-related events occurred during your time of ownership and residence in the home.

  • You moved to obtain, provide, or facilitate diagnosis, cure, mitigation, or treatment of disease, illness, or injury for yourself or a family member.
  • You moved to obtain or provide medical or personal care for a family member suffering from a disease, illness, or injury. Family includes your:
    • Parent, grandparent, stepmother, stepfather.
    • Child (including an adopted child, eligible foster child, and stepchild), grandchild.
    • Brother, sister, stepbrother, stepsister, half-brother, half-sister.
    • Mother-in-law, father-in-law, brother-in-law, sister-in-law, son-in-law, daughter-in-law.
    • Uncle, aunt, nephew, or niece.
  • A doctor recommended a change in residence for you because you were experiencing a health problem.
  • The above is true of your spouse, a co-owner of the home, or anyone else for whom the home was his or her residence.

Unforeseeable Events:

You meet the standard requirements if any of the following events occurred during the time you owned and lived in the home you sold.

  • Your home was destroyed or condemned.
  • Your home suffered a casualty loss because of a natural or man-made disaster or an act of terrorism. (It doesn’t matter whether the loss is deductible on your tax return.)
  • You, your spouse, a co-owner of the home, or anyone else for whom the home was his or her residence:
    • Became divorced or legally separated.
    • Gave birth to two or more children from the same pregnancy.
    • Became eligible for unemployment compensation.
    • Became unable, because of a change in employment status, to pay basic living expenses for the household (including expenses for food, clothing, housing, medication, transportation, taxes, court-ordered payments, and expenses reasonably necessary for making an income).

How to calculate the Partial Exclusion:

Step 1: To calculate the partial exclusion, we first need to determine the shortest of the following:

  1. Your time of residence in the home during the 5-year period leading up to the sale:
  2. Your time of ownership of the home leading up to the sale:
  3. The time that has lapsed between the sale and the date you last sold a home for which you took the exclusion:

Step 2: We must then divide the shortest period above by 730 days or 24 months.

Step 3: We will then multiply this by $250,000. STOP if single If Married filing joint Continue to step 4.

Step 4: Repeat These steps for your spouse (If married filing jointly); Add the two results.


Let’s say you are single and just purchased and moved into your first house in June of 2020 for $300,000 (including all the fees). In August of 2021, you were transferred to a new job clear across the country and were required to move. Luckily your home appreciated in value over the year, and you sold it for $500,000. Because this is a work-related move and you had to move clear across the country you are eligible for the partial exclusion.

Let’s calculate the exclusion limit.

Step 1: Determine the shortest of the following Periods

  1. Residency: June 2020-August 2021= 14 Months
  2. Ownership: June 2020-August 2021=14 Months
  3. First home: Never taken the exclusion

Step 2: Take the smallest period from Step 1 and divide that number by 24 months.

  • 14 months/24 months: 0.583

Step 3: Multiply result from Step 2 by $250,000.

  • $250,000*0.583=145,833

From this scenario, the exclusion is limited to $145,833.

Now let’s calculate the gain assuming a 1% selling expenses.



Selling Expenses


Amount Realized


Adjusted Basis




Exclusion Amount


Taxable Gain


Because of the limitation, $49,167 will be included on your Schedule D in the year of the sale. If you were to move for a different reason, besides work/health/unforeseeable event, the entire gain would be on your Schedule D and included in your gross income.

How Can XYTS Help?

As we all know moving is a huge task that is already stressful enough. At XYTS we can help guide you through this complicated situation and calculate your taxable gain if any. So, sign up for a tax planning engagement and we will get everything sorted out (for you and your clients)!

New call-to-action

XYPN Blake Mattfeldt HeadshotAbout the Author
XYTS Tax Specialist Blake Mattfeldt is a recent graduate of the Master of Professional Accountancy program at Montana State University. He has a bachelor’s degree in business with a concentration in finance and accounting. In addition to his experience with the Volunteer Income Tax Assistance program while at Montana State, he worked as a tax intern for Rudd and Company.

Subscribe by email