Calculating capital gains on sale of a home is tricky. Especially if you’ve made improvements to the property.

Not everyone enjoys calculating capital gains on the sale of a home. It requires keeping close track of the cost of improvements made to the property over the years.

Over the past few weeks, we’ve fielded a number of questions about how to prove the cost of improvements and calculate the capital gains on the sale of a home.

Home prices have skyrocketed over the past ten years. Given how fast home prices have climbed, it’s clear sellers are concerned. They are looking for ways to save on capital gains tax.

Home prices have risen dramatically

According to the Federal Reserve Bank of St. Louis, the median home sales price in the first quarter of 2009 was $208,400. In the fourth quarter of 2021, the median home sales price was $408,100, nearly doubling in 13 years. But that doesn’t tell the whole story.

Over the past few years, home prices in certain locations have risen far faster:

  • According to Redfin, the median home price in Los Angeles has risen 14 percent year over year.
  • Zillow reports that the typical home in Boise, Idaho, rose 20.6 percent in value over the same period.
  • And according to the S&P CoreLogic Case-Shiller Index, home prices in 2021 rose 32.6% in Phoenix, 30.8% in Tampa, 28% in Miami, and 26.1% in Las Vegas. In a single year.

If you bought your home in a top 20 metro area a while ago, your property has likely seen a significant increase in value. If you’re getting ready to sell you may have a significant capital gains tax bill to pay. And, that capital gains tax might eat significantly into the funds you’ll have to pay for your next home, which has also increased significantly in value.

Calculating capital gains on sale of home: how it works

Here’s how the capital gains tax currently works: Generally, if you buy a home and live there as your primary residence for two of the past five years, you can keep up to $250,000 in capital gains tax free. If you’re married, you can keep up to $500,000 in capital gains tax free.

How do you calculate your capital gains? According to the IRS Publication 523, Selling Your Home, add up the cost of purchasing the property, plus the cost of any material improvements you’ve made over the years (such as replacing a roof, adding a room or a pool), plus the cost of selling the property (like the commission you’ll pay). Then, subtract that number from the sales price of the home.

Calculating capital gains on rebuilt home from 1993

One of our readers wrote in asking about how to calculate the capital gains on the home they demolished in 1993. They rebuilt it for about $250,000, and a year later added a swimming pool for $25,000. Their improvements totaled $275,000. Assuming they paid $100,000 for the old house, the basis (using very general figures) would be $375,000.

Let’s assume the house would sell today for $1 million. If they paid a 5 percent commission, or $50,000, they would add that amount to the basis, bringing it to $425,000. They would subtract $425,000 from the sales price of $1 million, and realize $575,000 in capital gain. Of that, they’d keep $500,000 tax free. They’d then owe long-term capital gain tax on the $75,000 at whatever their marginal tax rate would indicate.

(They may owe an additional 3.8 percent for the Net Investment Income Tax. That tax may affect those who have Net Investment Income and adjusted gross income above certain thresholds. For 2021, the threshold was $250,000 in adjusted gross income for married couples filing jointly. They may also owe taxes to the state in which the home is located.)

Calculating capital gains on rental homes

Many homeowners have rented out their properties for some period of time during their years of ownership. That complicates the capital gain calculation, especially if you’ve taken depreciation and need to repay the federal government for that depreciation after you sell.

Calculating capital gains on townhome sale

Another of our correspondents wrote: “We are selling our townhome this year that we bought in 1996. We lived there for 17 years as our primary residence. Then, we rented it out for eight years. There will be substantial gain. How do we shelter that?”

The easiest thing to do would be to move back into the property for two years and use it as your primary residence. Then, you would meet the standard of having lived there as your primary residence for two of the past five years, which would allow you to keep up to $500,000 in profits tax free. You may still have to recapture 25 percent of the depreciation you took on the property for those years, but you would shelter a significant part (if not all) of the gains.

As you rented the home for many years, you will have to make sure that you strictly adhere to the “two out of the last five years” rules. Otherwise, you might fail the test and not be entitled to take the exclusion. IRS Publication 523 gives a number of examples on your eligibility and how the exclusion works.

Calculating capital gains can be complicated

As with anything that comes from the IRS, the rules can be convoluted and confusing. If you have questions,  consult with a tax or financial advisor with extensive experience in this area. Don’t sell the home thinking you are safe from capital gains tax only to find out that you didn’t technically fit into the exclusion. Then, you’ll end up with a big capital gains tax bill. federal government.

Consider using a 1031 exchange

Alternatively, consider using a 1031 exchange if the property is now fully a rental property and you want to sell it. You’d buy a rental property that costs at least as much as the property you’re selling. That would allow you to defer capital gains tax until you sell the new property. If you keep the property, and pass it down to your heirs, under current tax law, the property would receive a step-up in value to the current market value at the time of your death.

Be aware that 1031 exchanges can be complicated and there are strict rules you have to follow when identifying replacement property and completing the sale. You can read some of our past columns about 1031 exchanges here and here.

Read more about calculating capital gains: