Answer · IRC § 121

How to avoid capital gains tax on real estate

The $250,000 and $500,000 home-sale exclusion, the two-of-five-year test, the reduced exclusion most calculators get wrong, and the basis records worth finding.

Tax year 2026 figures. Last updated .

The exclusion is the whole game

For a principal residence, section 121 excludes $250,000 of gain if you file single and $500,000 if you file jointly. That is not a deduction or a deferral — the excluded gain simply never becomes taxable income.

For the majority of home sales it covers everything, and the tax is zero. Nothing else on this page matters if your gain fits inside it.

The two-of-five-year test

To qualify you must have owned the home for at least two of the five years ending on the sale date, and used it as your principal residence for at least two of those same five years.

Three details people get wrong. The two years need not be continuous — twenty-four months in aggregate is enough. The ownership and use periods need not be the same two years. And for joint filers, only one spouse must meet the ownership test, though both must meet the use test to get the full $500,000.

There is also a frequency limit: you generally cannot claim the exclusion if you claimed it on another home within the previous two years.

The reduced exclusion, and the step most calculators get wrong

If you fall short of two years because of a change in place of employment, a health reason, or another qualifying unforeseen circumstance, you do not lose the exclusion. You get a reduced one.

Here is the part that is routinely computed incorrectly. The reduction prorates the maximum exclusion, not the gain. Treasury Regulation 1.121-3(g) is explicit about it.

Work through it: eighteen months of qualifying use out of twenty-four is a fraction of 18/24. Applied to the $250,000 maximum, that gives an exclusion of $187,500. A calculator that instead applies 18/24 to the gain produces a completely different and wrong answer — and for a gain smaller than the maximum it will understate the exclusion badly. This site prorates the maximum, and a test fixture pins that behaviour.

Depreciation is never excluded

If you ever let the property or claimed a home-office deduction, the depreciation allowed or allowable after 6 May 1997 cannot be excluded under section 121. It remains taxable as unrecaptured section 1250 gain at up to 25%, no matter how large your exclusion is.

So a home that was briefly a rental produces a small taxable amount even when the exclusion covers everything else. It catches people who let a property for a year while trying to sell it.

Basis: the lever people forget

Every dollar of capital improvement raises your basis and therefore reduces your gain. A new roof, an extension, a rewiring, a kitchen — these add to basis. Routine repairs and maintenance do not.

Selling costs also come off: agent commission, legal fees, transfer taxes. On a typical sale those alone are several percent of the price.

This is the least glamorous lever on the page and often the most valuable, because it requires no planning at all — only records. If you are approaching the exclusion ceiling, an afternoon spent finding twenty years of improvement receipts can be worth more than any timing strategy.

Beyond the exclusion

For investment property rather than a home, a 1031 like-kind exchange can defer the gain into a replacement property. It defers rather than forgives, the deadlines are strict, and it does not apply to a principal residence. This calculator does not model it.

Assets held until death generally receive a stepped-up basis, extinguishing the unrealised gain for heirs. And spreading a sale across two tax years, or realising it in a low-income year, works for property exactly as it does for shares — see the general levers.

Converting a rental into a residence, and the limit on it

Moving into a property you previously let, living there two years and then selling looks like a route to converting rental gain into excluded gain. It works, but far less completely than it first appears.

Section 121(b)(5), added for periods after 2008, allocates the gain between qualified and nonqualified use. Time the property was not your principal residence produces a proportional share of gain that cannot be excluded, so a property let for eight years and lived in for two does not become fully excludable by the move.

And depreciation claimed during the rental years is recaptured regardless — the exclusion never reaches it.

Divorce, death and the ownership tests

The two-of-five-year tests have specific relief in circumstances where applying them literally would be unfair.

A spouse who receives a home in a divorce transfer generally takes on the transferor’s ownership period, so the clock is not reset. A taxpayer whose spouse has died may be able to use the full $500,000 joint exclusion on a sale within two years of the death, provided the couple would have qualified.

Service members and certain government employees can suspend the five-year lookback for periods of qualified extended duty, up to ten years — which prevents a posting abroad from quietly disqualifying a home.

These are exactly the sort of provisions this calculator does not model. It applies the ownership and use months you give it, so if one of the above applies to you, the months to enter are not necessarily the months you actually lived there.

The records to keep, and for how long

Basis is the lever most available to most owners, and it is the one most often lost to poor record-keeping. What matters is knowing what to keep.

Keep: the closing statement from purchase and from sale, invoices for capital improvements — additions, a new roof, replacement windows, rewiring, a new heating system, landscaping that adds value — and records of any casualty losses or insurance reimbursements that adjusted basis.

Do not bother: routine repairs and maintenance do not add to basis. Repainting, fixing a leak, servicing a boiler and replacing a broken pane are all maintenance rather than improvement, however much they cost.

On duration: the usual advice to keep tax records for three years is about the assessment period for a return already filed. Basis records are different — they support a gain calculation on a sale that may be decades away, so they need to survive for as long as you own the property and then for the assessment period after the sale year.

For a property held twenty or thirty years, this is the difference between a documented basis and a guessed one. It is unglamorous, it requires no planning, and on a sale near the exclusion ceiling it can be worth more than every timing strategy on this page.

The exclusion is per sale, not per lifetime

A common misunderstanding, and a legacy of the rules that applied before 1997. There is no once-in-a-lifetime limit and no age requirement on the section 121 exclusion.

You can claim it repeatedly, on successive homes, provided each sale meets the ownership and use tests and you have not claimed it on another home within the previous two years. Someone moving every three or four years can use it every time.

The older rules — a one-time exclusion available from age 55, and a rollover that deferred gain into a replacement home — were repealed in 1997 and replaced by the current exclusion. Advice framed around either is nearly thirty years out of date, and it still circulates.

Worked example

Computed by the same engine that powers the calculator, at the moment this page was built — not typed in by hand. Open the derivation to see every rule and citation.

A gain larger than the exclusion

A single filer with $110,000 of wages sells a long-held principal residence for $900,000. Adjusted basis $400,000, owned and lived in throughout.

Taxable income after deduction
$343,900
Taxable gain
$250,000
Tax owed without the sale
$15,370
Tax the sale added
$43,580
of which net investment income tax
$6,080
Total federal tax
$58,950
Effective rate on the gain
17.43%

A $500,000 gain, less the $250,000 exclusion, leaves $250,000 taxable. Filing jointly the same sale would be fully excluded — which is one of the starkest filing-status differences in the code.

Caveats on this example (1)
  • Net investment income was derived from capital gains and qualified dividends only. Interest, non-qualified dividends, rents, royalties and passive business income inside ordinaryIncome are also net investment income under IRC 1411(c) and are not counted here.
Show the working — 16 steps, each with its citation
  1. Gain on sale of principal residence$500,000Amount realized less adjusted basisIRC 1001; IRS Pub. 523

    $900,000 amount realized less $400,000 adjusted basis.

  2. Maximum Section 121 exclusion$250,000Section 121 exclusionIRC 121; IRS Pub. 523

    Owned for 60 months and used as a principal residence for 60 months in the 5-year lookback, both at least 24. No exclusion claimed in the prior 2 years.

  3. Section 121 exclusion applied-$250,000Section 121 exclusionIRC 121; IRS Pub. 523

    $250,000 of gain is excluded from income, the lesser of the $250,000 maximum exclusion and the $500,000 of excludable gain.

  4. Taxable long-term gain from the home sale$250,000Section 121 exclusionIRC 121; IRS Pub. 523

    Taxed at the long-term capital gain rates.

  5. Net short-term capital gain or loss for the year$0Short-term / long-term nettingIRC 1222; IRS Pub. 550

    Assets held one year or less. Taxed at ordinary rates if a net gain.

  6. Net long-term capital gain or loss for the year$250,000Short-term / long-term nettingIRC 1222; IRS Pub. 550

    Assets held more than one year. Eligible for the 0/15/20% rates.

  7. Standard deduction-$16,100Deduction from adjusted gross incomeRev. Proc. 2025-32 4.14(1) (IRC 63(c)(2))

    Adjusted gross income of $360,000 less $16,100.

  8. Taxable income$343,900Taxable incomeIRC 63(a)

    The figure the rate tables and the capital gain ceilings are both measured against.

  9. Ordinary income taxed at 10%$1,240Ordinary income tax bracketsRev. Proc. 2025-32 4.01 (IRC 1(j)(2))

    $12,400 of taxable income between $0 and $12,400.

  10. Ordinary income taxed at 12%$4,560Ordinary income tax bracketsRev. Proc. 2025-32 4.01 (IRC 1(j)(2))

    $38,000 of taxable income between $12,400 and $50,400.

  11. Ordinary income taxed at 22%$9,570Ordinary income tax bracketsRev. Proc. 2025-32 4.01 (IRC 1(j)(2))

    $43,500 of taxable income between $50,400 and $93,900.

  12. Ordinary income stacked below the long-term gain$93,900LTCG bracket stackingIRC 1(h); Schedule D Tax Worksheet, Form 1040 instructions

    Long-term gain is taxed by reference to where it sits ON TOP of $93,900 of other taxable income, not from the bottom of the rate table.

  13. Long-term gain taxed at 15%$37,500LTCG bracket stackingRev. Proc. 2025-32 4.03 (IRC 1(h), 1(j)(5))

    Gain between the $49,450 zero-rate ceiling and the $545,500 15% ceiling.

  14. Net investment income tax threshold$200,000IRC 1411 thresholdIRC 1411(a)-(b); 26 C.F.R. 1.1411-2

    Modified AGI of $360,000 against the $200,000 threshold for a single filer. This threshold is statutory and is not adjusted for inflation.

  15. Net investment income tax at 3.8%$6,080Net investment income taxIRC 1411(a)-(b); 26 C.F.R. 1.1411-2

    3.8% of $160,000, the lesser of net investment income ($250,000) and the amount by which modified AGI exceeds the threshold ($160,000). Here the binding figure is the excess of modified AGI over the threshold.

  16. Total tax$58,950Sum of all tax stepsRev. Proc. 2025-32 (I.R.B. 2025-45)

    $58,950 on $360,000 of total income, an effective rate of 16.38%.

A work move at eighteen months

The same filer sells after eighteen months rather than five years, having relocated for a job. Gain of $120,000, qualifying for the reduced exclusion.

Taxable income after deduction
$93,900
Taxable gain
$0
Tax owed without the sale
$15,370
Tax the sale added
$0
Total federal tax
$15,370
Effective rate on the gain

The reduced exclusion is 18/24 of the $250,000 maximum — $187,500 — which comfortably covers the $120,000 gain. Prorating the gain instead would have produced a taxable amount that does not exist.

Show the working — 14 steps, each with its citation
  1. Gain on sale of principal residence$120,000Amount realized less adjusted basisIRC 1001; IRS Pub. 523

    $520,000 amount realized less $400,000 adjusted basis.

  2. Reduced maximum exclusion (partial exclusion)$187,500Section 121(c) prorationIRC 121(c); Treas. Reg. 1.121-3(g)

    18 of the 24 required months qualify, so the maximum exclusion of $250,000 is prorated to $187,500. The fraction applies to the maximum exclusion amount, not to the gain.

  3. Section 121 exclusion applied-$120,000Section 121 exclusionIRC 121; IRS Pub. 523

    $120,000 of gain is excluded from income, the lesser of the $187,500 maximum exclusion and the $120,000 of excludable gain.

  4. Taxable long-term gain from the home sale$0Section 121 exclusionIRC 121; IRS Pub. 523

    Taxed at the long-term capital gain rates.

  5. Net short-term capital gain or loss for the year$0Short-term / long-term nettingIRC 1222; IRS Pub. 550

    Assets held one year or less. Taxed at ordinary rates if a net gain.

  6. Net long-term capital gain or loss for the year$0Short-term / long-term nettingIRC 1222; IRS Pub. 550

    Assets held more than one year. Eligible for the 0/15/20% rates.

  7. Standard deduction-$16,100Deduction from adjusted gross incomeRev. Proc. 2025-32 4.14(1) (IRC 63(c)(2))

    Adjusted gross income of $110,000 less $16,100.

  8. Taxable income$93,900Taxable incomeIRC 63(a)

    The figure the rate tables and the capital gain ceilings are both measured against.

  9. Ordinary income taxed at 10%$1,240Ordinary income tax bracketsRev. Proc. 2025-32 4.01 (IRC 1(j)(2))

    $12,400 of taxable income between $0 and $12,400.

  10. Ordinary income taxed at 12%$4,560Ordinary income tax bracketsRev. Proc. 2025-32 4.01 (IRC 1(j)(2))

    $38,000 of taxable income between $12,400 and $50,400.

  11. Ordinary income taxed at 22%$9,570Ordinary income tax bracketsRev. Proc. 2025-32 4.01 (IRC 1(j)(2))

    $43,500 of taxable income between $50,400 and $93,900.

  12. Net investment income tax threshold$200,000IRC 1411 thresholdIRC 1411(a)-(b); 26 C.F.R. 1.1411-2

    Modified AGI of $110,000 against the $200,000 threshold for a single filer. This threshold is statutory and is not adjusted for inflation.

  13. Net investment income tax does not apply$0IRC 1411 thresholdIRC 1411(a)-(b); 26 C.F.R. 1.1411-2

    Modified AGI is $90,000 below the threshold.

  14. Total tax$15,370Sum of all tax stepsRev. Proc. 2025-32 (I.R.B. 2025-45)

    $15,370 on $110,000 of total income, an effective rate of 13.97%.

Run your own figures

Nothing you enter leaves your browser. The calculation runs locally and no values are transmitted or stored on a server — see the privacy page.

You
The sale
State

Related questions

How to avoid capital gains tax on real estate

On a main home the exclusion under IRC section 121 is the large one: $250,000 of gain excluded filing single, $500,000 jointly, if you owned and lived in the property for two of the five years before the sale. The two years need not be continuous. Falling short for a work move, a health reason or another qualifying unforeseen circumstance gives a reduced exclusion rather than none — and that reduction prorates the maximum exclusion, not the gain, which is the step most calculators get wrong. Improvements you paid for also raise your basis and shrink the gain, if you kept the receipts.

How much is capital gains tax on real estate?

It depends on what the property was to you. On a main home, often nothing, because the section 121 exclusion covers the whole gain. On a second home, the ordinary 0/15/20% ladder. On a rental the gain splits: the part matching depreciation you claimed is unrecaptured section 1250 gain taxed at up to 25%, and only the remainder gets the preferential rates. Selling a long-held rental therefore produces a higher bill than the headline rates suggest.

Why do I owe 25% on the sale of a rental property?

Because depreciation you claimed while letting the property reduced your basis, and on sale that portion of the gain is recaptured as unrecaptured section 1250 gain. The 25% is a maximum, not a flat rate — if your ordinary rate is lower, the lower rate applies. The recaptured amount is the lesser of the depreciation taken and the total gain, so it can never exceed what you actually made on the sale.

The full guide index lists every answer page, and the state comparison covers the state layer on top of these federal figures.