What is a capital gains tax? It’s the income tax you pay on gains from selling capital assets.

If you sell your home for more than what you paid for it, that’s good news for you! The downside, however, is that you probably have a capital gain. You may have to pay taxes on your capital gains in the form of capital gains tax.

Yep, just as you pay income tax and sales tax, gains from the sale of your home sale are subject to taxation, too.

Complicating matters is the new Tax Cuts and Jobs Act, which is changing the rules somewhat as of the 2018 tax year. So if there’s ever a time to brush up on all things capital gains, it’s right now. Here’s what you need to know.

What is capital gains tax—and who pays it?

In a nutshell, capital gains tax is a tax levied on property and possessions that you sell for a profit—including your home.

If you sell it in one year or less, you have a short-term capital gain.

If you sell the home after you hold it for longer than one year, you have a long-term capital gain. Unlike short-term gains, long-term capital gains are subject to preferential capital gains tax rates.

What about the primary residence tax exemption?

Unlike other investments, home sale profits still benefit from exemptions that might exempt you from tax on capital gains entirely under some conditions, says Kyle White, an agent with Re/Max Advantage Plus in Minneapolis–St. Paul.

The IRS gives each person, no matter how much the person earns, a $250,000 tax-free exemption on capital gains from a primary residence. This is not just a capital gains deferral or “rollover,” like the old, pre-1998 rules. You can exclude this capital gain from your income permanently.

“So if you and your spouse buy your home for $100,000, and years later sell for up to $600,000, you won’t owe any capital gains tax,” says New York attorney Anthony S. Park. However, you do have to meet specific requirements to claim this capital gains exemption:

  • The home must be your primary residence.
  • You must have owned the home for at least two years.
  • You must have lived in the home for at least two of the past five years.
  • You cannot have taken this exclusion in the past two years.

If you don’t meet all of these requirements, you may be able to take a partial exclusion for capital gains tax if you meet certain exceptions (e.g., if your job forces you to move before you live in the home two years). For more information, consult a tax adviser or IRS Publication 523.

What’s my capital gains tax rate?

For capital gains over that $250,000-per-person exemption, just how much tax will Uncle Sam take out of your long-term real estate sale? In the past, your capital gains tax rate depended on your tax bracket. Under the new tax law, long-term capital gains tax rates are now based on your income instead of on tax brackets, explains Park. Let’s break it down.

  • Your tax rate is 0% on long-term capital gains if… you’re a single filer earning less than $39,375, married filing jointly earning less than $78,750, or head of household earning less than $78,750.
  • Your tax rate is 15% on long-term capital gains if… you’re a single filer earning between $39,376 and $434,550, married filing jointly earning between $78,751 and $488,850, or head of household earning between $52,751 and $461,700.
  • Your tax rate is 20% on long-term capital gains if… you’re a single filer earning more than $434,550, married filing jointly earning more than $488,850, or head of household earning more than $461,700. For those earning above $488,850, the rate tops out at 20%, says Park.

Don’t forget, your state may have its own tax on income from capital gains. And very high-income taxpayers may pay a higher effective tax rate because of an additional 3.8% net investment income tax.

If you held the property for one year or less, it’s a short-term gain. You pay ordinary income tax rates on your short-term capital gains. That’s the same income tax rates you would pay on other ordinary income such as wages.

Do home improvements reduce tax on capital gains?

You can also reduce the amount of capital gains subject to capital gains tax by the cost of home improvements you’ve made. You can add the amount of money you spent on any home improvements—such as replacing the roof, building a deck, replacing the flooring, or finishing a basement—to the initial price of your home to give you the adjusted cost basis. The higher your adjusted cost basis, the lower your capital gain when you sell the home.

For example, if you purchased your home for $200,000 in 1990 and sold it for $550,000, but over the past 29 years have spent $100,000 on home improvements, that $100,000 would be subtracted from the sales price of your home this year. Instead of owing capital gains taxes on the $350,000 profit from the sale, you would owe taxes on $250,000. In that case, you’d meet the requirements for a capital gains tax exclusion and owe nothing.

You can’t take a deduction from income for ordinary repairs and maintenance, unfortunately.

Take-home lesson: Make sure to save receipts of any renovations and repairs, since they can help reduce your taxable income when you sell your home.

How the tax on capital gains works for inherited homes

What if you’re selling a home you’ve inherited from family members who’ve died? The IRS also gives a “free step-up in basis” when you inherit a family house. But what does that mean?

Let’s say Mom and Dad bought the family home years ago for $100,000, and it’s worth $1 million when the last parent dies and leaves it to you. When you sell, your purchase price (or “basis”) is not the $100,000 your folks paid, but instead the $1 million it’s worth on the last parent’s date of death.

You pay capital gains tax only on the difference between what you sell the house for, and the amount it was worth when your last parent died.

What if I have a loss from selling real estate?

If you sell your personal residence for less money than you paid for it, you can’t take a deduction for the capital loss. It’s considered to be a personal loss, and a capital loss from the sale of your residence does not reduce your income subject to tax.

If you sell other real estate at a loss, however, you can take a tax loss on your income tax return. The amount of loss you can use to offset other taxable income in one year may be limited.

How to avoid capital gains tax as a real estate investor

If the home you’re selling is a second home (i.e., vacation home) rather than your primary residence, avoiding capital gains tax is a bit more complicated. But it’s still possible. The best way to avoid a capital gains tax if you’re an investor is by swapping “like-kind” properties with a 1031 exchange. This allows you to sell your property and buy another one without recognizing any potential gain in the tax year of sale.

“In essence, you’re swapping one investment asset for another,” White says. He cautions, however, that there are very strict rules regarding timelines and guidelines with this transaction, so be sure to check them with an accountant.

If you’re opting out of the rental property investment business and putting your money in another venture that does not qualify for the 1031 exchange, then you’ll owe the capital gains tax on the profit.

As featured on realtor.com