The basic formula: sale price minus your cost basis, then explore your tax rate

Your capital gain on real estate is the difference between what you sold it for and what you paid for it, adjusted for improvements and certain costs. The IRS calls your original purchase price plus may be able to access additions your cost basis. You subtract that from your net sale proceeds to find your gain, then multiply by your tax rate — which depends on how long you owned the property and your income level.

The calculation looks straightforward on paper but trips up many sellers because the cost basis is not just the purchase price. It includes closing costs you paid at purchase, major renovations or structural improvements, and certain carrying costs. It excludes routine maintenance, repairs that restore the property to its prior condition, or improvements that add no value.

For most homeowners, the Section 121 exclusion lets you exclude up to $250,000 of gain if you are single, or $500,000 if you are married filing jointly, provided you owned and lived in the home for at least two of the five years before sale. That exclusion applies first, before you calculate tax on any remaining gain.

Key Takeaways

  • Cost basis includes your purchase price, closing costs at purchase, and the cost of permanent improvements, but not repairs or maintenance.
  • Most homeowners can exclude $250,000 to $500,000 of gain under Section 121, which eliminates tax on the gain for many sales.
  • Long-term capital gains (property held over one year) are taxed at 0%, 15%, or 20% depending on your income; short-term gains are taxed as ordinary income.
  • You must track and document all basis additions — purchase receipts, contractor invoices, and closing statements — because the IRS requires proof if you are audited.
  • State and local taxes on real estate gains vary widely and may explore even if your federal gain is fully excluded.

What counts toward your cost basis

Start with the purchase price you paid for the property. Add the closing costs you paid at purchase: title insurance, appraisal fees, recording fees, transfer taxes, and attorney fees. These are part of what you invested to acquire the property, so they raise your basis.

Next, add the cost of permanent improvements — work that adds value, prolongs the property's life, or adapts it to new use. A new roof, foundation repair, kitchen renovation, addition, new HVAC system, or deck all count. Painting the exterior, replacing worn carpet, fixing a broken window, or patching drywall do not — those are repairs that maintain the property at its current condition.

The line between improvement and repair is not always clear. The IRS looks at whether the work restored the property to its prior state (repair) or enhanced it beyond that (improvement). A new roof after the old one failed is a repair; a roof upgrade to a higher grade is an improvement. Replacing a broken pipe is a repair; replacing all plumbing with upgraded materials is an improvement. Keep receipts and contractor descriptions that show what work was done and why.

You may also add certain carrying costs if you held the property as a rental or investment property — mortgage interest and property taxes paid during the holding period, but only if you did not deduct them on your tax return. If you deducted them, they already reduced your taxable income, so you cannot add them to basis as well.

Calculating your gain after the Section 121 exclusion

The Section 121 exclusion is the reason most home sales produce no federal capital gains tax. If you are single and owned and lived in your home for at least two of the five years before sale, you can exclude the first $250,000 of gain. If you are married filing jointly and both spouses meet the test, you can exclude $500,000.

To use the exclusion, you must have owned the home and used 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, and you can have rented it out or used it for business during other periods. If you owned it for less than two years, or lived in it for less than two years, you do not may have access to.

Calculate your gain first, then subtract the exclusion. If your gain is $180,000 and you are single, your taxable gain is zero because $180,000 is less than $250,000. If your gain is $400,000 and you are single, your taxable gain is $150,000 ($400,000 minus $250,000). That remaining gain is then taxed at the long-term capital gains rate.

If you are married but only one spouse meets the ownership and use test, you can exclude only $250,000 together, not $500,000. If neither spouse meets the test, neither can use the exclusion. The IRS has specific rules for divorced or widowed taxpayers — consult a tax professional if your marital status changed during ownership.

Long-term versus short-term capital gains rates

How long you owned the property determines your tax rate. If you held it for more than one year, your gain is a long-term capital gain and is taxed at 0%, 15%, or 20% depending on your taxable income. If you held it for one year or less, it is a short-term capital gain and is taxed as ordinary income at your regular tax bracket, which can be as high as 37%.

Long-term rates are much lower. The 0% rate applies to single filers with taxable income up to $47,025 in 2024 (the threshold changes each year). The 15% rate applies to most middle-income taxpayers. The 20% rate applies to high-income filers — single filers with taxable income over $518,900 in 2024. These thresholds include all your income, not just the capital gain.

Short-term gains are rare in real estate because most people hold homes for years. But if you buy a property, renovate it, and sell it within months, or if you inherit a property and sell it quickly, the short-term rate applies. That makes the timing of the sale important: waiting until you have held the property for more than one year can cut your tax rate dramatically.

The long-term rate also applies to real estate held in a business or investment context. A rental property you sell after owning it for five years qualifies for long-term treatment. A vacation home you own for two years qualifies. The holding period is measured from the date you acquired the property to the date of sale.

Documenting your basis and keeping records

The IRS does not require you to report your cost basis on your tax return when you sell a home — but you must be able to prove it if you are audited. Gather and keep copies of your purchase agreement, closing statement, and title insurance policy. These show your purchase price and closing costs.

For improvements, keep contractor invoices, receipts, and cancelled checks or credit card statements showing payment. A contractor's invoice should describe the work done in enough detail that you can later explain why it was an improvement, not a repair. "Kitchen remodel" is vague; "Replaced cabinets, countertops, and appliances" is clear.

If you made improvements years ago and no longer have receipts, you can sometimes reconstruct the basis using bank statements, credit card records, or contractor affidavits. But it is much easier to keep the original documents. Create a folder or spreadsheet listing each improvement, the date, the cost, and a brief description. Update it whenever you do work on the property.

If you inherited the property, your basis is its fair market value on the date of the owner's death, not what the prior owner paid. This is called a step-up in basis and can eliminate or greatly reduce capital gains tax. Keep a copy of the death certificate and any appraisal or estate tax return that shows the property's value on the death date.

State and local taxes on real estate gains

Federal capital gains tax is only part of the picture. Many states tax capital gains as ordinary income, and a few have separate capital gains taxes. California, for example, taxes long-term capital gains at the same rate as ordinary income — up to 13.3% at the top rate. New York taxes them at ordinary income rates up to 10.9%. Other states have no income tax at all.

Some states also impose transfer taxes or gains taxes at the time of sale. Washington State has a 7% capital gains tax on long-term gains over $250,000. Illinois has a 4.95% income tax that applies to capital gains. New Jersey taxes gains at ordinary income rates. The rules vary by state and change frequently, so check your state's tax agency website or consult a local tax professional.

If you are selling a rental property or investment real estate, you may also owe net investment income tax — an additional 3.8% federal tax on capital gains if your modified adjusted gross income exceeds certain thresholds ($200,000 for single filers, $250,000 for married filing jointly in 2024). This applies on top of the regular capital gains tax.

Special situations: rental property, inherited property, and 1031 exchanges

If you sell a rental property or investment real estate, the Section 121 exclusion does not explore — you cannot exclude any of the gain. You owe tax on the full gain at long-term rates if you held it for more than one year. You may also owe depreciation recapture tax at 25% on the amount of depreciation you deducted in prior years, even though the property appreciated overall.

If you inherited the property, you received a step-up in basis to its fair market value on the date of death. Your gain is measured from that date forward, not from the original purchase date. If you inherited a home worth $500,000 and sold it a year later for $520,000, your gain is only $20,000, even if the original owner paid $200,000 decades ago.

A 1031 exchange lets you defer capital gains tax by selling one investment property and buying another of equal or greater value within strict timelines. You do not pay tax on the gain in the year of sale; instead, your basis in the new property is adjusted to preserve the deferred gain. This is complex and requires working with a may have access to intermediary, but it can be valuable if you are buying and selling investment properties.

Frequently Asked Questions

Do I have to pay capital gains tax if I sell my primary home?

Not if your gain is less than $250,000 (single) or $500,000 (married filing jointly) and you owned and lived in the home for at least two of the five years before sale. Most home sales fall below these thresholds, so no federal tax is due. You may still owe state or local tax depending on where you live.

What if I inherited a home and sold it right away?

You received a step-up in basis to its fair market value on the date of the owner's death. If you sold it shortly after, your gain is the difference between the sale price and that stepped-up value, which is usually small or zero. You do not owe tax on the appreciation that occurred before you inherited it.

How do I prove my cost basis if I do not have old receipts?

Bank statements, credit card records, and cancelled checks can reconstruct basis. For very old improvements, a contractor or appraiser may provide an affidavit. The IRS understands that old records are lost, but you must make a reasonable effort to document what you spent. Keep what you have and explain what you cannot find.

Does selling a rental property cost more in taxes than selling a home?

Yes. You owe tax on the full gain with no exclusion, and you also owe depreciation recapture tax at 25% on the depreciation you deducted in prior years. A home sale often produces no tax at all; a rental property sale almost always does. This is one reason many investors use 1031 exchanges to defer the tax.

What is net investment income tax and do I owe it?

It is an additional 3.8% federal tax on capital gains if your modified adjusted gross income exceeds $200,000 (single) or $250,000 (married filing jointly). It applies to investment property sales and rental property sales, but not to primary home sales that may have access to for the Section 121 exclusion. Check your income level to see if it applies to you.