Updated

If you sell your home for more than you paid for it, you're a happy camper who gets to rake in all the profits, right? Not exactly. Just as you pay income tax and sales tax, you may very likely have to pay capital gains tax too.

Wait, what is capital gains tax, exactly? In a nutshell, it's a duty levied on property and possessions you sell for a profit -- including your home.

So just how much of a bite will Uncle Sam take out of your real estate sale? That depends, of course, on the tax laws in your state, your tax bracket and other factors. But first some good news: Unlike other investments, home sale profits benefit from a number of tax breaks that might exempt you from capital gains tax entirely.

"You can get out of paying any capital gains taxes on your home sale and not owe Uncle Sam a dime under certain conditions," says Kyle White, an agent with RE/MAX Advantage Plus in Minneapolis/St. Paul.

How to avoid capital gains tax

Here are some common circumstances under which the profits from the sale of your home would not be subject to capital gains tax:

  • The home has been your primary residence for at least two of the last five years.
  • Your profit on the sale is $250,000 or less if you're an individual, or $500,000 or less if you are married. To determine if you fall within those guidelines, subtract what you paid for the home from what you're selling it for. If you have gains of more than those amounts, make sure you track your expenses for any repairs and updates you made to your home. You may be able to deduct those costs from your profits, which might lower your gains to within those ranges.

With exemptions like these, it's actually relatively easy to avoid capital gains tax these days -- and you can do it over and over (well, at least every two years, since you have to live in the house at least that long).

How to avoid capital gains tax if you are an investor

If the home you're selling is a second home (i.e. vacation home) rather than your primary residence, avoiding capital gains tax gets 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 doing a 1031 exchange. This allows you to sell your property and buy another one without recognizing any potential gain.

"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, then you'll owe the capital gains taxes on the profit.

How to calculate your capital gains tax

To get an estimate of the taxes you'll pay, plug the numbers into a capital gains tax calculator, including your original purchase price, sale price, renovation costs, and other factors. And since everyone's situation varies, check with your accountant or tax professional to see if there are ways to curb the taxes you may have to pay.