# Capital Gains Exclusion (Section 121) Calculator

Apply the IRS $250k/$500k primary-residence exclusion, including depreciation recapture and partial exclusions.

---

- **Canonical URL:** https://dothecalculation.com/calculators/capital-gains-exclusion-calculator
- **Category:** Real Estate & Property
- **Publisher:** Do The Calculation (https://dothecalculation.com)
- **Cost:** Free, no account or sign-up required
- **Privacy:** Runs entirely in the browser; inputs are never sent to a server
- **Methodology:** https://dothecalculation.com/methodology

---

## Section 121: Tax on the Sale of Your Home

Apply the IRS primary-residence exclusion — $250,000 single, $500,000 joint — to a home sale, including depreciation recapture and the reduced exclusion for an early move.

- The IRC Section 121 rule, by name, with the two-of-five-years test
- Depreciation recapture handled separately, because it can never be excluded
- Reduced exclusion prorated by qualifying months for a qualifying early sale

## Quick Answer — How Much Tax Do You Pay When You Sell Your Home?

Often none. **IRC Section 121** lets you exclude up to **$250,000** of gain on the sale of a main home, or **$500,000** if married filing jointly, provided you owned the property and used it as your principal residence for at least **two of the five years** before the sale. The two years need not be continuous, and you generally cannot use the exclusion more than once every two years.

The arithmetic runs in this order: \(\text{Amount Realized} = \text{Sale Price} - \text{Selling Costs}\); \(\text{Adjusted Basis} = \text{Purchase Price} + \text{Improvements} - \text{Depreciation}\); \(\text{Gain} = \text{Amount Realized} - \text{Adjusted Basis}\). Depreciation recapture comes off that gain first, the exclusion applies to what remains, and anything still left is a long-term capital gain.

**Worked example:** a couple filing jointly sell for $750,000 with $45,000 of selling costs, having bought for $400,000 and made $60,000 of capital improvements, with no depreciation ever claimed. Amount realized = **$705,000**. Adjusted basis = **$460,000**. Gain = **$245,000** — inside the $500,000 joint limit, so the entire gain is excluded and the federal tax is **$0**.

Two things routinely break that clean result: depreciation claimed for a home office or a rental period, which can never be excluded, and selling before the two-year test is met, which reduces the limit. Both are modelled below.

This is the primary-residence rule and nothing else. Investment property is a different regime entirely — see the [1031 exchange tax calculator](/calculators/1031-exchange-tax-calculator) — and gains on assets other than a home belong in the [capital gains calculator](/calculators/capital-gains-calculator).

## How to Use This Calculator: A Straightforward Joint Sale

Enter the sale price and every selling cost — agent commission, transfer taxes, legal fees, and any closing costs you paid as seller. For a $750,000 sale with $45,000 of costs, the amount realized is **$705,000**.

Then build the adjusted basis. Purchase price $400,000 plus $60,000 of capital improvements gives **$460,000**. Improvements mean work that adds value or extends the life of the home — a new roof, an addition, a kitchen renovation — not repainting or fixing a leak. This is the number most sellers understate, because claiming it means finding receipts going back years, and every documented dollar is a dollar of gain that never gets taxed.

Total gain = 705,000 − 460,000 = **$245,000**. With 24 qualifying months and married-filing-jointly status, the maximum exclusion is the full **$500,000**, the exclusion applied is the whole **$245,000**, taxable capital gain is **$0**, and total federal tax is **$0**.

Note what the $60,000 of improvements did. Without them the basis would be $400,000 and the gain $305,000 — still inside the joint limit, so no difference here. But for a single filer the same sale would produce a $55,000 taxable gain without the improvements and none with them. Documentation is worth real money precisely at the margin.

## A Second Example: A Large Gain With Depreciation Recapture

Now a single filer who once rented the property out. Sale price $900,000 with $54,000 of selling costs, bought for $300,000, $80,000 of capital improvements, and **$40,000 of depreciation** claimed during a rental period. Long-term capital gains rate 20%, and the net investment income tax applies.

Depreciation reduces basis, so adjusted basis = 300,000 + 80,000 − 40,000 = **$340,000**, and amount realized = **$846,000**. Total gain = **$506,000** — note the depreciation has *increased* the gain by exactly the $40,000 deducted.

That $40,000 is now **depreciation recapture**, taxed as unrecaptured section 1250 gain at up to 25%, and it can never be excluded. It comes off the top, leaving **$466,000** eligible for the exclusion. The single-filer limit caps the exclusion at **$250,000**, so **$216,000** remains as a taxable long-term capital gain.

The tax: recapture of $40,000 × 25% = **$10,000**. Capital gains of $216,000 × 20% = **$43,200**. Net investment income tax of 3.8% on the $256,000 of taxable gain = **$9,728**. Total federal tax = **$62,928**, an effective rate of **12.4%** on the full $506,000 gain — low, because two thirds of it escaped tax entirely, but a long way from the $0 in the first example.

## The Two-of-Five-Years Test, Partial Exclusions, and What Trips People Up

The **ownership and use test** requires that you owned the home for at least two years and lived in it as your principal residence for at least two years, both within the five-year window ending on the sale date. The two periods do not have to be the same two years and need not be continuous — 24 months in aggregate is what counts. There is also a look-back rule: you generally cannot claim the exclusion if you already used it on another home sold within the previous two years.

A **reduced exclusion** is available if you sell early, but only for specific reasons: a change in place of employment, a health-related move, or certain unforeseen circumstances set out in the regulations. Where it applies, the limit is prorated by qualifying months over 24 — so a single filer at 14 qualifying months has a maximum exclusion of $250,000 × 14/24 = **$145,833**, which still shelters a great many ordinary gains. Selling early simply because you want to is not a qualifying reason, and the calculator will happily prorate a limit you may not actually be entitled to. Check the criteria before relying on it.

**Depreciation recapture** is the most common unpleasant surprise, and it catches people who never thought of themselves as landlords. Anyone who claimed a home-office deduction against a room in the house has been depreciating it, and that depreciation is recaptured on sale at up to 25% regardless of the exclusion. It is not optional either — the rule applies to depreciation *allowed or allowable*, meaning the IRS can recapture depreciation you were entitled to claim even if you never actually claimed it.

There is also **nonqualified use**, added in 2009, which this calculator does not model. Broadly, periods after 2008 when the property was not your principal residence — rented out, or a second home — can make a proportional share of the gain ineligible for the exclusion, calculated as nonqualified years over total ownership years. If the property has ever been a rental since 2009, the exclusion available to you is likely smaller than the figure shown here, and the calculation genuinely needs a tax professional.

## Limitations

This calculator estimates **federal** tax only, under IRC Section 121, using the rates you enter. It does not know your income, so it cannot determine which long-term capital gains bracket you fall into (0%, 15%, or 20%) or whether the 3.8% net investment income tax applies — both are inputs you set. It also ignores state and local income tax entirely, which in high-tax states can add a substantial amount and which many states apply differently from the federal rule.

It does not model nonqualified use under the 2009 rules, which proportionally reduces the exclusion for post-2008 periods when the home was not your principal residence. It does not handle a partial-year conversion between rental and residence, an inherited or gifted basis, a property acquired in a prior like-kind exchange (which carries its own restrictions on using Section 121), the special rules for a surviving spouse or for members of the armed forces, or installment sales. Any of these changes the answer materially.

It also assumes the depreciation figure you enter is complete. Recapture applies to depreciation *allowed or allowable* after 6 May 1997, which means the IRS can assess it on deductions you were entitled to take even if you never claimed them — a real trap for anyone who used a home office informally. **This is a general educational estimate, not tax advice.** A home sale is usually among the largest taxable events a household ever has, the rules above are simplified, and thresholds change. Confirm your situation with a qualified tax professional or against current IRS Publication 523 before relying on any figure here.

## Related Calculators

These three tools cover different regimes and should not be confused with each other. This one is the **primary residence** rule: exclusion under Section 121. The [1031 Exchange Tax Calculator](/calculators/1031-exchange-tax-calculator) covers **investment property**, where the mechanism is deferral through a like-kind exchange rather than exclusion — a different rule, a different asset, and not interchangeable. The [Capital Gains Calculator](/calculators/capital-gains-calculator) handles the general case for assets that are neither. Alongside those, the [Closing Cost Estimator](/calculators/closing-cost-estimator) helps build the selling-cost figure that reduces your amount realized, and the [Rental Property ROI Calculator](/calculators/rental-property-roi-calculator) models the depreciation that later comes back as recapture.

## Frequently asked questions

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

Up to $250,000 if you file singly and $500,000 if married filing jointly, under IRC Section 121, provided you owned and lived in the home as your principal residence for at least two of the five years before the sale. Gain above the limit is taxed as a long-term capital gain.

### What is the two-of-five-years rule?

You must have owned the home for at least two years and used it as your principal residence for at least two years, both within the five-year period ending on the sale date. The two periods need not be the same years or be continuous — 24 months in aggregate is what matters. You also generally cannot use the exclusion twice within two years.

### Can I get a partial exclusion if I sell before two years?

Only for specific reasons: a change in place of employment, a health-related move, or certain unforeseen circumstances defined in the regulations. Where one applies, the limit is prorated by qualifying months over 24 — 14 months gives a single filer $145,833 rather than $250,000. Selling early by choice does not qualify.

### Does depreciation from a home office affect my home sale?

Yes, and it is the most common surprise. Depreciation claimed after 6 May 1997 reduces your basis, which increases the gain, and is then recaptured as unrecaptured section 1250 gain at up to 25%. It can never be excluded under Section 121. The rule applies to depreciation allowed or allowable, so the IRS can assess it even on deductions you did not actually claim.

### What counts as a capital improvement for basis purposes?

Work that adds value or extends the life of the home — a new roof, an addition, a kitchen or bathroom renovation, a new HVAC system, landscaping that is genuinely structural. Routine repairs and maintenance do not count. Keep receipts: this is the number sellers most often understate, and every documented dollar is a dollar of gain that never gets taxed.

### How is Section 121 different from a 1031 exchange?

They apply to different property and work differently. Section 121 excludes gain permanently on a primary residence. A 1031 exchange defers gain on investment property by rolling it into a replacement property — the tax is postponed, not forgiven. A home you live in is not eligible for a 1031 exchange, and investment property is not eligible for Section 121.

### Do I still pay the 3.8% net investment income tax?

Possibly, on the portion of gain that is not excluded. Gain excluded under Section 121 is not net investment income, but taxable gain above the limit and depreciation recapture can be, if your modified adjusted gross income exceeds the applicable threshold. This calculator applies it as an optional toggle because whether it applies depends on your income.

### Does this include state tax?

No. It estimates federal tax only. State treatment of home sale gains varies considerably — some states conform to the federal exclusion, some do not, and rates differ widely — so add your state's treatment separately and check with a tax professional for your jurisdiction.

## Related concepts

- **IRC Section 121** — The Internal Revenue Code provision excluding up to $250,000 ($500,000 joint) of gain on the sale of a principal residence, subject to the two-of-five-years ownership and use test.
- **Adjusted Basis** — Purchase price plus capital improvements minus depreciation claimed. Raising it with documented improvements is the most reliable way to reduce a taxable home sale gain.
- **Unrecaptured Section 1250 Gain** — Depreciation claimed after 6 May 1997, recaptured on sale at up to 25%. It is never excludable under Section 121 and applies to depreciation allowed or allowable, claimed or not.

## Related guides

- [How to Use Do The Calculation Calculators: A Practical Step-by-Step Guide](https://dothecalculation.com/blog/site-guides/how-to-use-calculators) — Learn the fastest reliable workflow for using Do The Calculation calculators, reading results, checking formulas, and using save, print, share, and export actions correctly.
- [Understanding Calculator Formulas: How DTC Turns Inputs into Results](https://dothecalculation.com/blog/site-guides/understanding-calculator-formulas) — Understand how Do The Calculation formulas are presented, what the explanation blocks mean, and how to verify calculator logic before using a result in a real decision.

## Related calculators

- [1031 Exchange Tax Deferral Calculator](https://dothecalculation.com/calculators/1031-exchange-tax-calculator) — Calculate capital gains tax liability, depreciation recapture, and adjusted basis when deferring taxes through an IRS Section 1031 exchange.
- [Seller Financing Amortization Calculator](https://dothecalculation.com/calculators/seller-financing-calculator) — Model owner-financed loan amortization schedules, balloon payments, and installment sale capital gains tax benefits for seller financing deals.
- [Airbnb ROI Calculator](https://dothecalculation.com/calculators/airbnb-roi-calculator) — Calculate Airbnb rental ROI, including projected monthly cash flow, cap rate, and cash-on-cash return, to evaluate short-term rental profitability.
- [Real Estate Closing Costs Estimator](https://dothecalculation.com/calculators/closing-cost-estimator) — Estimate real estate closing costs, including buyer and seller expenses, prepaid items, reserves, and total cash needed to close on a home.
- [HELOC Payment & Draw Calculator](https://dothecalculation.com/calculators/home-equity-line-of-credit-heloc-calculator) — Simulate variable-rate HELOC payments, including interest-only draw period payments and later principal-and-interest repayment schedules.
- [House Flipping Calculator](https://dothecalculation.com/calculators/house-flipping-calculator) — Calculate house flipping profit potential, including maximum allowable offer, renovation budget, holding costs, and expected ROI for property flips.

---

_This is a general educational estimate of federal tax under IRC Section 121, not tax advice. It uses the capital gains and recapture rates you enter rather than determining your bracket, excludes state and local tax entirely, and does not model nonqualified use under the 2009 rules, inherited or gifted basis, property acquired in a prior like-kind exchange, surviving-spouse or armed-forces provisions, or installment sales — any of which changes the answer materially. A home sale is often the largest taxable event a household has; confirm your situation against current IRS Publication 523 and with a qualified tax professional._

---

_Source: [Do The Calculation](https://dothecalculation.com/calculators/capital-gains-exclusion-calculator). Quote freely with attribution and a link to this page._
