This article is reprinted by permission from NerdWalletThe investing information provided on this page is for educational purposes only. NerdWallet does not offer advisory or brokerage services, nor does it recommend or advise investors to buy or sell particular stocks, securities or other investments.

If your home’s value has soared, congratulations. If you decide to sell, beware.

Financial adviser James Guarino says some clients don’t realize that home sale profits are potentially taxable until their returns are prepared — and by that time, they may have spent the windfall or invested the money in another house.

“They’re not happy campers when they find out that Uncle Sam not only is going to tax this as a capital gain, but they’re also going to have some exposure at the state level,” says Guarino, a certified public accountant and certified financial planner in Woburn, Massachusetts.

Longtime homeowners who took advantage of previous tax rules, which allowed people to roll the gains from one home into the next, could be in for a particularly nasty surprise. Those old rules could trigger taxes even if you’re under the current $250,000-per-person exemption limits.

Understanding how home sale profits are calculated — and how you can legally reduce your tax bill — could save you money and stress if you’re planning to cash in on the current home price boom.

How tax rules have changed

Until 1997, home sellers didn’t have to pay taxes on their profits if they bought another home of equal or greater value within two years. In addition, people 55 and older could use a one-time exclusion to avoid paying taxes on up to $125,000 of home sale profits.

The Taxpayer Relief Act of 1997 changed the rules so that instead of rolling profits into another home, homeowners could exclude up to $250,000 of home sale profits from their income. To qualify for the full exclusion, home sellers must have owned and lived in the home at least two of the five years prior to the sale. Married couples could shelter up to $500,000.

Those exclusion limits haven’t changed in 25 years, while home values have nearly tripled. The median home sale price when the law passed was $145,800, according to the Federal Reserve Bank of St. Louis. The median was $428,700 in the first three months of this year. Median means half of homes sold for less and half for more.

Having a taxable gain on a home sale used to be relatively rare outside of high-end properties and high-cost cities, but that’s no longer true, financial advisors say.

Also see: ‘Should we wait to see how the market plays out?’ I want to purchase a rental home. Is this a good time?

Why your tax basis matters

Your first step in determining your gain is to identify the amount you realized from the sale. That’s the sales price minus any selling costs, such as real estate commissions. Then, figure your tax basis. That’s generally the price you paid for the home, plus certain closing costs and improvements. The higher the basis, the lower your potentially taxable profit.

Let’s say you realized $600,000 from your home sale. You originally bought it for  $200,000 and remodeled the kitchen for $50,000. You’d subtract that $250,000 from the $600,000 to get $350,000 in capital gains.

If you’re single, you could exclude $250,000 of the gain and pay tax on the remaining $100,000. (Long-term capital gains are normally taxed at 15% on the federal level,  although a big enough profit could push you into the higher 20% capital gains bracket. State tax rates vary.) If you’re married and can exclude up to $500,000 of gain, you wouldn’t owe any tax.

Your tax basis might be lower than the purchase price, however, if you previously deferred gain on a home sale, says CPA Mary Kay Foss of Walnut Creek, California. Say you sold a house before 1997 and rolled a $175,000 profit into the new house — the one that cost you $200,000. The initial tax basis of your home would be just $25,000. Now, if you realize $600,000 from the sale, your capital gain would be $525,000, even with the $50,000 kitchen remodel.

Other factors could increase your tax basis and lower your potentially taxable gains. If you owned a home with a spouse who died, for example, at least half of the house’s basis would be “stepped up,” or increased to its market value at the time your partner died. If you live in a community property state such as California, both halves of the home get this step up in tax basis.

Also read:My wife and I need to sell our ‘starter home’ of 40 years because we can’t handle stairs. When is a good time to buy a new one?

How to reduce your gains

Another way to beef up your basis: home improvements. To qualify, the improvements must “add to the value of your home, prolong its useful life, or adapt it to new uses,” according to IRS Publication 523, Selling Your Home.

Room additions, updated kitchens and new plumbing count; repairs or maintenance, such as painting, typically don’t. You also can’t count improvements that were later torn out or replaced.

Don’t miss: How about genuine reform of capital-gains tax rates?

Home sellers should carefully review Publication 523 to understand which costs can reduce their gains, and keep documentation — such as receipts — in case they’re audited, says Susan Allen, senior manager for tax practice and ethics for the American Institute of CPAs.

“Be proactive with your record maintenance because we all know if you go back 10 years later and look for something, it’s a lot harder to find,” Allen says.

More From NerdWallet

Liz Weston, CFP® writes for NerdWallet. Email: lweston@nerdwallet.com. Twitter: @lizweston

Source: finance.yahoo.com