Real Estate & Property Investment Property Tax, Depreciation & Exchanges IRC §121 exclusion; IRS Publication 523

Capital Gains Tax on Home Sale Calculator

Gain on a home sale is not the price minus what you paid — it is the net proceeds minus your adjusted basis, which includes buying costs and every capital improvement you made and is reduced by any depreciation you claimed. This calculator builds that basis, computes the gain, applies the Section 121 exclusion of $250,000 for a single filer or $500,000 for a married couple filing jointly, and estimates what remains after the long-term capital gains rate, the 3.8% net investment income tax, unrecaptured Section 1250 depreciation, and your state's rate.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Original purchase priceWhat you paid for the property when you acquired it, from your original settlement statement.300000 $
Buying costs added to basisTitle, legal, survey, transfer tax and recording paid at purchase. Loan points and prepaid escrow do not count.4000 $
Capital improvementsAdditions and upgrades that add value or extend life — a new roof, an addition, a kitchen. Repairs and maintenance do not count.60000 $
Depreciation claimedDepreciation allowed or allowable on any rental or home-office use since 6 May 1997. It reduces basis and is taxed separately.0 $
Sale priceThe contract price on the sale.700000 $
Selling costsCommission, transfer tax, title, legal and settlement fees — they reduce the amount realized.45000 $
Filing statusSets the exclusion cap: $250,000 or $500,000.Single or married filing separately
Years ownedTotal years you held title. The exclusion requires at least two years of ownership within the five years before the sale.12 yr
Years lived in it as your main homeYears of use as your principal residence within the five years before the sale; two years is the threshold.12 yr
Long-term capital gains rateThe federal bracket your taxable income places you in for long-term gains.15%
Net investment income tax appliesTick if your modified adjusted gross income exceeds the statutory threshold for your filing status; adds 3.8%.No
State tax rate on the gainYour state's rate on capital gains. Several states levy none; some tax gains as ordinary income.5 %

It returns

  • Estimated tax on the sale — Federal capital gains, depreciation recapture, NIIT and state tax combined.
  • Adjusted cost basis
  • Amount realized — Sale price less selling costs.
  • Total realized gain
  • Section 121 exclusion applied
  • Unrecaptured Section 1250 gain — The part of the gain attributable to depreciation. The exclusion never covers it.
  • Taxable capital gain
  • Proceeds after tax — Amount realized less the estimated tax. Any mortgage payoff comes out of this separately.

The formula

G=(Sc)(B+k+ID)
T=Gtr+G12500.25+(Gt+G1250)s

In plain text: Gain = (sale price − selling costs) − (purchase + buying costs + improvements − depreciation); Taxable = Gain − recapture − Section 121 exclusion

  • GRealized gain on the sale ($)
  • SSale price ($)
  • cSelling costs — commission, transfer tax, title, legal ($)
  • BOriginal purchase price ($)
  • kBuying costs capitalised into basis ($)
  • ICapital improvements over the holding period ($)
  • DDepreciation allowed or allowable since May 1997 ($)
  • ESection 121 exclusion: $250,000 single or $500,000 joint ($)

The exclusion applies to gain, not to proceeds, and it never shelters the portion of gain created by depreciation. That portion is unrecaptured Section 1250 gain, taxed at a maximum federal rate of 25%.

Updated Category Property Tax, Depreciation & Exchanges Verified against published test cases Reading time 11 min

Gain is not profit, and basis is not price

The single most common mistake in home-sale tax planning is computing gain as sale price minus purchase price. The actual calculation has four moving parts, and two of them are usually forgotten.

Amount realized is the sale price minus your selling costs — commission, transfer or excise tax, title and escrow fees, legal fees. These reduce what you are treated as having received, which is why a seller paying 7% of the price in costs is not taxed on that 7%.

Adjusted basis starts at what you paid, adds the buying costs you capitalised at purchase, adds every capital improvement over the whole holding period, and subtracts any depreciation you claimed. A homeowner who bought at $300,000, paid $4,000 of title and legal fees, and put in a $60,000 kitchen and roof over twelve years has a basis of $364,000, not $300,000.

Gain is the difference. On a $700,000 sale with $45,000 of costs, the amount realized is $655,000 and the gain is $291,000.

The exclusion then removes up to $250,000 of that gain for a single filer or $500,000 for a married couple filing jointly, provided the ownership and use tests are met. In the example, a single filer excludes $250,000 and is taxed on $41,000; a married couple filing jointly excludes the whole $291,000 and owes nothing.

Notice how much rides on basis. Every dollar of documented capital improvement is a dollar removed from the taxable gain, worth 15 or 20 cents of federal tax plus state. Receipts kept for twenty years pay for themselves at exactly this moment.

The Section 121 tests, and what breaks them

To claim the exclusion you must satisfy two tests, both measured over the five years ending on the date of sale.

Ownership. You must have owned the home for at least two years of that five-year window. Use. You must have lived in it as your principal residence for at least two years of that window. The two-year periods need not be continuous and need not coincide, which is what lets someone who rented the property out for part of the period still qualify.

A third rule limits frequency: the full exclusion is generally available only once in a two-year period. Selling two homes in eighteen months usually means the exclusion is available on one of them.

For a married couple filing jointly to claim the full $500,000, either spouse may satisfy the ownership test but both must satisfy the use test, and neither may have excluded gain on another sale within the preceding two years. A couple where only one spouse lived in the home is limited to $250,000.

Failing the tests does not always mean zero relief. A reduced exclusion is available where the sale is caused by a change in place of employment, by health, or by another unforeseeable circumstance the regulations recognise. It is prorated by the fraction of the two-year requirement actually satisfied, so a qualifying sale after twelve months gives half the cap. This calculator does not compute the reduced exclusion — if your situation might qualify, that is a conversation for your tax adviser.

Two more restrictions catch people with mixed-use history. Gain allocable to periods of non-qualified use after 2008 — time the property was not your principal residence — is generally not excludable, and is prorated by time. And depreciation claimed since 6 May 1997 is never excludable, whatever the tests say.

Worked example: a $700,000 sale by a single filer

You bought in 2014 for $300,000, paying $4,000 in title, legal and recording costs. Over twelve years you replaced the roof, added a bathroom and rebuilt the kitchen, spending $60,000 in total on work that qualifies as capital improvement. You never rented the property and never claimed a home-office deduction, so depreciation is zero. You sell for $700,000 with $45,000 of selling costs. You file as a single taxpayer in the 15% bracket, your income is below the net investment income tax threshold, and your state taxes capital gains at 5%.

  1. Adjusted basis. $300,000 + $4,000 + $60,000 − $0 = $364,000.
  2. Amount realized. $700,000 − $45,000 = $655,000.
  3. Realized gain. $655,000 − $364,000 = $291,000.
  4. Recapture. No depreciation was claimed, so $0.
  5. Exclusion. Both two-year tests are met and you file single, so the cap is $250,000. The exclusion is the lesser of $250,000 and $291,000 = $250,000.
  6. Taxable gain. $291,000 − $0 − $250,000 = $41,000.
  7. Federal tax. 15% × $41,000 = $6,150.
  8. State tax. 5% × $41,000 = $2,050.
  9. Total tax. $6,150 + $2,050 = $8,200.
  10. Proceeds after tax. $655,000 − $8,200 = $646,800.

Two counterfactuals show what the levers are worth. Married filing jointly, the cap is $500,000, the whole $291,000 is excluded, and the tax is zero. And had you not documented the $60,000 of improvements, the basis would be $304,000, the gain $351,000, the taxable gain $101,000, and the tax 20% × $101,000 = $20,200 — $12,000 more, purely for lack of receipts.

Reading the result and what to do about it

If the tax is zero, check why. The exclusion covering your whole gain is the normal outcome for an ordinary owner-occupied sale, and it is why most home sales generate no tax at all. If your gain is close to the cap, that is a signal to look harder at basis before you file.

If there is a taxable amount, attack the basis first. Improvements are the only input you can still change through documentation rather than through a transaction. Additions, a new roof, replacement windows, HVAC systems, a finished basement, landscaping that is permanent, and assessments for local improvements all count. Repairs, repainting and routine maintenance do not — but a repair done as part of a larger remodel can be included in the improvement.

Depreciation is the trap for former landlords. If you ever rented the home or claimed a home-office deduction, the depreciation allowed or allowable since May 1997 reduces your basis — whether or not you actually claimed it. It is then taxed as unrecaptured Section 1250 gain at up to 25%, and no amount of Section 121 exclusion shelters it. In the third test vector, a couple with a $250,000 gain and $80,000 of depreciation excludes $170,000 and still writes a $20,000 cheque.

The 3.8% net investment income tax applies to the taxable portion of the gain when your modified adjusted gross income exceeds the statutory threshold for your filing status. Excluded gain is not net investment income, so the exclusion protects you from NIIT as well — one more reason the exclusion is worth so much more than its face rate suggests.

State treatment varies enormously. Several states levy no income tax at all; several tax capital gains at ordinary income rates; and states differ in whether they conform to the federal exclusion. Check your own state rather than assuming conformity.

Tax at different sale prices for the worked example

Basis $364,000, selling costs $45,000, single filer, both two-year tests met, 15% federal plus 5% state on the taxable portion. Taxable gain = sale price − $409,000 − $250,000, floored at zero.
Sale priceRealized gainExclusion appliedTaxable gainTax at 20% combined
$600,000$191,000$191,000$0$0
$659,000$250,000$250,000$0$0
$700,000$291,000$250,000$41,000$8,200
$800,000$391,000$250,000$141,000$28,200
$900,000$491,000$250,000$241,000$48,200

Below $659,000 the exclusion covers the entire gain and the tax is zero. Above it, every extra dollar of price is taxed at the full combined rate — 20 cents on the dollar here — because the exclusion is already exhausted.

This is an estimate, not a tax return

The calculator applies the structure of the residence-sale rules with the rates you supply. It does not model your full return: capital gains brackets depend on your total taxable income, so a large gain can push part of itself into a higher bracket; the net investment income tax depends on modified adjusted gross income against thresholds that are not indexed; the reduced exclusion for a qualifying early sale is not computed; and non-qualified-use allocation for property that was not always your main home is not applied.

Nor does it handle inherited property, which generally receives a stepped-up basis at date of death; property received in divorce; a like-kind exchange under Section 1031; or the interaction between an installment sale and the exclusion. Read IRS Publication 523 and take professional advice on any gain large enough to matter.

What counts, and what does not

  • Adds to basis: additions and structural work, a new roof, replacement windows, HVAC and water heater replacement, a finished basement, permanent landscaping, new plumbing or wiring, and special assessments for streets or sewers.
  • Does not add to basis: repainting, repairs, routine maintenance, appliances that stay personal property, and any improvement you later removed or replaced.
  • Reduces the amount realized: brokerage commission, transfer or excise tax, owner's title policy, escrow and legal fees, and advertising you paid to sell.
  • Reduces basis: depreciation allowed or allowable, casualty loss deductions taken, and insurance reimbursements for damage you did not repair.
  • Never in the calculation: your mortgage balance and payoff. How much you borrowed against the house has no effect on gain — only on how much cash you receive.
  • Not deductible: a loss on a personal residence. It produces no deduction and no carryforward.
  • Special treatment: depreciation since 6 May 1997, which is excluded from Section 121 relief and taxed at up to 25%.

Related calculations and planning options

Gain and proceeds answer different questions, and it is worth running both. The seller net sheet calculator gives you the cash that reaches your account after the mortgage payoff — a figure that can be far smaller or far larger than the gain computed here. The commission calculator sizes the largest of the selling costs that reduce the amount realized.

For a property that has been a rental, the depreciation side needs care. The rental property depreciation calculator reconstructs how much was allowable over the holding period, and the depreciation recapture calculator handles the recapture computation in more detail than this page does. If the property is an investment rather than a residence, a 1031 exchange can defer the entire gain into a replacement property — but a like-kind exchange is not available for a personal residence, and the rules on timing and identification are strict.

Two planning levers are worth knowing about. Improving basis is retrospective and costs nothing but record-keeping. And converting a rental back into a principal residence for two years does not shelter the whole gain — the non-qualified-use rules allocate gain to the rental period, and depreciation recapture survives regardless. If you are considering that move, model it with an adviser before you rely on it.

Frequently asked questions

How much gain can I exclude when I sell my home?

Up to $250,000 if you file single or married filing separately, and up to $500,000 for a married couple filing jointly, provided you owned the home for at least two years and lived in it as your principal residence for at least two years, both measured within the five years ending on the sale date. The exclusion is generally available only once every two years. Gain above the cap is taxed at long-term capital gains rates.

Do I pay tax on the whole sale price?

No — only on the gain, and only on the part of the gain that exceeds your exclusion. Gain is the sale price minus selling costs minus your adjusted basis, and adjusted basis is what you paid plus buying costs plus capital improvements minus depreciation. A $700,000 sale on a $364,000 basis with $45,000 of costs produces a $291,000 gain, of which a single filer excludes $250,000 and is taxed on $41,000.

Does my mortgage balance affect the tax?

Not at all. Gain depends on what you paid, what you improved and what you sold for; borrowing is irrelevant to all three. A seller who refinanced heavily may receive almost no cash at closing and still owe substantial tax, and a seller who owns free and clear may receive a large wire on a sale that produces no taxable gain. Use the seller net sheet for the cash question and this page for the tax question.

What repairs and improvements can I add to my basis?

Work that adds value, prolongs the property's life or adapts it to a new use — additions, a new roof, replacement windows, HVAC systems, rewiring, replumbing, a finished basement, permanent landscaping and special assessments for streets or sewers. Routine repairs, repainting and maintenance do not qualify, although repairs done as part of a larger remodel can be included in the improvement. Keep invoices and proof of payment; the burden of substantiation is yours.

I rented the house out for a few years. What changes?

Two things. The depreciation allowed or allowable during the rental reduces your basis and is taxed as unrecaptured Section 1250 gain at a federal rate of up to 25%, and Section 121 never shelters it — even if the rest of your gain is fully excluded. Separately, gain allocable to periods of non-qualified use after 2008 is generally not excludable and is prorated by time. Both effects mean a converted rental deserves professional advice rather than a calculator alone.

What if I sell at a loss?

A loss on a personal residence is not deductible and does not carry forward. There is no tax to pay and no benefit to claim; the loss simply disappears for tax purposes. That asymmetry — gains taxable above the exclusion, losses ignored — is deliberate. A loss on property genuinely held for rental or investment is treated differently, so if the property changed character during your ownership, the characterisation is worth confirming with your adviser.

When does the 3.8% net investment income tax apply?

It applies to the taxable portion of your gain when your modified adjusted gross income exceeds the statutory threshold for your filing status. Excluded gain is not net investment income, so the Section 121 exclusion shields you from this tax as well as from the capital gains rate — which is why the exclusion is worth more than 15 or 20 cents on the dollar to a higher-income seller. Tick the box on this calculator only if you are above the threshold.

Can I avoid the tax with a 1031 exchange?

Not on a personal residence. A like-kind exchange under Section 1031 is available only for real property held for productive use in a trade or business or for investment, so it cannot be used to defer gain on the home you live in. It is available on a rental property, subject to strict identification and closing deadlines and the rules on receiving other property or cash. Property that has been both a residence and a rental raises questions that need professional advice.

References