Selling real estate can be a solid way to increase your available cash, or to use the equity of a home for another goal. But when you sell real estate, there’s often a specific tax that goes along with the sale called the capital gains tax. It doesn’t apply to everyone, or even every dollar of your gain, but it’s important to understand this concept before planning your sale.

Tax forms laying scattered with a calculator, glasses, some cash, and a pen on top.
Image source: Getty Images

What is the capital gains tax?

In general, capital gains tax applies when you sell any kind of capital asset for a profit, also known as a capital gain. This could be an investment, or a car, or real estate holdings. But there are many exemptions to the capital gains tax on real estate. Many people end up paying no or very little capital gains tax throughout their lives.

If you’ve inherited property, or you’ve bought and sold several pieces of real estate in rapid succession, it’s important to know what you’re in for before you file your taxes.

There are two types of capital gains: short-term and long-term. Real estate is generally considered a long-term capital asset since you usually will hold it for more than one year, although some exceptions may apply.

How is real estate capital gains tax calculated?

The capital gains tax on real estate is calculated based on a number of specific factors, including:

  • Tax bracket. Like other types of income, capital gains are taxed based on your taxable income. The base rate you’ll pay is based on just how much income you earned total for the tax year. For example, if your taxable income for 2022 was between $41,675 and $459,750 for a single earner, or between $83,350 and $517,200 for married filing jointly, you’ll pay no more than 15% on the net capital gain.
  • Length of ownership. As stated above, real estate is generally considered a long-term capital asset, because it’s typically held for more than one year. But if you hold the property for two of the five years before selling it, you may not have to pay capital gains taxes at all.
  • Length of occupancy. Generally, you’ll pay capital gains on a house you don’t occupy for two of the five years before selling it. There may be an exception to this rule, however, if you’re disabled, in the military, or work in another qualified career.
  • Utilization of the property. How your property is used also matters. Was it a primary home? Was it a vacation home? Did you use it as an income property? Primary residences generally have the lowest capital gains taxes; income-generating properties, if not properly managed on paper, will result in the highest taxes.
  • Purchase price. The actual tax is generally calculated based on the amount you paid for your home, as well as improvements. The difference between the cost basis (what you paid and what you’ve since invested in the home) and its sales price is the figure by which the tax is calculated.
  • Other considerations. There are additional deductions that may apply in a limited number of cases that can drive down the amount of tax owed. In addition, if you’re subject to expatriate tax or bought the property using a 1031 exchange (a swap of one investment property for another) in the five years before selling it, it can affect your tax liability.

How to avoid capital gains tax on real estate

For many people, capital gains tax on real estate won’t apply. If you’ve lived in the same home for many years, or you didn’t make a fortune on your home’s sale, you’re likely eligible for the maximum exclusion of gain, which is $250,000 for single filers and $500,000 for married filing jointly. The maximum exclusion of gain is literally a way to reduce your taxable profit on your home by $250,000 to $500,000.

However, if you’re selling anything other than a primary residence, you almost certainly will be required to pay some amount of tax. In addition, if you acquired the property through a 1031 exchange during the last five years, you are not eligible for the maximum exclusion of gain.

You can avoid capital gains taxes entirely if you:

Own the home for at least two of the last five years

The ownership requirement ensures that homeowners receive the greatest benefit when it comes to capital gains tax reductions. You must have owned the house for at least two of the last five years. If you’re married filing jointly, at least one spouse has to meet this requirement.

Although you can certainly meet this requirement by living in your home for two years straight, this isn’t the only way to meet the ownership requirement. If you owned the property in the last five years and sold it before somehow re-acquiring it (for example, foreclosing on a home that you tried to sell with an owner-financing deal), you simply have to have been the owner for at least two of the five years. If you owned it for a while a decade ago, and then owned it for six months again before selling it, that doesn’t count.

Make the home your primary residence for two of the last five years

To meet the residence requirement, you need to have owned the home and used it as your primary residence for any two of the last five years. The two years don’t have to all occur together (unlike with the ownership requirement). Unlike the ownership requirement, both spouses also must meet the residence requirement individually to get the maximum tax exclusion.

Vacations and other short times away from home don’t count against you, even if you rented out your home while you were away – as long as you intended to return fairly quickly and continued to consider that home your primary residence while you were gone.

There are also exceptions to the residence requirement, largely for people who become ill or who are put on active military duty.

Service members have a different residence requirement test if they’re been on qualified active duty. You may be eligible for a period of suspension lasting no more than 10 years, along with the five-year test period, for a total of 15 years during which you need to only live in the home for two years. The period of suspension only applies if you’re on active duty, and you can’t use it for more than one property at a time.

A nursing home resident who lived in the house at least 12 months out of the last five years also can use any time spent in a licensed care facility toward the two-year residence requirement. (This is especially helpful for people who have to sell their home to move in with a family member permanently.)

Don’t sell another home in the two years before you sell your current residence

The exclusion of gain is meant to support homeowners, not commercial entities, so there’s a final requirement called the look-back requirement. The look-back period is two years before the sale of the home you want to take the exclusion on, during which you can’t have sold another home and taken the exclusion.

For example, suppose you bought a house in Chicago in 2015 and lived there for five years before being transferred and selling it. You would be fine to use the exclusion again with the house you bought in 2020 in Houston, but sold in 2023 because of yet another relocation. But you can't hold on to the house in Chicago, sell it in 2022, then sell your Houston home in 2023 and take the exclusion on both.

Related investing topics

The bottom line on capital gains taxes on real estate

Because real estate is taxed differently from other assets, it’s important to consider this before you sell a piece of property – especially if the property is your home. Since your personal home can be eligible for a tax exclusion of as much as $500,000 of profit, planning your moves strategically can have massive financial benefits.

The Motley Fool has a disclosure policy.