Short answer: if you owned the home and lived in it as your main home for at least 24 of the 60 months before closing, section 121 of the tax code takes the first $250,000 of the gain out of your income, or $500,000 on a joint return, and most sellers owe nothing. It stops being a simple answer in four places: when you missed the 24 months and the exclusion is reduced rather than lost, when you claimed depreciation on the property, when some of the ownership years were not anybody’s main residence, and past the ceiling, where the leftover gain is taxed at rates that depend on your other income. The calculator works all of it in the order Publication 523 does, and the tables under it are the same arithmetic done by hand so you can check the tool against them.
The Two Tests, in the Words of the Law
Eligibility is one sentence long, and it is worth reading the actual sentence rather than a summary of it:
“Gross income shall not include gain from the sale or exchange of property if, during the 5-year period ending on the date of the sale or exchange, such property has been owned and used by the taxpayer as the taxpayer’s principal residence for periods aggregating 2 years or more.” 26 U.S.C. 121(a)
Publication 523 puts the same test in the two counts the calculator asks for. On ownership: “If you owned the home for at least 24 months (2 years) out of the last 5 years leading up to the date of sale (date of the closing), you meet the ownership requirement.” On use: “All that is required is a total of 24 months (730 days) of residence during the 5-year period.”
Aggregating is the operative word, and it is the reason a rented-out year does not automatically cost you the exclusion. Neither 24 months has to be consecutive. You can own the home through a decade and count use only for the nights you actually slept there, which is why the panel asks for the two numbers separately instead of asking how long you have owned the place. The months between closing and moving out still count as use; the months after that count as ownership only.
Two periods that people assume are lost are not. A spouse’s or former spouse’s use of the home under a divorce or separation instrument counts as your use, 26 U.S.C. 121(d)(3)(B), and property transferred from a spouse counts as owned for as long as the transferor owned it, 121(d)(3)(A).
What the Ceiling Is, and Why It Has Never Moved
The two-year test decides whether you get an exclusion. Paragraph (b) decides how much of the gain it can swallow:
“The amount of gain excluded from gross income under subsection (a) with respect to any sale or exchange shall not exceed $250,000.” 26 U.S.C. 121(b)(1)
A joint return gets $500,000 when “either spouse meets the ownership requirements of subsection (a) with respect to such property; (ii) both spouses meet the use requirements of subsection (a) with respect to such property”, 121(b)(2)(A). Publication 523 states the trap in that sentence plainly: “Unlike the ownership requirement, each spouse must meet the residence requirement individually for a married couple filing jointly to get the full exclusion.”
Those two ceilings are statute, not inflation-adjusted guidance, so a 2026 page prints the same $250,000 and $500,000 that a 2009 page printed. That is the asymmetry that hurts: the brackets, the standard deduction of $16,100 and the gain bands in the tables below all moved for 2026 under Rev. Proc. 2025-32, and the ceiling did not move at all. In a market where median prices roughly doubled since 2009, a growing number of ordinary sales now clear it, and the tax starts on the part above $250,000.
One Excluded Sale Every Two Years
The exclusion is not a bucket you can dip into twice in quick succession:
“Subsection (a) shall not apply to any sale or exchange by the taxpayer if, during the 2-year period ending on the date of such sale or exchange, there was any other sale or exchange by the taxpayer to which subsection (a) applied.” 26 U.S.C. 121(b)(3)
Publication 523’s version is the one to keep in your head when you are planning: “You may take the exclusion only once during a 2-year period.” Sell in March 2026 and the next sale that can use the exclusion is March 2028. The panel asks for that gap because it is a real situation for people who move twice in three years, and because the answer to a too-soon second sale is not always zero: the reduced exclusion in subsection (c) reaches 121(b)(3) failures as well as ownership and use failures.
If You Missed 24 Months: Reduced, Not Lost
This is the single most common wrong answer on the competing pages, which print “you need two of the last five years” and stop. Section 121(c) exists for people who sold early because life moved them:
“the amount which bears the same ratio to such limitation (determined without regard to this paragraph) as” the shortest of the qualifying periods “bears to (ii) 2 years.” 26 U.S.C. 121(c)(1)
It applies when the sale is “by reason of a change in place of employment, health, or, to the extent provided in regulations, unforeseen circumstances”, 121(c)(2)(B). Publication 523’s employment test is a distance, not a feeling: “You took or were transferred to a new job in a work location at least 50 miles farther from the home than your old work location.”
The arithmetic is the shortest of three periods divided by 24. Owned 40 months but lived in it 14: the ceiling becomes $250,000 x 14 / 24 = $145,833, and because that sale’s gain was only $36,000, the reduced exclusion still covers all of it and the tax is $0. Nine months from closing to selling gives $250,000 x 9 / 24 = $93,750. Twenty months of use on a $194,000 gain gives $208,333, which is more than the gain, so nothing is left to tax. A contract ending on schedule is not on Publication 523’s list; a new work location 50 miles farther, a health problem, or a job loss is.
The Depreciation the Exclusion Can Never Reach
If you ran a home office or rented part of the house and claimed depreciation, part of the gain is permanently outside the exclusion, however clean the two-year tests look:
“Subsection (a) shall not apply to so much of the gain from the sale of any property as does not exceed the portion of the depreciation adjustments (as defined in section 1250(b)(3)) attributable to periods after May 6, 1997, in respect of such property.” 26 U.S.C. 121(d)(6)
Publication 523 says the same thing in worksheet language: “depreciation deductions claimed during the previous business use must be reported on line 5a of Worksheet 2 and recognized as unrecaptured section 1250 gain”. It also moves that depreciation through your basis before the gain is even figured, which is why the panel subtracts it from the purchase price rather than treating it as a separate bill: on its Finley example the publication prints “The total gain on the sale is $320,000”, worked as the $700,000 price against a basis reduced to $380,000 by $20,000 of depreciation.
The rate on that slice is capped lower than your bracket, but not at zero. The Schedule D Tax Worksheet line for it is literally “Multiply line 39 by 25% (0.25)”. Take the case L sale: $40,000 of depreciation, a marginal bracket that would otherwise take 35 percent of it, and the ceiling holds the tax on that layer to $10,000 instead of $14,000. On the home-office example in Publication 523, Logan “must recognize $2,000 of the gain as unrecaptured section 1250 gain” and “may exclude the remaining $11,000 of the gain”. Two thousand dollars that no ceiling can touch, at a flat quarter.
Nonqualified Use: the Years After 2008 It Was Not a Home
For homes bought after 2008 there is a second leak. Section 121(b)(5)(A): “Subsection (a) shall not apply to so much of the gain from the sale or exchange of property as is allocated to periods of nonqualified use.” The allocation is a ratio, 121(b)(5)(B): “the aggregate periods of nonqualified use during the period such property was owned by the taxpayer, bears to (ii) the period such property was owned by the taxpayer.”
Three periods are carved out of that ratio, and the biggest one is the one investors keep getting wrong. Any stretch after you last lived there is not nonqualified use: “any portion of the 5-year period described in subsection (a) which is after the last date that such property is used as the principal residence of the taxpayer or the taxpayer’s spouse”, 121(b)(5)(C)(ii)(I). Neither is depreciation recapture money: “Gain from depreciation for periods after May 6, 1997, isn’t taken into account to determine gain from nonqualified use.” And the order matters, because 121(b)(5)(D) says subparagraph (A) applies “after the application of subsection (d)(6)” and the ratio is applied “without regard to any gain to which subsection (d)(6) applies”. The panel does exactly that: basis first, depreciation out of what is left, then the ratio.
The publication measures the ratio in days: “Enter the total number of days after 2008 and before the date of sale that neither you nor your spouse (or former spouse) used the entire home as a main residence.” The panel asks for whole months instead, because that is how a lease and a closing statement read, and it takes whatever you enter as already meeting those three conditions.
Publication 523’s Finley example is the test case, and this engine reproduces it to the dollar. Bought for $400,000, rented for 24 months with $20,000 of depreciation, lived in for 24 months, sold for $700,000: gain $320,000, depreciation layer $20,000, and the publication says “Finley allocates 40% (2/5, or 2 years out of 5) of the remaining $300,000 gain, or $120,000, to nonqualified use”, which this panel computes as $120,000. What survives is $180,000, the exclusion covers all of it, and $140,000 is left to tax, of which $20,000 is the depreciation at 25 percent and $70,000 is the part of the ceiling the publication describes as “The balance of the $250,000 exclusion can’t be used.” That last sentence is the point of the whole paragraph: an exclusion you cannot reach does not roll forward.
Case N, the Taylor example in the same publication, runs the opposite way and shows why the field is worth filling in honestly. There the rental period came after Taylor last lived in the home, so it is not nonqualified use at all: $0 allocated, and only the $27,000 of depreciation escapes the exclusion.
Married, but Only One of You Made the Use Test
When a joint return fails 121(b)(2)(A) because one spouse did not live there, the ceiling is not $250,000 flat:
“If such spouses do not meet the requirements of subparagraph (A), the limitation under paragraph (1) shall be the sum of the limitations under paragraph (1) to which each spouse would be entitled if such spouses had not been married. For purposes of the preceding sentence, each spouse shall be treated as owning the property during the period that either spouse owned the property.” 26 U.S.C. 121(b)(2)(B)
So each spouse is measured alone on use, both are credited with the shared ownership, and the two answers are added. Case G, where one spouse used the home for the full five years and the other for 10 months, is $250,000 plus $250,000 x 10 / 24 = $354,166, not $500,000 and not $250,000.
Widowed: the Joint Ceiling Without a Spouse
Two provisions work together here. 121(b)(4) gives the $500,000 ceiling to “an unmarried individual whose spouse is deceased on the date of such sale” when the sale happens “not later than 2 years after the date of death of such spouse”, and 121(d)(2) supplies the years: “the period such unmarried individual owned and used such property shall include the period such deceased spouse owned and used such property before death.”
Case F is the situation that trips people up most often: 18 months of your own ownership and use, which fails the two-year test on its own, plus a spouse’s 40 years of ownership and use before death. The periods are added, the tests pass, and the ceiling is $500,000.
The Election to Give the Exclusion Up
Nobody wants this power, but it exists, and it is the answer to a scheduling problem rather than a tax one:
“This section shall not apply to any sale or exchange with respect to which the taxpayer elects not to have this section apply.” 26 U.S.C. 121(f)
Read it next to 121(b)(3). Taking the exclusion on this sale starts a 24-month clock on the next one. If a second, larger sale is coming inside that window, the question is which sale should burn the ceiling. Case O is a $408,000 gain on a single filer: use the exclusion and the tax is $24,384 ($23,700 plus $684 of surtax). Elect out on the same sale and all $408,000 is taxed, $71,384 in total, which buys back $250,000 of ceiling for the sale that follows at a cost of $47,000. Whether that is the right trade depends entirely on the size of the second gain, which is why it is a planning decision and not a rule of thumb.
A Loss Is Not Deductible Either
When the amount realized comes in under basis, there is no tax and no deduction:
“If the number is negative (adjusted basis is greater than amount realized), you sold your home at a loss. You can’t deduct this loss, but you don’t need to pay any tax on the money you received from selling your home.” Publication 523, line 7 of Worksheet 2
Case D is that sale: a loss of $75,000, nothing excluded because nothing was gained, and $0 of tax. A personal residence is the one capital asset in the code whose losses go nowhere, which is the mirror image of the exclusion: the upside is protected up to $250,000 and the downside is not protected at all.
The Tax on Whatever the Exclusion Missed
Once a number survives the exclusion it is a capital gain, and the rate on it is not one number. It depends on how long you held the home and what else you earned that year. The stacking order, from the worksheet the IRS makes you use, is: your ordinary income fills the $0 to $49,450 band first, the long-term gain sits on top of it at 0 percent until it runs out of room in that band, then 15 percent up to $545,500 for a single filer, then 20 percent, with the depreciation layer capped at 25 percent and the short-term part taxed as wages.
Two cases that are identical except for a salary show how much that order is worth. Case J leaves $30,000 of gain taxable and only $20,000 of other income in the year, so $29,450 of the gain lands in the 0 percent band and the whole tax is $83. Case K is the same house, the same price, the same $30,000 left to tax, and $60,000 of other income: the band is already full, every dollar goes at 15 percent, and the tax is $4,500. A $40,000 difference in wages, and the gain costs 54 times as much.
Two more things sit on top of that. Hold the home for 12 months or less and there is no preferential rate at all: case H owned for 9 months, and its $100,250 is taxed as ordinary income, $33,701. And above the modified adjusted gross income thresholds, section 1411 adds 3.8 percent of the gain you did not exclude. Its thresholds are $250,000 on a joint return, $200,000 single or head of household and $125,000 married filing separately, and like the $250,000 ceiling they are written in the statute, so they are the same 2026 as they were in 2013. Case O clears it by $18,000 and pays $684. The excluded part of the gain is not investment income, so the surtax only ever touches whatever the exclusion missed.
Capital Gains on a Home Sale Calculator (2026)
Works out your section 121 exclusion first, then the tax on whatever the exclusion cannot cover. Fill in the months, then the money.
The two-year tests
The money
Your income for the year of the sale
Eligibility follows 26 U.S.C. 121(a), (b)(1), (b)(2), (b)(3), (b)(4), (b)(5) and (c), and the order of Publication 523 (2025 edition) Worksheets 1, 2 and 3. Rates, the 0 and 15 percent gain ceilings and the standard deductions are 2026 figures from IRS Rev. Proc. 2025-32. Federal tax only: your state may tax the same gain differently. Figures checked against those documents on 14 October 2026. Educational tool, not personal tax advice.
The 2026 Numbers in One Table
Every figure the panel holds, with the two ceilings and the surtax thresholds added. The gain bands are the section 1(j)(5)(B) amounts for 2026 from Rev. Proc. 2025-32 section 4.03; a widowed filer uses the single rate table and the standard deduction of $16,100, but the joint ceiling of $500,000 if the sale is within two years of the death.
| Filing status for the year of the sale | Standard deduction, 2026 | Top of the 0% gain band | Top of the 15% gain band | Section 121 ceiling | Income where the 3.8% surtax starts |
|---|---|---|---|---|---|
| Single | $16,100 | $49,450 | $545,500 | $250,000 | $200,000 |
| Head of household | $24,150 | $66,200 | $579,600 | $250,000 | $200,000 |
| Widowed, not remarried | $16,100 | $49,450 | $545,500 | $500,000 | $200,000 |
| Married filing jointly | $32,200 | $98,900 | $613,700 | $500,000 | $250,000 |
| Married filing separately | $16,100 | $49,450 | $306,850 | $250,000 | $125,000 |
Fifteen Situations, Worked
These are the rows the engine above produced, and each one is a different reader’s question. Case M and case N are Publication 523’s own Finley and Taylor examples, included precisely so the arithmetic can be checked against something outside this page.
| Case | The situation | Gain on the sale | Exclusion ceiling | Gain excluded | Gain left to tax | Federal tax on the sale |
|---|---|---|---|---|---|---|
| A | Own 40 months, lived in it 14, sold for a job move | $36,000 | $145,833 | $36,000 | $0 | $0 |
| B | Married filing jointly, both lived in it 5 years, $253,400 gain | $253,400 | $500,000 | $253,400 | $0 | $0 |
| C | Two years rented out before you moved in, then sold | $262,000 | $250,000 | $120,000 | $142,000 | $22,916 |
| D | Sold for less than it cost you | Loss of $75,000 | $250,000 | $0 | $0 | $0 |
| E | 11 months of use, no qualifying reason | $194,000 | $0 | $0 | $194,000 | $36,472 |
| F | Widowed, still in the home, 18 months of your own use | $253,400 | $500,000 | $253,400 | $0 | $0 |
| G | Joint return, but only one spouse meets the use test | $253,400 | $354,166 | $253,400 | $0 | $0 |
| H | 9 months from closing to selling | $194,000 | $93,750 | $93,750 | $100,250 | $37,511 |
| I | 20 months of use, gain under the reduced ceiling | $194,000 | $208,333 | $194,000 | $0 | $0 |
| J | $20,000 of other income, $30,000 of gain left over | $280,000 | $250,000 | $250,000 | $30,000 | $83 |
| K | The same sale, $60,000 of other income | $280,000 | $250,000 | $250,000 | $30,000 | $4,500 |
| L | Depreciation above the exclusion, in the 35% band | $360,000 | $250,000 | $250,000 | $110,000 | $24,680 |
| M | Publication 523’s Finley example | $320,000 | $250,000 | $180,000 | $140,000 | $15,735 |
| N | Publication 523’s Taylor example | $227,000 | $250,000 | $200,000 | $27,000 | $2,992 |
| O | A $700,000 sale, $408,000 of gain, filed single | $408,000 | $250,000 | $250,000 | $158,000 | $24,384 |
Case A, case I and case B all end with $0 of tax on real gains, and they get there by three different routes: a reduced exclusion that still covers the gain, a joint ceiling that swallows it, and a two-year test that passed outright. Case E is the opposite: 11 months of use, no qualifying event, and $194,000 fully exposed. The difference between a good outcome and a bad one on this page is rarely the price.
What You File, and What You Keep
Publication 523 splits the paperwork across three worksheets: “Figure your maximum exclusion, using Worksheet 1, Determine if you have a gain or loss on the sale or exchange of your home, using Worksheet 2, Figure how much of any gain is taxable (if any) using Worksheet 3”. The panel follows the same order: eligibility, then basis and gain, then depreciation and nonqualified use, then rates.
A zero tax is not always a zero filing. “You received a Form 1099-S. If so, you must report the sale on Form 8949 even if you have no taxable gain to report.” The settlement statement usually generates that form, so a fully excluded sale still appears on the return; it just appears with the exclusion as the adjustment. Keep the purchase contract, the improvement invoices and the depreciation records: “In general, keep these records until 3 years after the due date for your tax return for the year in which you sold your home.” The three-year clock is measured from the due date, not the sale date, so the records for a 2026 sale are worth keeping into 2030.
What This Page Does Not Settle
- State tax. The panel is federal only. Most states tax a home sale the way they tax any other capital gain, several let you subtract the same federal exclusion, and a few do neither, so a sale this tool reports as fully excluded can still draw a state bill. Check the state you file in.
- Repairs versus improvements. Only additions, roofs, decks, fencing and similar capital work raise basis. Maintenance does not, and the line between them is the most common argument on an audited sale.
- Business portions of the property. If part of the land or a separate structure was used for business, Publication 523 wants the residence and business portions calculated on separate copies of Worksheet 2, and Form 4797 comes into it.
- Installment sales and 1031 exchanges. A seller-financed sale spreads the gain over years; an exchange on investment property defers it. Neither is what this panel does.
- Your actual return. This is arithmetic, not advice, and a preparer with the closing statement can usually confirm it in one line.
Sources
- 26 U.S.C. 121, exclusion of gain from sale of principal residence: (a) the two tests, (b)(1) and (b)(2)(A) and (B) the ceilings, (b)(3) the one sale every two years, (b)(4) the surviving spouse, (b)(5) nonqualified use and its exceptions, (c) the reduced exclusion, (d)(2) and (d)(3) the periods credited from a spouse, (d)(6) the depreciation carve-out, and (f) the election out
- IRS Publication 523, Selling Your Home: the 24-month and 730-day tests, the requirement that each spouse meet the use test, the 50 mile job move, the partial exclusion worksheet, line 5a of Worksheet 2, the loss rule, the Form 1099-S reporting rule, the three year record period, and the Finley, Taylor and Logan examples this page reproduces
- Instructions for Schedule D (Form 1040): the Unrecaptured Section 1250 Gain Worksheet feeding Schedule D line 19, and line 40 of the Schedule D Tax Worksheet: “Multiply line 39 by 25% (0.25)”
- IRS Rev. Proc. 2025-32: the 2026 rate tables in section 4.01, the 0 percent and 15 percent gain ceilings in section 4.03, and the 2026 standard deductions in section 4.14
- 26 U.S.C. 1411, unearned income contribution to net investment income tax: the 3.8 percent rate and the thresholds of $250,000, $200,000 and $125,000, which the section does not index for inflation
Next step: Run your own sale through the panel, then run it a second time with the last question answered Yes and 0 months, which is how the tool reaches a sale with no exclusion at all. The gap between those two totals is what section 121 is worth to you in dollars; take both numbers and the closing statement to a preparer before you sign anything.
Related guides
Whether a sale is taxable is a section 121 question, and how heavily is a stacking question. These are the pages that carry the rest of each answer.
- Qualified Dividends and Capital Gain Tax WorksheetThe stacking order that sets the rate on whatever the exclusion misses, line by line.
- Avoid Capital Gains Tax on Inherited PropertyA basis step-up does the same job as an exclusion, on a house you did not live in.
- Do Net Operating Losses Offset Capital Gains?When a business loss eats a gains year, and the 80 percent wall on how far it can go.
- Travel Nurse Tax Home: The 2026 RulesWhich home is your main home when you spend the year on contract somewhere else.
- Maryland vs Virginia TaxesThe state side of the same sale, because this calculator is federal only.
- Pennsylvania Capital Gains Tax in 2026Pennsylvania runs its own version of this exclusion, it is not capped at 250,000, and the state's four tests are not the federal two
- New Jersey Capital Gains Tax in 2026New Jersey exempts up to 250,000 of gain on a principal residence, or 500,000 on a joint return, but everything above that is taxed as ordinary income
- Are Social Security Benefits Taxed in 2026? The 85 Percent WorksheetA home sale gain goes into the same worksheet, so the year you sell can move benefits from the half tier to the 85 percent tier.
