The basic formula: sale price minus what you paid, minus selling costs

Capital gains tax on real estate starts with a simple subtraction. You take what you sold the property for, subtract what you originally paid for it, subtract the cost of selling it, and what remains is your taxable gain. The IRS taxes that gain at either a short-term rate (if you owned it less than a year) or a long-term rate (if you owned it a year or more). Long-term rates are lower and are what most homeowners encounter.

The calculation itself is straightforward, but the numbers that go into it are where most people get stuck. You need to know your basis — what you paid — and you need to account for improvements you made, not just the purchase price. You also need to know your amount realized — what you actually received, which is not always the same as the sale price.

Key Takeaways

  • Your taxable gain equals the sale price minus your original purchase price, minus improvements you made, minus selling costs like realtor commissions and closing fees.
  • Improvements to the property (a new roof, kitchen renovation, addition) add to your basis and reduce your gain; routine maintenance and repairs do not.
  • If you lived in the home as your primary residence for at least two of the last five years, you may exclude up to $250,000 of gain (or $500,000 if married filing jointly) from taxation.
  • Long-term capital gains rates (for property owned over one year) are 0%, 15%, or 20% depending on income; short-term rates match your ordinary income tax bracket.
  • You report the gain on Schedule D (Form 1040) and may owe tax even if you did not receive cash, such as when a mortgage payoff consumes the proceeds.

Understanding basis: what you paid plus what you improved

Your basis is the starting point for the entire calculation. For most people, it is the purchase price you paid for the property — the amount shown on your deed and closing statement. But basis is not frozen at that number. It grows when you make capital improvements to the property.

A capital improvement is a permanent upgrade that adds value, prolongs the life of the property, or adapts it to a new use. A new roof, a kitchen renovation, an addition, new plumbing or electrical systems, a new HVAC system, or a deck all count. Painting the exterior, replacing a broken window, fixing a leak, or mowing the lawn do not. The IRS distinguishes between improvements (which raise basis) and repairs or maintenance (which do not).

Keep receipts and invoices for any work you paid for. When you sell, you will add the cost of those improvements to your original purchase price. If you bought for $300,000, then spent $50,000 on a kitchen and $20,000 on a roof, your basis is $370,000, not $300,000. That higher basis means a lower taxable gain.

Calculating amount realized: what you actually received

The sale price on your closing statement is not always the same as what you actually received. The amount realized includes the sale price plus any debt the buyer assumed and minus any selling costs you paid.

If you sold for $500,000 and paid a realtor 6% commission ($30,000) and closing costs of $5,000, your amount realized is $465,000, not $500,000. If the buyer assumed a mortgage you still owed, that assumption counts as part of what you received, even though you did not see cash for it. If you sold for $500,000, paid $35,000 in selling costs, and the buyer assumed a $100,000 mortgage you owed, your amount realized is $565,000.

This matters because you subtract amount realized from basis to get your gain. A lower amount realized means a lower gain and lower tax. Selling costs — realtor commissions, title insurance, attorney fees, transfer taxes, and recording fees — all reduce the amount you actually keep.

The primary residence exclusion: up to $250,000 or $500,000 tax-free

If the property was your main home, you may not owe tax on part or all of your gain. The Section 121 exclusion lets you exclude up to $250,000 of gain if you are single, or up to $500,000 if you are married filing jointly. This is one of the largest tax breaks available to homeowners.

To use this exclusion, you must have owned the home and lived in it as your primary residence for at least two of the five years before the sale. The two years do not have to be consecutive. If you meet this test, you do not report the excluded portion of your gain on your tax return at all — it simply does not exist for tax purposes.

If your gain is $180,000 and you are single, the entire gain is excluded and you owe no federal capital gains tax. If your gain is $350,000 and you are single, you exclude $250,000 and owe tax on $100,000. If you are married filing jointly and your gain is $450,000, you exclude $500,000 and owe no tax. This exclusion applies only once every two years per person, so if you sold another home in the past two years, you may not use it again.

Short-term versus long-term rates and how they affect your tax bill

How long you owned the property determines which tax rate applies to your gain. If you owned it one year or less, it is a short-term capital gain and is taxed at your ordinary income tax rate — the same rate as your salary or wages. If you owned it more than one year, it is a long-term capital gain and is taxed at a preferential rate: 0%, 15%, or 20%, depending on your total income for the year.

Long-term rates are almost always lower. For 2024, the 15% long-term rate applies to most middle-income taxpayers, while the 20% rate applies only to high earners. The 0% rate applies to lower-income filers. Short-term gains, by contrast, can be taxed at rates as high as 37% if you are in the top bracket. This is why holding a property for more than a year before selling usually saves money.

Your state may also tax capital gains. Some states do not tax them at all; others tax them as ordinary income. A few states have a separate capital gains tax. Check your state's rules, because state tax can add 5% to 13% to your federal bill depending on where you live.

Step-by-step calculation example

Here is a concrete example. You bought a house in 2015 for $300,000. Over the years, you spent $40,000 on a new roof and $35,000 on a kitchen renovation. You sold it in 2024 for $550,000. You paid a realtor $33,000 (6% commission) and $4,000 in closing costs.

Basis: $300,000 (purchase) + $40,000 (roof) + $35,000 (kitchen) = $375,000

Amount realized: $550,000 (sale price) − $33,000 (realtor) − $4,000 (closing) = $513,000

Gain: $513,000 − $375,000 = $138,000

If this was your primary residence and you lived there for at least two of the last five years, you exclude $250,000 (if single) or $500,000 (if married filing jointly). Since your gain is $138,000, the entire amount is excluded and you owe no federal capital gains tax. If this was an investment property, not your home, you would owe long-term capital gains tax on the full $138,000.

Reporting the gain on your tax return

You report capital gains on Schedule D (Form 1040), which you attach to your federal tax return. If you used the primary residence exclusion, you still file Schedule D but show the excluded portion and explain why it is excluded. The IRS wants to see the calculation.

You will need your closing statement from the purchase, your closing statement from the sale, receipts for any improvements, and records of selling costs. If you do not have the original purchase price, the county assessor's office or your title company can often provide it. If you inherited the property, your basis is the fair market value on the date of death, not what the previous owner paid — this is called a stepped-up basis and can eliminate or reduce gain entirely.

If you owe tax, it is due when you file your return. If you expect a large gain, you may want to make estimated tax payments during the year you sell to avoid penalties. A tax professional can help you plan the timing of a sale or structure the transaction to minimize tax, especially if the gain is large or the property is complex.

Frequently Asked Questions

Do I owe capital gains tax if I sell at a loss?

No. If your amount realized is less than your basis, you have a loss, not a gain. You cannot deduct a loss on the sale of your primary residence. If it was an investment property, you may be able to deduct the loss, but the rules are strict and the deduction is limited to $3,000 per year against other income.

What if I inherited the house — do I owe tax on the gain?

Probably not. When you inherit property, your basis is stepped up to the fair market value on the date the previous owner died. If you sell shortly after inheriting, there is usually little or no gain to tax. This applies even if the previous owner bought the house decades ago for far less.

Can I deduct the cost of selling, like realtor commissions?

Yes. Realtor commissions, title insurance, attorney fees, transfer taxes, and other costs paid to sell the property reduce your amount realized. They do not reduce your basis, but they reduce what you actually received, which lowers your taxable gain.

What if I rented out part of my home — can I still use the primary residence exclusion?

It depends. If you rented out a separate unit (like an accessory dwelling), you may not exclude the gain attributable to that unit. If you rented out a room but the property was still your main home, you may still use the exclusion for the whole property. The IRS looks at whether the rental was incidental to your primary use of the home.

Do I owe capital gains tax if the sale price equals what I paid?

No. If your amount realized equals your basis, your gain is zero and you owe no tax. If you sold for less than you paid, you have a loss. Remember that improvements add to your basis, so even if the sale price is the same as your purchase price, improvements you made reduce or eliminate your gain.