Do i have to pay capital gains if i sell my house and buy another

Do i have to pay capital gains if i sell my house and buy another
When you sell your house and buy another, capital gains are the profits that you make from your sale, and these are subject to capital gains tax. However, if your new home purchase doesn’t impact your capital gains, the exclusions available could allow you to reduce your tax liability. If your sale is conducted properly and your living arrangements meet the criteria, you can avoid capital gains tax all together. 

Here's a Breakdown of How Capital Gains Work When Selling Your House and Buying Another

Each homeowner can exclude up to $250,000 in capital gains on a sale of a home, assuming certain criteria are met. Married taxpayers filing their taxes jointly can exclude up to $500,000. Additionally, capital gains are reduced by costs of home projects that build equity, or expenses paid at the purchase or sale of a house. It is important to understand the capital gains calculation process so you can record these expenses properly and avoid unnecessary taxes. 

Can You Qualify for the Capital Gains Tax Exclusion?

Before making any calculations, you must first qualify for the capital gains exclusion. This requires satisfying three criteria: 

  1. You have lived in the home at least two years. If you sell your home and buy another, the capital gains exclusion requires you to have lived in the first home for at least two years of the five years prior to the sale.
  2. The home is your primary residence. For at least two of the five years before the sale, you or your spouse must have used the home as your primary residence.
  3. Other capital gains exclusions were made more than two years ago. If you have used the capital gains exclusion before, it must have been more than two years ago.

How to Calculate Capital Gains When Selling a House and Buying Another

Before 1997, different methods were used to calculate capital gains taxes, and one home sale was impacted by a new home purchase. Currently, the tax implications of each home are calculated separately. This means that when you sell your house and buy another, capital gains are calculated only using the sale and purchase price of the first house. 

Free Download: The Ultimate Guide to Building Equity in Your Home

Capital gains are calculated using the following method: The sale price of your home minus what you paid for it, other purchase costs, improvements you made, selling costs, and some insurance payments. In other words, the capital gains are the total net profits you made from the home after deducting expenses related to improving, buying, and selling the home. 

Capital Gains Tax Exclusion Example

Let's say you purchase your first home for $100,000. At that time, you pay closing costs totaling $3,000. While you own the house, you renovate the kitchen, bathroom, and finish the basement, totaling $50,000 in expenses. Thanks to your home upgrades, you’re able to sell the house for $250,000. Your selling costs amount to $2,000. You can calculate your capital gains as follows:

$250,000 – ($100,000 + $3,000 + $50,000 + $2,000) = $95,000

As a single person who owned and lived in the house for at least two years in the five years prior to sale, you can exclude up to $250,000 of capital gains. This means that your $95,000 capital gains do not have to be reported, and you will not pay taxes on it. Keep in mind that when you sell your house and buy another, capital gains will be calculated separately on the new house when you sell it.


If your total capital gains exceed the exclusion amount, you will have to pay capital gains taxes at a rate decided by your income. When calculating your capital gains, be sure to diligently record investments you’ve put into the home as well as expenses incurred when you bought and sold the property. If you’re not sure what these expenses are or how to calculate your capital gains taxes, ask your realtor to help you or refer you to a property tax expert who can help.

Selling your second home? When you sell a vacation home, rental, fix-and-flip, or any second property that is not your primary residence, you will typically be responsible for paying capital gains taxes on any profits you make, at a rate of up to 20%, depending on your tax bracket.  But you may be able to mitigate those taxes. In this article, we discuss under what conditions you can minimize your capital gains tax, and maximize your profits as sellers.

To give you the most up-to-date information, we talked with real estate attorney Koert Brown with Rammelkamp Bradney in Illinois, and top real estate agent AJ Pettersen of the Advisor Realty Group, a high performance real estate team in Minneapolis that also specializes in Townhome sales.

Disclaimer: Information in this blog post is meant to be informational and used as a helpful guide only, and not professional tax or legal advice. If you need help determining the taxes on the sale of your second home, HomeLight always encourages you to reach out to a tax advisor regarding your particular situation.

Selling a second home vs. selling a primary residence

When selling a primary home, the seller generally doesn’t have to worry about paying taxes on profits — up to a certain point. The IRS allows a single-filer homeowner to forgo paying taxes on up to $250,000 gained from the sale, and a married couple can exclude up to $500,000 in profit.

Brown says a property is considered a primary residence if the owners occupy it the greater part of a year (6+ months) for at least two of the past five years, and can prove it. For audit purposes, proof is determined by where the owner is employed, banks, receives mail, and attends community places like recreational clubs.

You typically have to pay tax on capital gains on sale of a second home at a rate of up to 20% in 2022, depending on your tax bracket.

A property is considered your second home if it’s a vacation home or an investment property that you rent out.

How much you’ll pay in capital gains tax depends on several factors:

  • How long you’ve owned the second home
  • The cost of owning the property, including the cost of capital improvements and any fees
  • Your income tax bracket
  • Your marital status
  • Whether you rent out your second home
  • Whether you replace that property with a like-exchange
  • Whether you claim an investment loss in the same tax year

Do i have to pay capital gains if i sell my house and buy another

Selling a Second Home? Work With a Top Agent

While you will likely have to pay tax on any capital gains realized from the sale of your second home, working with a top agent can take some of the sting out.

HomeLight data shows that the top 5% of agents across the U.S. help clients sell their home for as much as 10% more than the average real estate agent, potentially helping to offset the cost of taxes.

What are capital gains taxes?

Capital gains taxes are the taxes you pay when you sell an appreciating asset and make a profit (capital gain). According to the IRS, there are two main categories of capital gains tax on the sale of a non-primary residence:

  • Short-term capital gains tax. This is a tax on any profits from the sale of a property that you’ve owned for one year or less. For short-term properties, you’ll typically pay the same tax rate as you would for your ordinary income.
  • Long-term capital gains tax. If you’ve owned your second home for more than a year, you’ll typically pay a long-term capital gains tax between 0% and 20%, depending on your earnings. According to the IRS, property owners will pay a 15% tax unless they exceed the higher income level.

What’s the 2022 capital gains tax rate?

For tax year 2022, a capital gain rate of 15% applies if your taxable income is $40,400-$445,850 for single, $80,800-$501,600 for married filing jointly or qualifying widow(er), $40,400-$250,800 for married filing separately, or $54,100-$473,750 for head of household.

In 2022, a net capital gain tax rate of 20% applies if your taxable income exceeds the thresholds set for the 15% capital gain rate.

Ways to reduce your capital gains tax

The capital gains tax may seem high, but don’t kiss all of those tax dollars away just yet. Depending on your situation, there are several different ways that you may be able to mitigate some of your capital gains.

Adjust your profits to reflect any acquisition costs or property improvements

At the most basic level, your capital gain is calculated by figuring out your cost basis and subtracting any profit made from the sale.

The cost basis is typically the amount you spent to buy and improve your second home, including the purchase price, any acquisition or closing fees, and the cost of any capital improvements you made while owning it. Capital improvements are permanent repairs or upgrades not including routine repairs or maintenance. For a list of the capital improvements you can add to the cost basis of your home, see IRS Publication 530.

You can also increase your cost basis by adding any qualifying real estate fees, such as real estate commission and closing costs, paid when selling your second home, which can reduce your taxable gain even further.

How to calculate capital gains tax

Remember that the capital gains tax depends on marital status, how long you’ve owned your home, your taxable income, and your net profit. For example, if you’re married filing jointly with a net combined income of $233,000, and you purchased your second home for $400,000 and sold it for $500,000, it would initially appear that you profited $100,000 from the sale.

But if you also spent $15,000 on acquisition costs, $20,000 to renovate the bathrooms, $25,000 to put on a new roof, and $30,000 in real estate commission, your cost basis may be $490,000. Your profit could actually only be $10,000. In this example scenario, you’ll pay a capital gains tax rate of 15% or $1,500.

Depreciate the property if it was used as a rental

If you rent out your home,  you can typically deduct depreciation on an annual basis. Simply put, depreciation is the tax deduction of the cost to fix, update, maintain, or own a rental property, spread out over the years you own the property.

If your second home was rented out while you owned it, you could opt to deduct real estate depreciation for the number of days it was occupied by renters or available to rent each year. As an example, if the property was rented or available to be rented for half of the year, you could claim 50% of the yearly depreciation deduction. Each year, the depreciation would continue to reduce your cost basis.

However, keep in mind that if you depreciate your second home, you’ll have to pay another tax called a depreciation recapture, which is a flat 25% of the cumulative depreciation. For example, if you’ve claimed $35,000 in total depreciation, you would likely face an additional $8,750 in taxes when you sell.

Rent out your second home

You cannot depreciate a vacation home, which is considered personal property, but because it’s a second property, when you sell, it is fully taxable at the capital gains rate as an investment. However, renting out a vacation home is one of the most common ways for a homeowner to mitigate their tax liability on the sale of a second home. In this case, you can typically deduct depreciation and the costs to own, maintain, and rent that property.

To use this strategy, you’ll need to start renting out the home long before you list it. It’s also important to note that if you use this strategy to mitigate your capital gains tax, you cannot have used it as a primary residence the last two of the past five years, and you will very likely have to pay the depreciation recapture tax. It’s strongly encouraged that you consult with a tax and/or real estate professional to map out whether this strategy is available and how it might apply to your situation.

Make your second home your primary residence

Another way to reduce your tax liability is to turn your second home into your primary residence, which will make you eligible for up to $500,000 exclusion. Every homeowner will most likely exempt the sale of a primary residence within their lifetime, says Brown.

The definition of primary residence is most important when going about making your second home your primary residence. You must have lived in it the majority of the year (6+ months) in any given year for two out of the last five years.

“That’s the safe harbor that will get you there. The tests, facts, and circumstances that prove a home is your primary residence include your place of employment, where you have your mail sent, where you bank and where you go to church,” says Brown.

It’s important to note that you can’t use this strategy if you have excluded a capital gains tax on the sale of another property within the past two years.

Do a 1031 exchange and defer capital gains tax

Named for the IRS Code Section 1031, a “1031 exchange” — also called a “like-kind exchange” — allows you to swap out an investment home for another property of the same type without paying any capital gains tax.

The 1031 exchange can generally only be used if the real estate involved is an investment or business property, so you can likely only employ the like-kind strategy if your second home is used primarily as a rental rather than for personal enjoyment, and the replacement property cannot be used as your primary residence. There are also other specific exclusions in the tax code even if a property is used for investment or business purposes. These include:

  • Inventory or stock in trade
  • Stocks, bonds, or notes
  • Other securities or debt
  • Partnership interests
  • Certificates of trust

If you want to do a like-kind exchange, the clock starts ticking right after you sell the first property. You must find the replacement home within 45 days and must close on the second purchase within 180 days. If you miss that deadline, you’ll get hit with the full capital gains tax.

With the 1031 exchange, you do not avoid capital gains tax altogether. Instead, you are deferring the tax until you sell the replacement property. However, there is typically no limit to the number of times you can defer the capital tax with the 1031 exchange. You can continue rolling capital gains into a replacement investment property indefinitely, deferring the tax over and over and eventually paying it or passing the rental property to a beneficiary.

Property requirements for the 1031 exchange

So you’d like to take advantage of the 1031 exchange rule — but how do you know if your property and the replacement property qualify?

For the initial property, these conditions apply:

  • You must have owned and held the property for at least 24 months immediately preceding the 1031 exchange; and
  • You must have rented the subject property at fair market rates to other people for at least 14 days (or more) during each of the preceding two years; and
  • You must have limited your personal use and enjoyment of the property to not more than 14 days during each of the preceding two years, or 10% of the number of days that the property was actually rented out to other people during each of the preceding two years. For example, if you rent your investment property for 330 days in a given year, you can use it for personal enjoyment no more than 33 of the remaining 35 days of that year. However, time spent in the home to do maintenance and repairs don’t count toward that limit.

For example, if you rent out your vacation home at least 14 days per year for two consecutive years, don’t live in it more than 14 days per year, and it’s considered an investment property in the eyes of the IRS, it could be eligible for the 1031 exchange.

Likewise, the replacement property must meet the following criteria:

  • You must own the property for at least two years after exercising the 1031 exchange; and
  • You must rent it out for at least 14 days per year; and
  • You cannot use the property for personal enjoyment for more than 14 days per year or 10% of the days the home is rented out.

According to Petersen, the biggest difficulty with 1031 exchanges right now is the deadline combined with the inventory shortage.  “It’s not easy to find a like-kind property for a 1031 exchange in the first place and it can be harder still to do it in a 45-day time frame. I’ve had 1031 exchanges fall through because of the housing shortage.”

A warning about deferred 1031 exchanges

For homeowners wanting more flexibility in the 1031 exchange timeline, there is such a thing as a deferred exchange in which the owner sells the property to a qualified intermediary, known as a 1031 Accommodator, who buys the property at a later date. The entire process must still take place within 180 days and the sale is more complex as well as more risky.

The IRS warns that homeowners should fully vet a 1031 Accommodator and beware of schemes as there have been instances of these sales falling through or not meeting IRS requirements. It’s important to consult with a tax and/or real estate professional to see if this strategy might work for you.

Offset capital gain from sale of rental property with an investment loss

If your second home is a rental property and you are holding an investment that has lost value, there is a tax provision that may let you sell that investment in the same tax year to offset some or all of your capital gains. Also called tax-loss harvesting or tax-loss selling, this investment strategy is commonly used to minimize taxable capital gains from investment income, but can sometimes also be used to offset capital gains from the sale of a rental property.

When using this strategy, Brown says it’s important to remember that a short-term capital gain can only be offset with a short-term capital loss; a long-term capital gain can only be offset by a long-term capital loss.

Example: In July 2021, Jim and Elizabeth sold a rental property for a net profit of $45,000. They were holding a stock investment that had lost $55,000 in value. To offset their capital gains for tax year 2021, they sold $45,000 of that stock at the end of 2021 and paid $0 capital gains tax.

When in doubt, talk to a professional

Real estate taxes can get complicated fast. It’s best to partner with a real estate accountant and a top real estate agent with experience in selling second homes. They can help you determine your net profits and identify opportunities to mitigate your capital gains tax so you don’t pay more than you absolutely must.

Do i have to pay capital gains if i sell my house and buy another

Find a Top Agent to Sell Your Home for More

Tell us a little about your home and selling needs and we’ll provide recommendations for up to three top real estate agents in your area.

Header Image Source: (Gunnar Ridderström / Unsplash)

Can I avoid capital gains by buying another house?

If you plan on buying another house, you have options that may reduce or eliminate your capital gains tax liability depending on whether the property is for personal use or if you plan to reinvest those funds into an investment property using a like-kind 1031 exchange.

How long do I have to buy another property to avoid capital gains?

You do not need to make a direct swap in a like-kind exchange. Instead, once you sell your first investment property you can put the proceeds from this sale (your capital gains profits) into escrow. You then have 180 days to find and purchase another similarly situated piece of land.

Do I pay capital gains if I reinvest the proceeds from sale?

Homeowners can avoid paying taxes on the sale of their home by reinvesting the proceeds from the sale into a similar property through a 1031 exchange.

How long do I have to reinvest proceeds from the sale of a house?

Gains must be reinvested within 180 days of the day they are recognized as taxable income.