Home Loans by JaimeYour friendly mortgage advisor
FHA, VA & Conventional

How the IRS Calculates Capital Gains Exclusion When You Sell Your Home

Learn how the IRS calculates the capital gains exclusion—$250,000 for single filers or $500,000 for married couples filing jointly —when you sell your primary residence, using the two-out-of-five-year ownership-and-use test.

A guide from The Home Loans by Jaime DeskOctober 09, 2026

If you're selling your home and wondering how much of the profit the IRS actually lets you keep tax-free, the answer comes down to two things: how long you owned and lived in the home, and whether your total gain fits under a dollar cap. Under Internal Revenue Code Section 121, a single filer can exclude up to $250,000 of gain from the sale of a primary residence, while married couples filing jointly can often exclude up to $500,000. This explainer walks through how the IRS defines eligibility in Publication 523, then runs a full worked example for a single filer so you can see exactly where the numbers come from.

The legal basis: what Section 121 actually says, and where to find your numbers

The exclusion exists because of IRC Section 121(a), which says gain from selling a home is left out of your taxable income if you owned and used the property as your principal residence for periods totaling at least 2 years out of the 5 years ending on the sale date. That 2-out-of-5 window is the backbone of the whole rule, and it applies to any taxpayer selling a principal residence, not just first-time sellers. Section 121(b)(1) then caps how much gain an individual can exclude on any single sale at $250,000. IRS Publication 523, the 2025 revision, translates this statute into plain-language guidance for people actually preparing a tax return, including worksheets for figuring your exclusion. Certain settlement and closing costs, such as abstract fees, legal fees, recording fees and transfer taxes, along with the cost of capital improvements, can be added to the home's purchase price to determine adjusted basis, which lowers the taxable gain you calculate on Publication 523's worksheets. Worksheet 1 in Publication 523 is where a single filer, or someone married filing separately, can confirm the $250,000 cap applies after meeting the residence, ownership and look-back requirements, while married joint filers meeting the combined conditions use the same worksheet to confirm the $500,000 cap.

The two-out-of-five-year test, broken into parts

Publication 523 splits the 2-out-of-5-year rule into separate ownership and use requirements, and it helps to treat them separately. For ownership, you need to have held title to the home for at least 24 months, or 2 years, within the 5-year period ending on the sale date. For married couples filing jointly, only one spouse needs to clear this ownership bar. For use, you need to have lived in the home as your residence for a cumulative 24 months, or 730 days, during that same 5-year window, and those months do not need to be consecutive, with short temporary absences such as vacations still counting as time living in the home. A married couple seeking the full $500,000 exclusion needs both spouses to independently satisfy the use requirement, even though only one needs to meet the ownership requirement.

The look-back rule and how basis shrinks your gain

Beyond ownership and use, there is a third condition called the look-back requirement: you generally cannot claim the exclusion if you already used it on a different home sale within the 2 years before your current sale's closing date. If you sold a prior home in that window but did not claim the exclusion on it, you still satisfy the look-back requirement. Certain settlement costs from when you bought the home, such as abstract fees, legal fees, recording fees, and transfer taxes, along with the cost of capital improvements you made over the years, can be added to your purchase price to raise your adjusted basis, which in turn lowers your taxable gain, though certain costs such as mortgage-related fees, fire or casualty insurance, and amounts deducted as moving expenses before 1994 are excluded from basis.

Worked example: a single filer selling for $700,000

Picture a single filer who bought a home for $300,000 and later put $20,000 into capital improvements, bringing the adjusted basis to $320,000. This is a hypothetical, illustrative example, not an official IRS example, and it assumes no other basis adjustments like depreciation recapture. The filer sells the home for $700,000 and pays $40,000 in selling expenses, leaving an amount realized of $660,000. Subtracting the $320,000 adjusted basis from the $660,000 amount realized produces a total gain of $340,000 before any exclusion is applied. For this example, we assume the filer owned and used the home as a principal residence for at least 24 months within the prior 5 years, did not claim the exclusion on another home sale in the prior 2 years, and has no disqualifying factors such as a 1031 exchange or expatriate tax status, meaning the full Eligibility Test in Publication 523 is satisfied.

  • selling price: 700000
  • selling expenses: 40000
  • purchase price: 300000
  • improvements: 20000
  • Formula: (selling price - selling expenses) - (purchase price + improvements)
  • Result: 340000

Applying the $250,000 exclusion to the gain

Because this filer meets the eligibility conditions, the $250,000 single-filer exclusion cap under Section 121(b)(1) applies to the $340,000 gain. Subtracting the $250,000 exclusion from the $340,000 total gain leaves $90,000 of taxable gain that the filer would need to report. Notice that the exclusion does not erase the entire gain here; it simply shields the first $250,000, and anything above that cap is still subject to capital gains treatment on the return.

  • selling price: 700000
  • selling expenses: 40000
  • purchase price: 300000
  • improvements: 20000
  • exclusion cap: 250000
  • Formula: ((selling price - selling expenses) - (purchase price + improvements)) - exclusion cap
  • Result: 90000

Exclusion amount by filing status

Filing status Conditions to meet Maximum exclusion
Single, or married filing separately Filer individually meets the residence, ownership, and look-back requirements $250,000
Married filing jointly Both spouses meet the residence and look-back requirements, and one or both meet the ownership requirement $500,000

Based on IRS Publication 523 Worksheet 1 for determining the maximum exclusion by filing status.

Key takeaways

  • The exclusion comes from IRC Section 121: you must have owned and used the home as a principal residence for at least 2 of the 5 years before the sale date.
  • A single filer's exclusion caps out at $250,000 of gain on any one sale, while married joint filers meeting the combined conditions can exclude up to $500,000.
  • Ownership and use are measured separately: 24 months of ownership and 24 cumulative, non-consecutive months of actually living in the home, both within the 5-year window.
  • You generally cannot use the exclusion again if you already claimed it on a different home sale within the 2 years before this sale's closing.
  • Adding eligible closing costs and capital improvements to your purchase price raises your adjusted basis and reduces the gain subject to tax in the first place.

Frequently asked questions

Do the 24 months of ownership and use have to be the same 24 months?

The IRS treats ownership and use as separate requirements, each of which must total 24 months within the same 5-year period ending on the sale date.

Does the 24 months of living in the home need to be continuous?

No. Publication 523 states the 730 days of residence can fall anywhere within the 5-year period and do not need to be a single uninterrupted block of time, so periods of living there at different points can be added together.

What happens if I sold another home and excluded gain on it within the past 2 years?

Because that prior exclusion falls inside the 2-year look-back window, you would generally not be allowed to use the Section 121 exclusion again on this sale.

What if I sold a different home within the last 2 years but didn't claim the exclusion on it?

You would still meet the look-back requirement, since Publication 523 only disqualifies you if you actually took the exclusion on that earlier sale, not merely because a sale occurred.

Can married couples get $500,000 if only one spouse owned the home?

Potentially, yes for the ownership piece: only one spouse needs to meet the ownership requirement, but Publication 523's worksheet requires both spouses to independently meet the residence and look-back requirements to reach the full $500,000 exclusion.

Can I add the cost of a new roof or kitchen remodel to my basis?

Generally, yes, capital improvements can be added to your purchase price to calculate adjusted basis, which lowers your taxable gain, though some costs such as mortgage-related fees and certain insurance are excluded from basis under Publication 523.

Where to go from here

This explainer walks through the mechanics of the exclusion using a hypothetical example, but your own adjusted basis, eligibility, and filing status details can change the outcome significantly. If you're planning a home sale and want help thinking through financing or timing around it, you can read more on [homeloansbyjaime.com](https://www.homeloansbyjaime.com/resources) or talk with a tax professional before you file.

Sources