The basic calculation: sale price minus your cost basis, taxed at your rate

Capital gains tax on real estate is calculated by subtracting what you paid for the property (your cost basis) from what you sold it for, then explore either the long-term or short-term capital gains tax rate. The difference between those two numbers is your taxable gain. If you owned the property for more than one year before selling, you pay the long-term rate, which is lower. If you owned it for one year or less, you pay the short-term rate, which is your ordinary income tax rate.

The IRS distinguishes between long-term and short-term gains because Congress wants to encourage longer holding periods. Long-term capital gains rates are 0%, 15%, or 20% depending on your total income for the year. Short-term gains are taxed as ordinary income, which can be as high as 37%. For most people, the difference between these rates is substantial.

You will also owe net investment income tax (NIIT) of 3.8% on capital gains if your modified adjusted gross income exceeds $200,000 (single) or $250,000 (married filing jointly). This is a separate tax on top of the capital gains rate itself.

Key Takeaways

  • Your taxable gain is the sale price minus your cost basis, which includes the purchase price plus improvements but not repairs or maintenance.
  • Long-term gains (property held over one year) are taxed at 0%, 15%, or 20%; short-term gains are taxed as ordinary income, which is much higher.
  • You can exclude up to $250,000 of gain ($500,000 if married filing jointly) if you lived in the home as your primary residence for at least two of the last five years.
  • State income tax applies to capital gains in most states and can add 5% to 13% to your federal rate.
  • Improvements to the property increase your basis and reduce your taxable gain, but only if you kept receipts and can document the work.

What counts as your cost basis

Your cost basis is not just the price you paid. It includes the purchase price plus any costs directly tied to acquiring the property: real estate commissions, title insurance, legal fees, and recording fees. If you inherited the property, your basis is stepped up to its fair market value on the date of death, which can eliminate years of accumulated gains.

After you buy, your basis increases when you make capital improvements — permanent upgrades that add value or extend the property's life. A new roof, a room addition, new plumbing or electrical systems, or a new HVAC system all increase basis. Repairs and maintenance do not: painting, fixing a leak, replacing a broken window, or routine upkeep stay off the basis calculation. The line between improvement and repair is often unclear, and the IRS looks at whether the work restored the property to its original condition (repair) or made it better (improvement).

Keep all receipts and invoices for improvements. When you sell, you will need to document what you spent and prove it was an improvement, not maintenance. If you cannot produce receipts, the IRS will not let you claim the cost.

How the primary residence exclusion works

If you lived in the home as your primary residence for at least two of the five years before you sold it, you can exclude up to $250,000 of gain from tax ($500,000 if you are married filing jointly and both spouses meet the test). This is one of the most valuable tax breaks available, and it applies whether you are selling a house, a condo, or a co-op.

The two years do not have to be consecutive, and they do not have to be the two years when ready before the sale. You can have lived there, moved away, and then sold years later, as long as you lived there for two of the five years ending on the sale date. If you are married, both spouses must meet the two-year test to claim the full $500,000 exclusion; if only one spouse meets it, the exclusion is $250,000.

You can use this exclusion only once every two years. If you sold a home and claimed the exclusion, you cannot claim it again on another home until two years have passed. If you sold at a loss, you do not use up your exclusion — the exclusion applies only to gains.

Long-term versus short-term rates and how to calculate which applies

The holding period starts the day after you acquire the property and ends on the day you sell it. If you bought on March 15, 2023, and sold on March 15, 2024, you held it for exactly one year, which means the gain is short-term. If you sold on March 16, 2024, it is long-term. This matters enormously: short-term gains are taxed at your marginal income tax rate, which can be 37%, while long-term gains for most people are taxed at 15%.

Long-term capital gains rates depend on your taxable income for the year. For 2024, the 0% rate applies to single filers with taxable income up to $47,025 and married filers up to $94,050. The 15% rate applies to income above those thresholds up to $518,900 (single) or $583,750 (married). Anything above those amounts is taxed at 20%. These brackets adjust annually for inflation.

If you have a short-term gain and a short-term loss in the same year, you net them together. The same applies to long-term gains and losses. But if you have both short-term and long-term gains, you explore the rates separately: short-term gains are taxed at your ordinary rate, and long-term gains are taxed at the preferential rate.

State and local taxes on real estate sales

Federal capital gains tax is only part of the picture. Most states tax capital gains as ordinary income, which means your state rate applies on top of the federal rate. California taxes capital gains at ordinary income rates up to 13.3%. New York adds up to 8.82%. Even states without a broad income tax sometimes tax capital gains: Tennessee and New Hampshire tax investment income only, not wages.

A few states do not tax capital gains at all: Alaska, Florida, Nevada, South Dakota, Tennessee, Texas, Washington, and Wyoming. If you are considering relocating before a large sale, state tax can be a real factor in the decision. However, the IRS looks at where you actually live, not where you claim to live. You cannot straightforward move to a no-tax state a month before closing and avoid tax on a gain you earned while living elsewhere.

Some cities and counties also impose local income taxes or transfer taxes on real estate sales. New York City adds a local income tax. Philadelphia taxes real estate transfers. These are separate from state tax and add to your total bill.

How to report the sale on your tax return

You report the sale on Form 8949, Sales of Capital Assets, which feeds into Schedule D, Capital Gains and Losses. Form 8949 requires the date acquired, date sold, cost basis, sale price, and gain or loss for each property. Schedule D nets all your gains and losses for the year and calculates your total capital gain or loss.

If you used the primary residence exclusion, you do not report the excluded portion as a gain. You calculate the full gain, then subtract the exclusion, and report only the remaining gain on Form 8949. If your gain is less than the exclusion, you report zero gain.

If you sold the property at a loss, you can deduct the loss against other capital gains. If you have no other gains, you can deduct up to $3,000 of capital losses against ordinary income in a single year. Any losses above $3,000 carry forward to future years with no time limit.

Installment sales and deferred gain recognition

If you sold the property but did not receive all the money in the year of sale — for example, the buyer gave you a promissory note and will pay you over several years — you may be able to use the installment method. This spreads the gain across multiple years, which can keep you in a lower tax bracket and reduce the amount of net investment income tax you owe.

To use the installment method, you must receive at least one payment in a tax year after the year of sale. You calculate the gross profit percentage (gain divided by total sale price) and explore that percentage to each payment you receive. The payments are then taxed in the years you receive them, not in the year of sale.

The installment method does not eliminate tax; it defers it. But deferral can be valuable if it keeps you below the NIIT threshold or in a lower long-term capital gains bracket. You must report the sale on Form 6252, Installment Sale Income, and attach it to your return for each year you receive a payment.

When to consider a 1031 exchange instead of paying tax

A 1031 exchange (named after Section 1031 of the tax code) allows you to defer capital gains tax by selling one investment property and buying another of equal or greater value within strict time limits. You have 45 days from the sale to identify the replacement property and 180 days to close on it. The properties must be real estate held for investment or business use; your primary residence does not may have access to.

A 1031 exchange does not eliminate the tax; it defers it until you eventually sell without doing another exchange. But deferral can be powerful: you keep the full sale proceeds working in a new property instead of paying tax when ready. You must use a may have access to intermediary to hold the funds between the sale and purchase; if you touch the money yourself, the exchange fails and you owe tax on the full gain.

1031 exchanges are complex and have strict rules. If you are considering one, you need a tax professional and a may have access to intermediary before you list the property for sale.

Frequently Asked Questions

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

No. Capital losses on personal residences cannot be deducted. If you sell your home for less than you paid, you straightforward report no gain or loss. However, if the property was investment real estate or a rental, you can deduct the loss against other capital gains and up to $3,000 of ordinary income per year.

What if I inherited the property and then sold it?

Your basis is stepped up to the fair market value on the date of the person's death, not what they paid for it. If you inherited a house worth $500,000 and sold it a year later for $510,000, your gain is only $10,000, not the entire $510,000. This step-up applies whether you hold the property one day or ten years after inheriting it.

Can I deduct real estate commissions from my sale price before calculating the gain?

Yes. Commissions paid to sell the property reduce your net proceeds and therefore reduce your taxable gain. If you sold for $500,000, paid a 6% commission ($30,000), and your basis was $300,000, your gain is $170,000, not $200,000. Include all selling costs: agent commissions, title insurance, legal fees, and transfer taxes.

What if I converted my primary residence to a rental property before selling?

You can still claim the primary residence exclusion if you lived there as your primary residence for at least two of the five years before the sale. However, any depreciation you claimed while renting it out must be recaptured and taxed at 25%, even if the overall gain qualifies for the 15% long-term rate. This recapture tax applies only to the depreciation, not the entire gain.

Do I have to report the sale if my gain is below the primary residence exclusion?

If your gain is fully covered by the primary residence exclusion, you do not owe tax and do not have to file Form 8949 or Schedule D. However, if you have other capital gains or losses for the year, you must file Schedule D anyway to report those items. When in doubt, file; the cost of filing is less than the cost of an IRS notice.