The Basic Formula for Capital Gains on Real Estate

Capital gains tax on real estate is calculated by subtracting what you paid for the property from what you sold it for. That difference is your gain. You pay tax on that gain, not on the full sale price. The formula is straightforward: Sale Price minus Adjusted Basis equals Capital Gain.

Your adjusted basis is not simply what you paid. It includes the original purchase price plus the cost of permanent improvements you made — a new roof, an addition, a foundation repair. It does not include maintenance or repairs that kept the property in its current condition, like painting or fixing a leak. The IRS distinguishes between improvements that add value and upkeep that preserves it.

Once you know your gain, the tax rate depends on how long you owned the property. If you owned it for more than one year, you pay the long-term capital gains rate, which is lower than ordinary income tax rates. If you owned it for one year or less, you pay the short-term rate, which is taxed as ordinary income and depends on your tax bracket.

Key Takeaways

  • Your capital gain is the sale price minus your adjusted basis, which includes the purchase price plus permanent improvements you paid for.
  • Long-term capital gains rates (for property owned over one year) are 0%, 15%, or 20% depending on your income; short-term rates are your ordinary income tax bracket.
  • You must track and document every improvement you made, because the IRS requires proof if you are audited.
  • 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 (or $500,000 if married filing jointly) of the gain from tax.
  • State and local taxes on capital gains vary widely and are calculated separately from federal tax.

What Counts as Basis and What Does Not

Your basis starts with what you actually paid for the property — the purchase price on the deed. If you bought the house for $300,000, that is your starting basis. But basis also includes closing costs that are capitalized: title insurance, recording fees, survey costs, and transfer taxes paid at purchase. These are one-time costs that become part of what you have invested in the property.

After purchase, any money you spend on the property may or may not add to basis. A new roof adds to basis. A kitchen remodel adds to basis. A new HVAC system adds to basis. These are permanent improvements that extend the life or value of the property. But replacing a broken window does not add to basis — that is repair. Painting the exterior does not add to basis — that is maintenance. The line is whether the work added something new or simply kept what you had from falling apart.

Depreciation also affects basis if you owned the property as a rental or business property. Each year you claimed depreciation deductions, your basis went down. When you sell, you must recapture that depreciation and pay tax on it at a rate of 25%, separate from the capital gains calculation. If you owned a rental house and claimed $50,000 in depreciation over ten years, your basis is $50,000 lower, and you owe 25% tax on that $50,000 when you sell.

Long-Term Versus Short-Term Capital Gains Rates

The tax rate on your gain depends on how long you held the property before selling. Long-term capital gains apply if you owned the property for more than one year. The rate is 0%, 15%, or 20% depending on your total taxable income for the year. These rates are much lower than ordinary income tax rates, which can reach 37% at the highest bracket.

Short-term capital gains apply if you owned the property for one year or less. These are taxed as ordinary income at your marginal tax rate — the rate that applies to your highest income dollars. If you are in the 24% tax bracket, short-term gains are taxed at 24%. If you are in the 35% bracket, they are taxed at 35%. This is why holding a property for just over one year can save you thousands in tax.

The holding period is measured from the date you took title (the closing date) to the date you sold it. If you closed on March 15, 2022, and sold on March 16, 2023, you meet the one-year test and may have access to for long-term rates. If you sold on March 14, 2023, you do not, and the entire gain is taxed as short-term.

The Primary Residence Exclusion

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 a portion of the gain from tax. This is the Section 121 exclusion. Single filers can exclude up to $250,000 of gain. Married couples filing jointly can exclude up to $500,000.

The two years do not have to be consecutive, and they do not have to be the two years immediately before the sale. You can have lived there, moved away, and sold it years later — as long as you lived there for two of the last five years, the exclusion applies. If you owned the home for 20 years but lived there for only the first two years, you still get the full exclusion.

You can use this exclusion only once every two years. If you sold a home and used the exclusion in 2021, you cannot use it again until 2023. If you are married and file jointly, both spouses must meet the ownership and use tests to claim the full $500,000 exclusion. If only one spouse meets the test, the exclusion is $250,000.

Depreciation Recapture for Rental and Business Properties

If you owned the property as a rental or business property and claimed depreciation deductions on your tax returns, you must recapture that depreciation when you sell. Depreciation recapture is taxed at 25%, separate from the capital gains calculation. This applies even if your long-term capital gains rate is only 15%.

The recapture amount is the total depreciation you deducted over the years you owned the property. If you owned a rental house for ten years and deducted $40,000 in depreciation, you owe 25% tax on that $40,000 — $10,000 — when you sell, regardless of whether the property actually appreciated or depreciated in value. This is a mandatory tax, not optional.

Your basis is reduced by the depreciation you claimed, so the capital gain itself is larger. If you bought a rental for $200,000, claimed $40,000 in depreciation, and sold for $250,000, your adjusted basis is $160,000 ($200,000 minus $40,000). Your capital gain is $90,000 ($250,000 minus $160,000). You pay 25% tax on the $40,000 of recapture and long-term capital gains tax on the remaining $50,000 of gain.

State and Local Capital Gains Taxes

Federal capital gains tax is only part of the picture. Most states also tax capital gains, and the rates and rules vary widely. Some states tax capital gains as ordinary income. Some have separate capital gains rates. Some states do not tax capital gains at all. You must calculate your state tax separately and add it to your federal tax bill.

A few states have recently enacted new capital gains taxes that apply only to high-income earners. Washington State, for example, taxes long-term capital gains at 7% on gains over $250,000 per year. New York has a 8.82% tax on gains over $1 million. These are in addition to federal tax and any ordinary state income tax. If you sold a property in one of these states, you need to know the specific rules for that year.

Some states also allow the primary residence exclusion, but the amount may differ from the federal exclusion. A few states have no exclusion at all. You cannot assume your state follows federal rules. If you sold a home in a state other than where you currently live, the state where the property was located taxes the gain, not your current state of residence.

How to Document and Report Your Calculation

When you sell real estate, you report the transaction on Form 8949 (Sales of Capital Assets) and Schedule D (Capital Gains and Losses). Form 8949 is where you list the property, the date acquired, the date sold, the basis, the sale price, and the gain or loss. Schedule D summarizes your gains and losses and tells you which rate applies.

You must keep records of your purchase price, closing statement, and every receipt or invoice for improvements you made. The IRS does not require you to attach these documents to your return, but you must have them if you are audited. Photographs of major work, contractor invoices, and permit records all help prove that a cost was an improvement, not a repair.

If you used the primary residence exclusion, you do not need to file a separate form, but you must be able to show that you lived in the home for two of the last five years. Keep records of your address on driver's licenses, utility bills, or lease agreements during the years you owned it. If you are audited and cannot prove you lived there, you lose the exclusion and owe tax on the full gain.

Frequently Asked Questions

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

No. If you sold for less than your adjusted basis, you have a capital loss, not a gain. You cannot deduct a loss on the sale of your primary residence. If the property was a rental or investment property, you can deduct the loss against other capital gains, and up to $3,000 of losses can offset ordinary income in a single year. Unused losses carry forward to future years.

What if I inherited the property — does my basis change?

Yes. When you inherit real estate, your basis is "stepped up" to the fair market value of the property on the date of the person's death, not what they paid for it. If your parent bought a house for $100,000 and it was worth $400,000 when they died, your basis is $400,000. If you sell it a year later for $410,000, your gain is only $10,000, not $310,000. This step-up applies to most inherited property.

Can I deduct the cost of selling — realtor commission, title insurance, closing costs?

Yes, but only as a reduction to your sale price, not as a separate deduction. If you paid a 6% realtor commission and $2,000 in closing costs, those amounts reduce your net proceeds. Your capital gain is calculated on the net amount you received, not the gross sale price. Keep all closing documents from the sale to prove these costs.

What if I owned the property with someone else — how do we split the tax?

Each owner reports their share of the gain based on their ownership percentage. If you owned the property 50-50 with a co-owner, you each report 50% of the total gain on your individual returns. If you are married and file jointly, you report the full gain on one joint return. If you are unmarried co-owners, you each file separately and report your share.

Do I have to pay estimated tax on the gain before I sell?

Not before the sale, but you may owe estimated tax for the year you sell if the gain is large enough. If you expect to owe more than $1,000 in tax for the year, the IRS may require you to make quarterly estimated tax payments. Your tax preparer can calculate whether you need to make these payments and when they are due.