Capital Gains Tax on a Home Sale: The IRC §121 Exclusion and a Calculator

Generally, up to $250,000 of the gain on the sale of a main home can be excluded from income, or up to $500,000 on a joint return, if the ownership and use tests are met (26 U.S.C. 121; IRS Topic no. 701). The calculator below subtracts adjusted basis from the amount realized, applies that exclusion for the answers you tick, and shows the taxable gain. For the federal tax rate on a taxable gain, use the capital gains tax calculator.

Maintained by Archie Chang · Reviewed November 3, 2026 · Methodology & sources

Not tax advice. FedRateCalc is independent and is not affiliated with the Internal Revenue Service, the U.S. Congress or any state tax office; each agency’s own site is authoritative. The calculator follows the IRS worksheets for the common case only. Special rules, such as rental or business use of the home, can change the result, so the IRS publication and the statute quoted below are the reference for a particular sale.

Your home sale

$
$
$

The starting numbers are an example, not a recommendation. Replace them with yours.

Gain and taxable gain, as the IRS worksheets describe them

Taxable gain after the exclusion

$20,000.00

Unmarried or married filing separately: $250,000 (26 U.S.C. 121(b)(1)).

Gain and exclusion, line by line
Selling price$600,000.00
Less selling expenses($30,000.00)
Amount realized$570,000.00
Less adjusted basis($300,000.00)
Gain or (loss)$270,000.00
Exclusion limit that applies$250,000.00
Exclusion used (not more than the gain)($250,000.00)
Taxable gain$20,000.00

The exclusion in IRS and statute words

IRS Topic no. 701 states the amounts and the two tests, and 26 U.S.C. 121(a) states the rule:

“If you have a capital gain from the sale of your main home, you may qualify to exclude up to $250,000 of that gain from your income, or up to $500,000 of that gain if you file a joint return with your spouse.”
IRS, Topic no. 701, Sale of your home
“In general, to qualify for this exclusion, you must meet both the ownership test and the use test. If you are filing jointly with your spouse, either you or your spouse must meet the ownership test while both you and your spouse must meet the use test individually.”
IRS, Topic no. 701, Sale of your home
“If you or your spouse owned the home for at least 24 months (2 years) out of the last 5 years leading up to the date of the sale, you meet the ownership test. If you and your spouse used the home as a residence for at least 24 months (2 years) of the previous 5 years, you meet the use test. You can meet the ownership and use tests during different 2-year periods. However, you must meet both tests during the 5-year period ending on the date of the sale.”
IRS, Topic no. 701, Sale of your home
“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 (uscode.house.gov, text current through Public Law 119-136, October 22, 2026)
“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 (uscode.house.gov, text current through Public Law 119-136, October 22, 2026)
“If you meet certain conditions, you may exclude the first $250,000 of gain from the sale of your home from your income and avoid paying taxes on it. The exclusion is increased to $500,000 for a married couple filing jointly.”
IRS, Publication 523 (2025), Selling Your Home

Ownership, residence and the once-every-2-years rule

Publication 523 (2025) takes the tests one step at a time. The ownership test:

“Determine whether you meet the ownership requirement. 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. For a married couple filing jointly, only one spouse has to meet the ownership requirement.”
IRS, Publication 523 (2025), Selling Your Home

The residence (use) test, with the absences that count. The text between the two parts of the quote is left out here:

“Determine whether you meet the residence requirement. If you owned the home and used it as your residence for at least 24 months of the previous 5 years, you meet the residence requirement. The 24 months of residence can fall anywhere within the 5-year period, and it doesn't have to be a single block of time. All that is required is a total of 24 months (730 days) of residence during the 5-year period. Unlike the ownership requirement, each spouse must meet the residence requirement individually for a married couple filing jointly to get the full exclusion. […] A vacation or other short absence counts as time you lived at home (even if you rented out your home while you were gone). If you become physically or mentally unable to care for yourself, and you used the residence as your main home for at least 12 months in the 5 years preceding the sale or exchange, any time you spent living in a care facility (such as a nursing home) counts toward your 2-year residence requirement, so long as the facility has a license from a state or other political entity to care for people with your condition.”
IRS, Publication 523 (2025), Selling Your Home

The look-back rule, in Publication 523 (2025), in Topic no. 701 and in the statute:

“Determine whether you meet the look-back requirement. If you didn't sell another home during the 2-year period before the date of sale (or if you did sell another home during this period but didn't take an exclusion of the gain earned from it), you meet the look-back requirement. You may take the exclusion only once during a 2-year period.”
IRS, Publication 523 (2025), Selling Your Home
“Generally, you're not eligible for the exclusion if you excluded the gain from the sale of another home during the two-year period prior to the sale of your home. Refer to Publication 523 for the complete eligibility requirements, limitations on the exclusion amount, and exceptions to the two-year rule.”
IRS, Topic no. 701, Sale of your home
“(3) Application to only 1 sale or exchange every 2 years | 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 (uscode.house.gov, text current through Public Law 119-136, October 22, 2026) A vertical bar in a quotation marks a line break in the source.

Publication 523 (2025) also lists exceptions to the eligibility test:

“There are some exceptions to the Eligibility Test. If any of the following situations apply to you, read on to see if they may affect your qualification. If none of these situations apply, skip to Step 6. […]”
IRS, Publication 523 (2025), Selling Your Home

The bulleted situations continue in Publication 523 (2025); the first three are a separation or divorce, the death of a spouse and service as a service member during the ownership of the home. The calculator uses only the checkboxes above and does not apply those exceptions.

Joint returns and surviving spouses

The $500,000 limit has conditions, and the statute gives a different result when they are not all met:

“In the case of a husband and wife who make a joint return for the taxable year of the sale or exchange of the property— | (A) $500,000 Limitation for certain joint returns | Paragraph (1) shall be applied by substituting “$500,000” for “$250,000” if— | (i) 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; and | (iii) neither spouse is ineligible for the benefits of subsection (a) with respect to such property by reason of paragraph (3).”
26 U.S.C. 121 (uscode.house.gov, text current through Public Law 119-136, October 22, 2026) A vertical bar in a quotation marks a line break in the source.
“(B) Other joint returns | 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 (uscode.house.gov, text current through Public Law 119-136, October 22, 2026) A vertical bar in a quotation marks a line break in the source.
“(4) Special rule for certain sales by surviving spouses | In the case of a sale or exchange of property by an unmarried individual whose spouse is deceased on the date of such sale, paragraph (1) shall be applied by substituting “$500,000” for “$250,000” if such sale occurs not later than 2 years after the date of death of such spouse and the requirements of paragraph (2)(A) were met immediately before such date of death.”
26 U.S.C. 121 (uscode.house.gov, text current through Public Law 119-136, October 22, 2026) A vertical bar in a quotation marks a line break in the source.

The calculator follows these three paragraphs: the joint $500,000 when the spouse answers are all ticked, the sum of each spouse’s own limit when they are not, and $500,000 for a surviving spouse only when the one extra box is ticked. For a surviving spouse, the statute and Publication 523 (2025) let the late spouse’s time count toward the tests, and the checkboxes are worded that way:

“(2) Property of deceased spouse | For purposes of this section, in the case of an unmarried individual whose spouse is deceased on the date of the sale or exchange of property, the period such unmarried individual owned and used such property shall include the period such deceased spouse owned and used such property before death.”
26 U.S.C. 121 (uscode.house.gov, text current through Public Law 119-136, October 22, 2026) A vertical bar in a quotation marks a line break in the source.
“If you are a surviving spouse who doesn't meet the 2-year ownership and residence requirements on your own, consider the following rule. If you haven’t remarried at the time of the sale, then you may include any time when your late spouse owned and lived in the home, even if without you, to meet the ownership and residence requirements. Also, you may be able to increase your exclusion amount from $250,000 to $500,000. You may take the higher exclusion if you meet all of the following conditions. 1. You sell your home within 2 years of the death of your spouse. 2. You haven’t remarried at the time of the sale. 3. Neither you nor your late spouse took the exclusion on another home sold less than 2 years before the date of the current home sale. 4. You meet the 2-year ownership and residence requirements (including your late spouse‘s times of ownership and residence, if applicable).”
IRS, Publication 523 (2025), Selling Your Home

Gain or loss

Publication 523 (2025) describes the arithmetic the calculator uses, and what happens to a loss:

“To figure the gain or loss on the sale of your main home, you must know the selling price, the amount realized, and the adjusted basis. Subtract the adjusted basis from the amount realized to get your gain or loss. | Selling price | − Selling expenses | Amount realized | − Adjusted basis | Gain or loss | A positive number indicates a gain; a negative number indicates a loss.”
IRS, Publication 523 (2025), Selling Your Home A vertical bar in a quotation marks a line break in the source.
“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. Skip to Reporting Your Home Sale, later. • If the number is positive, you sold your home at a gain. Skip to How Much Is Taxable, later, to see if Worksheet 3 is required. If this is your separate worksheet for business use, don’t follow guidance on line 7. Report the gain on Form 4797 because this gain is not excluded under section 121.”
IRS, Publication 523 (2025), Selling Your Home

The adjusted basis is an entry. The calculator does not work out basis, which Publication 523 (2025) does on Worksheet 2, and it uses selling expenses and adjusted basis as entered.

What the calculator ignores

The calculator does not figure depreciation recapture. For gain up to the depreciation adjustments after May 6, 1997, the statute says the exclusion does not apply:

“(6) Recognition of gain attributable to depreciation | 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 (uscode.house.gov, text current through Public Law 119-136, October 22, 2026) A vertical bar in a quotation marks a line break in the source.

It also ignores nonqualified use, the periods after 2008 when a home was not a main home, which the statute treats this way:

“(5) Exclusion of gain allocated to nonqualified use | (A) In general | 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.”
26 U.S.C. 121 (uscode.house.gov, text current through Public Law 119-136, October 22, 2026) A vertical bar in a quotation marks a line break in the source.
“(C) Period of nonqualified use | For purposes of this paragraph— | (i) In general | The term “period of nonqualified use” means any period (other than the portion of any period preceding January 1, 2009) during which the property is not used as the principal residence of the taxpayer or the taxpayer’s spouse or former spouse. | (ii) Exceptions | The term “period of nonqualified use” does not include— | (I) 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, | (II) any period (not to exceed an aggregate period of 10 years) during which the taxpayer or the taxpayer’s spouse is serving on qualified official extended duty (as defined in subsection (d)(9)(C)) described in clause (i), (ii), or (iii) of subsection (d)(9)(A), and | (III) any other period of temporary absence (not to exceed an aggregate period of 2 years) due to change of employment, health conditions, or such other unforeseen circumstances as may be specified by the Secretary.”
26 U.S.C. 121 (uscode.house.gov, text current through Public Law 119-136, October 22, 2026) A vertical bar in a quotation marks a line break in the source.

It does not compute a partial exclusion (also called a reduced exclusion) for a sale made because of a job change, health or unforeseen circumstances. The statute and Publication 523 (2025) say:

“(1) In general | In the case of a sale or exchange to which this subsection applies, the ownership and use requirements of subsection (a), and subsection (b)(3), shall not apply; but the dollar limitation under paragraph (1) or (2) of subsection (b), whichever is applicable, shall be equal to— | (A) the amount which bears the same ratio to such limitation (determined without regard to this paragraph) as | (B) (i) the shorter of— | (I) the aggregate periods, during the 5-year period ending on the date of such sale or exchange, such property has been owned and used by the taxpayer as the taxpayer’s principal residence; or | (II) the period after the date of the most recent prior sale or exchange by the taxpayer to which subsection (a) applied and before the date of such sale or exchange, bears to | (ii) 2 years. | (2) Sales and exchanges to which subsection applies | This subsection shall apply to any sale or exchange if— | (A) subsection (a) would not (but for this subsection) apply to such sale or exchange by reason of— | (i) a failure to meet the ownership and use requirements of subsection (a), or | (ii) subsection (b)(3), and | (B) such sale or exchange is by reason of a change in place of employment, health, or, to the extent provided in regulations, unforeseen circumstances.”
26 U.S.C. 121 (uscode.house.gov, text current through Public Law 119-136, October 22, 2026) A vertical bar in a quotation marks a line break in the source.
“If you don't meet the Eligibility Test, you may still qualify for a partial exclusion of gain. You can meet the requirements for a partial exclusion if the main reason for your home sale was a change in workplace location, a health issue, or an unforeseeable event.”
IRS, Publication 523 (2025), Selling Your Home
“Step 3 Multiply the result from Step 2 by $250,000. This is the amount of your reduced exclusion. For married filing jointly, continue to step 4.”
IRS, Publication 523 (2025), Selling Your Home

It does not apply the election to suspend the 5-year period for qualified official extended duty. The statute and Topic no. 701 say:

“(9) Uniformed services, Foreign Service, and intelligence community | (A) In general | At the election of an individual with respect to a property, the running of the 5-year period described in subsections (a) and (c)(1)(B) and paragraph (7) of this subsection with respect to such property shall be suspended during any period that such individual or such individual’s spouse is serving on qualified official extended duty— | (i) as a member of the uniformed services, | (ii) as a member of the Foreign Service of the United States, or | (iii) as an employee of the intelligence community. | (B) Maximum period of suspension | The 5-year period described in subsection (a) shall not be extended more than 10 years by reason of subparagraph (A).”
26 U.S.C. 121 (uscode.house.gov, text current through Public Law 119-136, October 22, 2026) A vertical bar in a quotation marks a line break in the source.
“If you or your spouse are on qualified official extended duty in the Uniformed Services, the Foreign Service or the intelligence community, you may elect to suspend the five-year test period for up to 10 years.”
IRS, Topic no. 701, Sale of your home

It does not apply the automatic disqualifiers that Publication 523 (2025) lists before the other tests:

“Determine whether any of the automatic disqualifications apply. Your home sale isn’t eligible for the exclusion if ANY of the following are true. • You acquired the property through a like-kind exchange (section 1031 exchange) during the past 5 years. See Pub. 544, Sales and Other Dispositions of Assets. • You are subject to expatriate tax. For more information about expatriate tax, see chapter 4 of Pub. 519, U.S. Tax Guide for Aliens. If any of these conditions are true, the exclusion doesn’t apply. Skip to Figuring Gain or Loss, later.”
IRS, Publication 523 (2025), Selling Your Home

It does not model installment sales. Topic no. 701 says the exclusion stays available with that method:

“If you sold your home under a contract that provides for all or part of the selling price to be paid in a later year, you made an installment sale. If you have an installment sale, report the sale under the installment method unless you elect out. Even if you use the installment method to defer some of the gain, the exclusion of gain on the sale of your home remains available.”
IRS, Topic no. 701, Sale of your home

It does not figure any state income tax on a taxable gain, and it does not apply the other special rules in Publication 523 (2025).

Rounding to whole dollars

The calculator keeps every amount to the cent. The Form 1040 instructions allow rounding the whole return to dollars:

“You can round off cents to whole dollars on your return and schedules. If you do round to whole dollars, you must round all amounts. To round, drop amounts under 50 cents and increase amounts from 50 to 99 cents to the next dollar. For example, $1.39 becomes $1 and $2.50 becomes $3. If you have to add two or more amounts to figure the amount to enter on a line, include cents when adding the amounts and round off only the total. If you are entering amounts that include cents, make sure to include the decimal point.”
IRS, 2025 Instructions for Form 1040, Rounding Off to Whole Dollars

Rounding to whole dollars changes the taxable gain whenever its cents are not zero: a taxable gain of $0.49 rounds to $0, and $0.50 rounds to $1. The calculator adds up the cents first and shows the whole-dollar figure for the total only, as that rule describes. If amounts are rounded one by one before they are subtracted, the result can differ by $1 from rounding only the total: proceeds of $100.50 round to $101 and a basis of $50.49 rounds to $50, a gain of $51, while the unrounded gain of $50.01 rounds to $50. That is the site’s own arithmetic with the whole-dollar rule above; the saved instructions do not say which lines of which forms are added or subtracted.

Frequently asked questions

How much of the gain on a home sale can be excluded from income?

Generally up to $250,000, or up to $500,000 if the sellers file a joint return and meet the conditions for it, when the ownership and use tests are met. IRS Topic no. 701 says a person “may qualify to exclude up to $250,000 of that gain from your income, or up to $500,000 of that gain if you file a joint return with your spouse.” 26 U.S.C. 121(b) sets the same limits, and 121(b)(3) bars the exclusion for a sale if another sale in the prior 2 years used it.

What are the ownership and use tests for the home sale exclusion?

IRS Topic no. 701 says to qualify “you must meet both the ownership test and the use test”: owned the home for at least 24 months (2 years) out of the last 5 years, and used it as a residence for at least 24 months of the previous 5 years, both within the 5-year period ending on the date of the sale. On a joint return either spouse must meet the ownership test, while both spouses must meet the use test individually.

Can the home sale exclusion be used more than once?

Generally not for two sales within 2 years. Publication 523 (2025) says “You may take the exclusion only once during a 2-year period”, and 26 U.S.C. 121(b)(3) says the exclusion does not apply to a sale if, during the 2-year period ending on the date of that sale, there was another sale to which it applied. However, 26 U.S.C. 121(c) allows a reduced exclusion, without the ownership and use requirements or 121(b)(3), for a sale made “by reason of a change in place of employment, health, or, to the extent provided in regulations, unforeseen circumstances”. Publication 523 (2025) also lists exceptions to the eligibility test, such as a separation, divorce or the death of a spouse.

What if a home is sold at a loss?

Publication 523 (2025) says that if adjusted basis is greater than the 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.” For the separate worksheet for business use, Publication 523 (2025) says not to follow that guidance and to report the gain on Form 4797, because that gain is not excluded under section 121.

What if the ownership and use tests are not both met?

A reduced (partial) exclusion may apply. 26 U.S.C. 121(c) allows a reduced limit for a sale “by reason of a change in place of employment, health, or, to the extent provided in regulations, unforeseen circumstances”, and Publication 523 (2025) says a partial exclusion may be available if the main reason for the sale was a change in workplace location, a health issue, or an unforeseeable event. The calculator does not compute a reduced exclusion; Publication 523 (2025), Worksheet 1, shows how the IRS figures it.

Does the exclusion cover gain from depreciation or from time the home was not a main home?

Not in full. 26 U.S.C. 121(d)(6) says the exclusion does not apply to gain up to the depreciation adjustments attributable to periods after May 6, 1997, and 121(b)(5) says it does not apply to gain allocated to periods of nonqualified use, subject to the exceptions in 121(b)(5)(C)(ii). The calculator ignores both, so a sale with rental or business use needs Publication 523 (2025), Worksheets 2 and 3.

Related pages

Capital gains tax calculator for the federal rates on a taxable gain, IRS notices if a letter arrives about a sale, and inheritance tax for property received from an estate.

Sources

Every quotation here is what the documents below said when we checked on November 3, 2026. Where a host did not answer plain requests, the link is to the agency’s page and the quotes come from the Internet Archive copy named next to it.

30 quotations on this page are word for word from these sources.