You sold your house for more than you paid for it, and now the question arrives: how much of that profit will the IRS take? For many homeowners the answer is "none of it," because federal law lets you exclude a large slice of the gain on the sale of your main home. The rule is known as the Section 121 exclusion (after section 121 of the Internal Revenue Code), or simply the home sale exclusion.

The exclusion is not automatic, though. You have to pass specific tests, you have to measure the gain correctly (which means knowing your adjusted basis, not just your purchase price), and in some situations you still have to report the sale even when you owe nothing. Rental use, a home office, an inherited property or a recent divorce can each change the math.

This guide walks through the rules as the IRS describes them, shows how to compute your gain step by step, and gives hypothetical examples with round numbers. It is written for U.S. homeowners; state taxes are separate and vary. Thresholds and amounts are quoted from the IRS pages named in the Sources section, with the year or date each page shows.

What the Section 121 exclusion does

According to IRS Topic no. 701 (page last reviewed October 12, 2026), 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 if you file a joint return with your spouse. Publication 523, Selling Your Home, provides the full rules and worksheets.

Three ideas are worth fixing in your mind before going further:

  • It applies to gain, not to the sale price. You are excluding profit. A home sold for $900,000 does not make $900,000 taxable; only the gain (explained below) is in play.
  • It applies only to your main home. Publication 523 says an individual has only one main home at a time. A second home, vacation property or rental does not qualify on its own (more on that later).
  • It is a maximum, not a guarantee. If your gain is smaller than the limit, the whole gain is excluded. If it is larger, only the excess is taxable. If you fail one of the tests, you may get a smaller (partial) exclusion or none.

A single-family house, a condominium, a cooperative apartment, a mobile home and a houseboat can each be a main home, according to Publication 523.

The four checks: ownership, use, look-back and the maximum

To qualify for the maximum exclusion, Publication 523 sets out an "Eligibility Test." In practice it comes down to four checks, summarized in the figure below and explained in order afterward.

The Section 121 home sale exclusion at a glance: ownership test, use test, look-back period and the maximum exclusion
Four checks for the home sale exclusion

1. The ownership test

You meet the ownership test if you owned the home for at least 24 months (2 years) out of the 5 years leading up to the date of sale. Publication 523 treats the closing as the date of sale. For a married couple filing jointly, only one spouse has to meet the ownership requirement.

2. The use test

You meet the use test if you lived in the home as your residence for at least 24 months of the previous 5 years. Those 24 months can fall anywhere in the 5-year window and do not have to be one continuous block; Publication 523 describes the requirement as a total of 24 months (730 days). The ownership and use periods can also be different 2-year periods, as long as both tests are met within the same 5-year period ending on the sale date.

Unlike ownership, the use test must be met by each spouse individually when a married couple files jointly and wants the full $500,000.

Short absences such as vacations count as time lived at home, even if you rented the home out while you were gone. Publication 523 also says that if you become physically or mentally unable to care for yourself and used the home as your main home for at least 12 months in the 5 years before the sale, time spent in a licensed care facility counts toward the 2-year use requirement.

3. The look-back

Generally, you are not eligible if you excluded the gain from the sale of another home during the two-year period before the sale of this one. Publication 523 puts it this way: you may take the exclusion only once during a 2-year period. Selling another home in that window without taking an exclusion on it does not trigger the limit.

4. The maximum exclusion

If you pass the tests, the maximum is $250,000 for most filers and $500,000 for a married couple filing jointly. The IRS worksheet in Publication 523 lays it out like this:

Filing situationWhat has to be trueMaximum
Single, or married filing separatelyYou meet the ownership, use and look-back requirements$250,000
Married filing jointlyBoth spouses meet the use and look-back requirements, and at least one meets the ownership requirement$500,000
Surviving spouseYou sell within 2 years of your spouse's death, have not remarried, neither of you took the exclusion on another home sold less than 2 years earlier, and you meet the 2-year ownership and use tests (counting your late spouse's periods where applicable)$500,000

If a married couple does not qualify for $500,000, the worksheet tells you to check whether either spouse is eligible for the single limit, and if not, whether either is eligible for a partial exclusion.

Two automatic disqualifications are worth knowing. According to Publication 523, the exclusion is not available if you acquired the home through a like-kind (Section 1031) exchange within the past 5 years, or if you are subject to the expatriate tax.

Special situations that change the clock

Publication 523 lists several exceptions to the basic tests. Check the publication for the details of your case; here is the short version.

  • Divorce or separation. If your spouse or former spouse is allowed to live in the home under a divorce or separation instrument and uses it as a main home, you can treat the home as your residence during that time. If the home was transferred to you by a spouse or ex-spouse, you can count their ownership time as yours, though you must meet the use requirement on your own. A transfer to a spouse or ex-spouse as part of a divorce settlement is generally treated as producing no gain or loss.
  • Death of a spouse. A surviving spouse who has not remarried can add the late spouse's ownership and use time, and may qualify for the $500,000 limit if the sale happens within 2 years of the death (see the table above).
  • Military, Foreign Service, intelligence community and Peace Corps. You may choose to suspend the 5-year test period for up to 10 years while on qualified official extended duty. That generally means more than 90 days (or an indefinite period) at a duty station at least 50 miles from your main home, or living in government housing under government orders. You can suspend the period for only one property at a time. Publication 523 contains worked examples.
  • Vacant land next to the home. Land sold within 2 years of the house can be treated as part of the home sale if you owned and used it as part of your home and both sales qualify; the two sales are then treated as one transaction, so the exclusion is applied only once.
  • Which home is your main home. If you have more than one home, the IRS applies a "facts and circumstances" test. The most important factor is where you spend the most time, but it also looks at the address on your driver's license, voter registration and tax returns, and how close the home is to your job, bank and family.

When you fail the tests: the partial exclusion

If you do not meet the full Eligibility Test, you may still qualify for a reduced maximum when the main reason for the sale was a change in workplace location, a health issue or an unforeseeable event. Publication 523 describes each category:

  • Work-related move. You took or were transferred to a new job at a work location at least 50 miles farther from the home than the old one (or you had no previous work location and started a job at least 50 miles away). The same can be true of your spouse, a co-owner or another person for whom the home was their residence.
  • Health-related move. You moved to obtain, provide or facilitate diagnosis, treatment or care of a disease, illness or injury for yourself or a family member, or a doctor recommended a change of residence because of a health problem.
  • Unforeseeable events. Examples listed include the home being destroyed or condemned, a casualty loss from a disaster, death, divorce or legal separation, multiple births from the same pregnancy, becoming eligible for unemployment compensation, or being unable to pay basic living expenses after a change in employment. Events named in IRS published guidance also count.

Even if your situation is not on those lists, Publication 523 says you may still qualify if the primary reason for the sale is work-related, health-related or unforeseeable under the facts and circumstances.

The reduced maximum is a proration. The worksheet takes the shortest of three periods (your time living in the home in the 5 years before the sale, your time owning it, and the time since you last used the exclusion on a different home), divides it by 730 days (or 24 months), and multiplies the result by $250,000. For a married couple, the calculation is repeated for the spouse and the results are added.

Hypothetical example (partial exclusion). Assume a single owner lived in a home for 12 months, then had to sell because a new job was more than 50 miles farther away, and has not used the exclusion on any other home. Twelve months divided by 24 months is one half, and one half of $250,000 is $125,000. The reduced maximum in this made-up case would be $125,000. Your own numbers depend on your exact dates; check Publication 523, Worksheet 1.

How to compute your gain

The exclusion only matters once you know whether you have a gain. Publication 523 gives the formula:

Selling price − selling expenses = amount realized. Amount realized − adjusted basis = gain (or loss).

Step 1: the amount realized

Start with the selling price (box 2 of Form 1099-S shows the gross proceeds if you received one; if box 4 is checked, the price included noncash payments that you must value and add). Then subtract your selling expenses, the costs directly tied to the sale. Publication 523 lists sales commissions, advertising fees, legal fees, mortgage points or other loan charges you paid that would normally have been the buyer's responsibility, and any other fees or costs to sell. Transfer or stamp taxes you paid as the seller are not deductible on their own, but you can treat them as selling expenses.

Step 2: the adjusted basis

Basis starts with what you paid. IRS Topic no. 703 explains that in most situations basis is your cost, and that certain events during ownership increase or decrease it, producing the "adjusted basis." Increase it by the cost of improvements that add to the value of the property, and decrease it by items such as allowable depreciation and insurance reimbursements for casualty and theft losses.

For a home you bought, adjusted basis generally means:

  • the purchase price (including your down payment and any amount you borrowed),
  • plus certain settlement fees and closing costs you paid when you bought,
  • plus the cost of capital improvements that are still part of the home,
  • plus special assessments for local improvements,
  • minus items that reduce basis, such as insurance reimbursements for casualty losses and energy credits or subsidies tied to improvements you added to basis.

Closing costs: which ones count

Generally added to basis (Publication 523)Generally not added to basis
Abstract (title) feesFire and casualty insurance premiums
Charges for installing utility servicesRent for occupancy before closing
Certain legal feesUtility charges for the period before closing
Recording feesMortgage insurance premiums and loan assumption fees
Survey feesCredit report and lender-required appraisal fees
Transfer or stamp taxesPoints and loan origination fees
Owner's title insuranceFees for refinancing a mortgage

Amounts placed in escrow for future taxes and insurance are not settlement costs for this purpose. If you refinanced during ownership, the refinancing fees are not added to basis, which is one more reason to read the guide on refinancing and break-even points before assuming a closing cost is "free" for tax purposes.

Improvements versus repairs

This is where homeowners most often leave money on the table. Publication 523 says improvements add to the value of your home, prolong its useful life or adapt it to new uses, and their cost is added to basis. The IRS chart includes a new bedroom or bathroom, a deck, garage or patio, landscaping, a new roof, new siding, a new heating or central air system, wiring, a swimming pool, a kitchen modernization, flooring and a fireplace.

Usually raises basis (improvement)Usually does not (repair or maintenance)
Adding a bathroom or a deckInterior or exterior painting
Replacing the roofFixing leaks
Installing central air conditioningFilling holes or cracks
Kitchen modernizationReplacing broken hardware
Replacing all the windows as part of one projectReplacing a single broken windowpane

The IRS notes that repair-type work done as part of an extensive remodeling or restoration is treated as part of the improvement. It also says you cannot include the cost of improvements that are no longer part of your home (for example, carpeting you installed and later replaced), and that casualty repairs restoring the home to its pre-casualty condition can increase basis, but you reduce basis by any insurance reimbursement.

A worked example (hypothetical)

The numbers below are hypothetical and chosen to be round. Assumptions: the seller is a single filer, meets the ownership, use and look-back tests, has never rented out the home or claimed depreciation, and has no other adjustments. Nothing here predicts your result.

Hypothetical example of the home sale gain: $350,000 adjusted basis, $660,000 amount realized, $310,000 gain, $250,000 excluded for a single filer and $60,000 taxable
Hypothetical example for a single filer who meets the tests
LineHypothetical amount
Purchase price$300,000
Plus capital improvements$50,000
Adjusted basis$350,000
Sale price$700,000
Minus selling costs$40,000
Amount realized$660,000
Gain ($660,000 − $350,000)$310,000
Excluded (single maximum)$250,000
Taxable gain$60,000

Notice that the seller's profit "on paper" is $400,000 ($700,000 minus $300,000), yet the taxable gain is $60,000 because of the $40,000 in selling costs, the $50,000 in improvements and the $250,000 exclusion. How much tax the $60,000 produces depends on the seller's other income and filing details; the section on capital gains rates below explains the general framework. Whether the $60,000 is reported on Form 8949 and Schedule D is covered in the reporting section.

A second hypothetical: married filing jointly

Assumptions: a married couple filing jointly, both of whom lived in the home as their main home for more than 2 of the last 5 years, with at least one spouse on the title; no use of the exclusion in the past 2 years; no rental use or depreciation. They bought for $400,000 and spent $70,000 on a kitchen and a new roof, so their adjusted basis is $470,000. They sell for $900,000 and pay $50,000 in selling costs, so the amount realized is $850,000.

Gain: $850,000 − $470,000 = $380,000. The joint maximum is $500,000, so the entire $380,000 gain is excludable and the taxable gain is $0. Because the gain is under the limit, the couple would not need to report the sale on the return unless they received a Form 1099-S or chose to report it anyway, as explained next.

Reporting the sale and how leftover gain is taxed

Reporting the sale and Form 1099-S

Topic no. 701 states that if you receive an informational document such as Form 1099-S, Proceeds From Real Estate Transactions, you must report the sale of the home even if the gain is excludable. You also must report the sale if you cannot exclude all of your gain. Publication 523 lists a third case: you choose to report a gain even though some or all of it is excludable (for example, because you expect a larger gain on another sale within two years), and it adds that you can undo that choice by filing an amended return within 3 years of the due date of the return for the year of the sale, excluding extensions.

When reporting is required, the IRS says to use Form 8949 and Schedule D (Form 1040). If none of the three conditions applies, Publication 523 says you do not need to report the home sale on your tax return. The date of sale appears in box 1 of Form 1099-S and the gross proceeds in box 2.

If you financed the buyer's purchase and receive payments over several years, you probably have an installment sale. Topic no. 701 notes that the exclusion remains available, and Publication 523 points to Form 6252 for reporting. Check the publication before assuming how a seller-financed sale works.

Short-term versus long-term gains, and the tax rates

Gain that is not excluded is a capital gain. IRS Topic no. 409 (page last reviewed September 24, 2026) explains that gain or loss is long-term if you held the asset for more than one year, and short-term if you held it for one year or less. Net short-term capital gains are taxed as ordinary income at graduated rates; net long-term gains can be taxed at lower rates.

For taxable years beginning in 2025, Topic no. 409 gives the following long-term capital gain rate thresholds based on taxable income. These adjust over time, so look up the figures for the year of your sale:

RateSingle (taxable income)Married filing jointly (taxable income)
0%$48,350 or less$96,700 or less
15%Over $48,350, up to $533,400Over $96,700, up to $600,050
20%Above the 15% thresholdAbove the 15% threshold

The same page lists exceptions with higher maximum rates, including a 25% maximum on the portion of unrecaptured section 1250 gain from selling real property, which matters if you claimed depreciation (see the next section). It also notes that losses from the sale of personal-use property, such as your home, are not tax deductible, so selling a main home below your basis does not create a deductible loss.

Finally, Topic no. 559 explains the 3.8% net investment income tax for people with net investment income above certain income thresholds. It includes net gains from selling real estate, but the page says it does not apply to the portion of gain from the sale of a principal residence that is excluded for income tax purposes. A taxable portion above the exclusion could be included, depending on your income.

Rental use, inherited homes and second homes

Rental use, a home office and depreciation

If part of your home was used for business or rented out, Publication 523 draws two lines.

Space inside your living area

If the business or rental space is within your home (a home office, a rented spare bedroom), you generally do not have to split the gain between the business and personal parts, and you do not report that part on Form 4797. However, you cannot exclude the portion of gain equal to depreciation allowed or allowable after May 6, 1997. That amount is "recaptured" and taxed instead of excluded.

The IRS gives this illustration: an attorney used part of a house exclusively as a law office and claimed $2,000 of depreciation. On a sale with a $13,000 gain, $2,000 was unrecaptured section 1250 gain (reported using Form 4797) and the remaining $11,000 could be excluded.

Space separate from the living area

For separate space such as the other unit of a duplex, a working farm or a store building with an upstairs apartment, you generally cannot exclude gain on the business or rental portion unless you owned and lived in that part for at least 2 years of the 5-year period. The IRS asks you to run separate calculations for the residential and business parts.

Turning a home into a rental, or a rental into a home

Periods after 2008 when neither you nor your spouse used the property as a main home are called "nonqualified use," and gain allocated to those periods cannot be excluded. Important exceptions in Publication 523: time after the last day you used the home as your main home (within the 5-year period before sale) is not nonqualified use, qualified official extended duty (up to 10 years) is excepted, and certain temporary absences of up to 2 years total for a change of employment, health or other unforeseen circumstances are excepted.

The IRS example involves an owner who lived in a house from 2017 through 2020, rented it from January 1, 2021 until selling it in April 2023, and could still exclude up to $250,000 because the rental period fell after the last day of use as a main home. The depreciation that was claimed or could have been claimed on the rental period could not be excluded. If you are planning to move out and rent, keep the 5-year window in mind and track depreciation. If you keep the property as an investment, our landlord bookkeeping guide covers the records you will want.

Inherited homes, gifts and other special cases

  • Inherited home. Publication 523 says that if you inherit a home, your basis is generally its fair market value on the date of the decedent's death (or an alternate valuation date chosen by the estate's personal representative). That is why the gain on a quick sale of an inherited home is often small. You can claim the Section 121 exclusion on an inherited home only if you yourself pass the tests, which generally means living in it as your main home.
  • Surviving spouse with a jointly owned home. Generally the half the late spouse owned takes a new basis at fair market value at death, while your half keeps its basis. In community property states, Publication 523 says the entire property usually gets the stepped-up basis when at least half the value is includible in the decedent's gross estate.
  • Gifted home. As a general rule you use the donor's adjusted basis, with exceptions for a donor basis higher than market value or when gift tax was paid. Keep the donor's records.
  • Home received in a divorce. Your starting basis is generally your former spouse's adjusted basis, as described in Publication 523 (with a different rule for homes acquired on or before July 18, 1984).
  • Foreclosure, repossession or abandonment. These can produce ordinary income, gain or loss. Publication 523 refers you to Publication 4681.

Second homes, investment property and the 1031 exchange

The exclusion belongs to a main home only. If you sell a vacation house or a pure investment property, you generally cannot use Section 121, and the gain is taxed as a capital gain (plus depreciation recapture if you claimed depreciation). Landlords often defer that tax with a like-kind exchange instead. Our guide to 1031 exchanges for landlords explains the mechanism.

Publication 523 notes that a main home is not itself available for a 1031 exchange, and that the two sections can interact in some cases, for example when a property acquired in a like-kind exchange is later converted to a main home (a 5-year holding period applies before the exclusion can be used) or a main home is converted to a rental. These are specialized situations where a tax professional is worth consulting.

States can tax home sale gains differently or not at all, and local rules can add transfer taxes. Check your state's revenue department for how it treats the sale of a main home.

Common mistakes and three hypothetical profiles

Common mistakes to avoid

  • Using the purchase price as the basis. Closing costs and capital improvements can raise basis; ignoring them overstates the gain.
  • Throwing away records. Without receipts and statements, improvements are hard to prove years later.
  • Assuming the exclusion is automatic. You must meet the tests, and in some cases you still have to report the sale.
  • Misreading the two-year tests. They are measured over a 5-year window and counted in months or days, and the use test applies to each spouse individually for the $500,000 limit.
  • Forgetting the look-back. An exclusion taken on another home sale in the prior 2 years can limit this one.
  • Treating repairs as improvements. Painting and routine fixes do not raise basis.
  • Ignoring depreciation. If you claimed or could have claimed depreciation after May 6, 1997, that portion is not excludable. The IRS says to adjust basis even if you did not deduct it, using the amount you could have deducted.
  • Waiting for the closing date to learn the rules. A sale a few weeks before the 2-year mark can change the outcome, so check your dates before you sign.

Three hypothetical profiles

These profiles are invented illustrations of how the rules might apply; they are not predictions for your situation.

Profile A: the long-time owner

Maria, single, has lived in her home as her main home for eight years and has not sold another home in decades. Ownership and use tests are met, no look-back issue. Her gain is compared with $250,000. If her gain were $180,000, it would be fully excluded; if it were $300,000, $50,000 would be above the limit and potentially taxable.

Profile B: the couple with one late-arriving spouse

Two partners marry and file jointly. One owned the home for years; the other moved in 14 months before the sale. Ownership is satisfied by one spouse, but the use test must be met by both for $500,000. Per the Publication 523 worksheet, the couple checks whether either spouse qualifies for the single $250,000 limit or a partial exclusion. This is a case where reading the worksheet closely, or asking a tax professional, pays off.

Profile C: the home turned rental

Sam lived in a home for four years, then moved for a job and rented it out for two years before selling. Because the rental period falls after the last date he used it as a main home and within the 5-year window, he still meets the 24-month use and ownership tests. But depreciation he claimed or could have claimed on the rental period is not excludable and is taxed separately. Sam should keep both purchase records and rental depreciation schedules.

Record-keeping checklist

Publication 523 says that, in general, you should keep records documenting adjusted basis until 3 years after the due date of the tax return for the year you sold the home. Publication 551 adds that you must keep accurate records of all items that affect basis. A practical checklist:

  • Closing disclosure or settlement statement from the purchase, showing price and each fee.
  • Closing statement from the sale and any Form 1099-S.
  • Receipts, contracts and permits for each improvement, with dates and amounts.
  • Records of insurance payouts, energy credits or subsidies that reduce basis.
  • Dates you moved in and moved out, and any periods of rental or business use.
  • Depreciation schedules if any part of the home was rented or used for business.
  • Documents for any special rule: divorce decree, death certificate, military orders, doctor's recommendation or employer letter.
  • Records of any prior home sale for which you took the exclusion.

In summary

  • The Section 121 exclusion can shield up to $250,000 of gain from your income, or up to $500,000 for a married couple filing jointly, on the sale of your main home (IRS Topic no. 701, October 2026).
  • You generally need 24 months of ownership and 24 months of use within the 5 years before the sale, and no other home sale exclusion in the prior 2 years.
  • Gain equals the amount realized (price minus selling expenses) minus your adjusted basis (cost plus closing costs and capital improvements, minus certain adjustments).
  • A reduced exclusion may be available for a work-related move, a health issue or an unforeseeable event.
  • You must report the sale if you receive Form 1099-S or if any gain is taxable.
  • Depreciation claimed after May 6, 1997 is not excludable, and rental periods can affect the result.
  • Keep records of every improvement and closing document, and check Publication 523 for your own facts.

This guide is general information, not tax, legal or financial advice. Rules and thresholds change, and your situation may differ. Consider speaking with a qualified tax professional before you sell, especially if you have rented the home, used part of it for business, gone through a divorce or inherited it.

Frequently asked questions

Do I owe federal tax if my gain is under $250,000?

If you meet the ownership, use and look-back requirements and your gain is within your maximum, the gain is excluded from income. You may still need to report the sale if you received Form 1099-S, according to IRS Topic no. 701.

Do the two years of living there have to be consecutive?

No. Publication 523 says the 24 months of use can fall anywhere in the 5-year period and do not have to be a single block; the total is 24 months or 730 days.

Can I use the exclusion more than once?

Yes, but generally only once in a 2-year period. If you excluded the gain from another home sale during the 2 years before this sale, you may not be eligible for the full exclusion.

What if I sell my home for a loss?

IRS Topic no. 409 says losses from the sale of personal-use property, such as your home, are not tax deductible.

Which home improvements count toward basis?

Capital improvements that add value, prolong the home's life or adapt it to new uses, such as an addition, a new roof or a kitchen remodel. Routine repairs and maintenance, such as painting or fixing leaks, generally do not count unless they are part of a larger remodeling project.

Does the exclusion apply to a home I inherited?

Your basis is generally the home's fair market value at the date of death, but the Section 121 exclusion still requires you to meet the ownership and use tests yourself. If you sell soon after inheriting, there is often little or no gain to worry about.

Sources