Costs and taxes
Capital gains tax on a home sale
Applies to United StatesBy Sell My House Fast Editorial Team
Published Updated Last reviewed
Checked by our editorial process. How we write and check our guides.
The short answer
In the United States, federal law lets a seller exclude up to $250,000 of gain on selling a main home, or $500,000 on a qualifying joint return, if the home was owned and used as the main home for at least 2 of the 5 years before the sale. Gain above the limit is taxable.
Key takeaways
- The exclusion covers only a main home, and the seller must have owned it and lived in it for at least 2 years each within the 5 years before the sale.
- A married couple filing jointly gets the higher limit only if either spouse meets the ownership test, both meet the use test, and neither used the exclusion in the 2 years before.
- A seller who fails the tests because of a work move, a health reason or certain unforeseeable events may still exclude a reduced, prorated amount.
- Gain is the amount realized minus the adjusted basis, so selling expenses and improvements reduce it, while ordinary repairs do not.
- Gain allocated to certain periods after 2008 when the home was not a main home, and gain equal to depreciation claimed after May 6, 1997, cannot be excluded.
Selling in Canada? Read The principal residence exemption in Canada.
How much gain on a home sale is tax-free?
Federal law excludes from income some or all of the gain on the sale of a main home. One taxpayer can exclude up to $250,0009 of gain. A married couple filing a joint return can exclude up to $500,00010 when the conditions for couples are met.
The rule is section 121 of the Internal Revenue Code. Its first subsection and the limit read: 1
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.
The amount of gain excluded from gross income under subsection (a) with respect to any sale or exchange shall not exceed $250,000.
The exclusion covers only a main home. Publication 523, the IRS guide to selling a home, says “An individual has only one main home at a time.” Where a person owns or lives in more than one home, the IRS applies a test of facts and circumstances, in which the most important factor is where the person spends the most time. 3
Section 121 does not require the seller to buy another home. An older provision, section 1034, under which buying a new residence could leave gain on the old one unrecognized, was repealed in 1997. 1
Who qualifies for the full exclusion?
A seller qualifies for the full exclusion by passing three tests: ownership, use and a look-back rule. Publication 523 sets them out this way: 3
- Ownership. The seller owned the home for at least 24 months (2 years) in the 5 years before the date of sale, which is the date of closing.
- Use. The seller lived in the home as a main home for a total of at least 24 months (730 days) in those 5 years. The time does not have to be one block.
- Look-back. The seller did not exclude the gain from another home sale in the 2 years before this sale. The exclusion can be used only once in a 2-year period.
The ownership test and the use test can be met in different 2-year periods, but both must fall within the 5 years ending on the date of sale, according to IRS Topic no. 701. 2
Two other rules shut the exclusion off completely. Section 121 does not apply to a seller subject to the expatriate tax, or to a home acquired in a like-kind exchange and sold within 5 years of that acquisition. 1 Publication 523 lists both as automatic disqualifications. 3
Time in a care facility
A seller who becomes physically or mentally unable to care for themselves can count time in a licensed care facility as time living in the home. The condition is that the seller owned the home and used it as a main home for periods totaling at least 1 year in the 5-year period. Time spent in a facility licensed by a state or local government to care for someone in that condition, such as a nursing home, then counts toward the use test, as long as the seller still owns the home. 1
Military, Foreign Service, intelligence and Peace Corps service
A seller, or a seller’s spouse, on qualified official extended duty in the uniformed services, the Foreign Service or the intelligence community may choose to suspend the 5-year test period for up to 10 years, according to IRS Topic no. 701. 2 The statute extends the same choice to Peace Corps service outside the United States. Qualified duty means active duty for more than 90 days or for an indefinite period, while serving at a duty station at least 50 miles from the home or living in government quarters under government orders. 1
How does the exclusion work for married couples and surviving spouses?
On a joint return, section 121 applies the limit “by substituting ‘$500,000’ for ‘$250,000’”, but only when all three of its conditions are met: 1
- either spouse meets the ownership test;
- both spouses meet the use test; and
- neither spouse is barred by the rule that allows one exclusion in any 2-year period.
When a couple does not meet all three, the statute gives each spouse the limit that spouse would have if unmarried, and adds the two together. 1
A surviving spouse who has not remarried can count the late spouse’s ownership and use of the home. The higher joint limit also stays available when the home is sold no later than 2 years after the date of death and the joint-return conditions were met immediately before the death. 1
Divorce has its own rules. A person who received the home from a spouse or former spouse counts the time the other spouse owned it. 1 Publication 523 adds that this person must still meet the residence requirement on their own. 3 Separately, an owner whose spouse or former spouse is allowed to live in the home under a divorce or separation instrument is treated as using it as a main home during that time. 1 The guide to selling a house during a divorce covers the sale itself.
Can part of the gain be excluded after a shorter stay?
Yes, in some cases. A seller who fails the ownership and use tests, or the once-in-2-years rule, can still exclude part of the gain when the sale is because of a change in place of employment, health or, to the extent regulations provide, unforeseen circumstances. 1
Publication 523 lists events that qualify when they happen while the seller owns the home and lives in it: 3
- A work-related move. A new job, or a transfer, to a work location at least 50 miles farther from the home than the old one, or, for someone with no previous work location, a new job at least 50 miles from the home. It counts for the seller, a spouse, a co-owner or anyone else who lived in the home.
- A health-related move. A move to get or give care for a disease, illness or injury of the seller or a family member, or a doctor’s recommendation of a change in residence because of a health problem.
- An unforeseeable event. The home was destroyed or condemned, or suffered a casualty loss in a natural or man-made disaster or an act of terrorism, or someone who lived there died, divorced or legally separated, had two or more children from the same pregnancy, became eligible for unemployment compensation, or lost the means to pay basic living expenses after a change in employment status.
Publication 523 also allows a partial exclusion on other facts and circumstances, where the main reason for the sale is work, health or an unforeseeable event. 3 On that route, the Treasury regulation treats whether the event happened while the seller owned and lived in the home as one of several factors that may be relevant to the main reason for the sale. In one of its examples, a seller who was no longer living in the house when a job assignment led to the sale is entitled to a reduced exclusion on the facts and circumstances. 7
The reduced limit is prorated. The statute sets it as a share of the full limit, measured against 2 years. 1
The Treasury regulation on the reduced exclusion, 26 CFR 1.121-3(g), sets out the count. The full limit is multiplied by a fraction. On top is the shortest of three periods: the time the seller owned the home during the 5 years before the sale, the time the seller used it as a main home during those 5 years, and the time since the last sale that used the exclusion. Underneath is 730 when the periods are counted in days, or 24 when they are counted in months. 7 Each period is counted on its own, so the time owned and the time lived there need not be the same time. The general rule in the same regulations says the ownership and use requirements may be met during periods that do not overlap, and one of its examples counts time a seller lived in a townhouse as a tenant before buying it. 8 Publication 523’s worksheet takes the same steps. 3
Example
An example with round numbers
This is an illustration, not a tax calculation. Suppose a single seller bought a home, lived in it for 12 months, had never used the exclusion before, and then sold because of a new job far enough away to qualify. Twelve months over 24 is one half, so up to half of $250,000, or $125,000, of gain could be excluded.
The guide to selling a house for a job move covers the practical side of a work-related sale. The home sale tax estimator takes these steps with a seller’s own figures, works out a reduced limit the regulation’s way, and stops at the gain.
Which parts of a gain cannot be excluded?
Two kinds of gain stay taxable even when the tests are met: gain allocated to periods of nonqualified use, and gain equal to depreciation.
Nonqualified use. The exclusion does not cover the share of the gain allocated to periods of nonqualified use. Those are periods after 2008 when the home was not the main home of the owner or the owner’s spouse or former spouse. The share is the ratio of those periods to the whole time the owner owned the home. Three kinds of time do not count as nonqualified use: 1
- time in the 5 years before the sale that comes after the owner last lived there as a main home;
- up to 10 years in total of qualified official extended duty in the uniformed services, the Foreign Service or the intelligence community;
- other temporary absence, up to 2 years in total, because of a change of employment, health or other unforeseen circumstances.
Depreciation. A seller who rented out the home or used it for business cannot exclude the part of the gain equal to depreciation allowed or allowable for periods after May 6, 1997. 1 In one of its examples, Publication 523 calls that part of the gain unrecaptured section 1250 gain. 3 The section on how gain above the exclusion is taxed says how the IRS taxes it.
How is the gain on a home sale figured?
Gain is the amount realized minus the adjusted basis. The amount realized is the selling price minus selling expenses, according to Publication 523. 3
| Step | What it means |
|---|---|
| Selling price | Everything received for the home: money, the value of other property, debts the buyer took over, and real estate taxes the buyer paid for the seller 3 |
| Minus selling expenses | Costs directly tied to selling, such as a real estate agent’s commission, advertising and legal fees |
| Equals amount realized | What the sale brought in after those costs |
| Minus adjusted basis | What the home cost, plus improvements and certain costs of buying it, with other adjustments |
| Equals gain or loss | A positive number is a gain and a negative number is a loss |
Gain is not the same as the cash a seller receives at closing. The guide to net proceeds shows what is left after the mortgage payoff and the other costs of the sale.
Transfer taxes and similar charges that a seller pays on a sale are not deductible. Publication 523 says the seller can treat them as selling expenses instead. 3
Improvements and repairs
An improvement adds to the basis, and an ordinary repair does not. Publication 523 defines improvements as work that adds to the value of a home, prolongs its useful life or adapts it to new uses: an addition, a new roof, a new heating system or a kitchen modernization, for example. Repairs that only keep the home in good condition, such as painting, fixing leaks or replacing broken hardware, are not added. They count as improvements when they are done as part of an extensive remodeling or restoration. 3
Publication 523 says that, in general, the records that show the basis should be kept until 3 years after the due date of the tax return for the year of the sale. 3
An inherited home
An inherited home starts with a new basis. Publication 523 says that for a death in any year other than 2010, the basis is the home’s fair market value on the date of death, or on a later alternate valuation date chosen by the estate’s personal representative. 3 The guide to selling an inherited house covers the rest of that sale.
When must a home sale be reported to the IRS?
A sale must be reported in two cases, according to IRS Topic no. 701. The first is when the seller receives Form 1099-S, Proceeds From Real Estate Transactions, even if all the gain is excludable. The second is when the seller cannot exclude all of the gain. The sale is then reported on Form 8949 and Schedule D (Form 1040). 2
Form 1099-S is generally filed by the person responsible for closing the sale. Where a Closing Disclosure or other settlement statement names a settlement agent, that is the person. 6 The form need not be filed for the sale of a principal residence for $250,000 or less, or $500,000 or less when the certification says the seller is married, if the seller gives a written certification that the whole gain is excludable. Those are limits on the sale price, not on the gain. Without the certification, the form is filed. 6
A seller may also choose not to use the exclusion, and the statute allows it. 1 Publication 523 gives a reason a seller might: a larger gain expected on another main home sold within the next 2 years. 3
A sale in which the buyer pays over time can be an installment sale. The exclusion remains available on an installment sale, according to IRS Topic no. 701. 2 The guide to seller financing covers that kind of sale.
How is gain above the exclusion taxed?
Gain that is not excluded is a capital gain. It is generally long-term when the home was held for more than one year and short-term when it was held for one year or less. Net short-term capital gains are taxed as ordinary income. 4
Long-term gain is taxed at its own rates. IRS Topic no. 409 says some or all net capital gain may be taxed at 0%, and that for taxable years beginning in 2025 the rate on most net capital gain is no higher than 15% for most individuals. A 20% rate applies to taxable income above the thresholds set for the 15% rate. 4 The topic lists the thresholds by filing status for taxable years beginning in 2025. This guide does not repeat them.
Unrecaptured section 1250 gain, which on a home sale includes the part of the gain equal to depreciation, is treated differently. Topic no. 409 says it is taxed at a maximum 25% rate. 4
The net investment income tax can also apply. For an individual it is 3.8% of the lesser of net investment income or the amount by which modified adjusted gross income is above $250,000 on a joint return, $200,000 for a single filer or head of household, or $125,000 for married filing separately. It does not apply to the part of a home sale gain that is excluded. 5
This guide covers federal income tax only. It does not describe state income tax on a home sale. A tax professional, such as a CPA, an enrolled agent or a tax attorney, can work out what tax a specific sale leaves.
Frequently asked questions
Do I owe capital gains tax if I sell my house for less than I paid?
No tax is due on a loss. The IRS says in Publication 523 that a seller whose adjusted basis is greater than the amount realized has sold at a loss, cannot deduct the loss, and does not need to pay tax on the money received. Topic no. 409 says losses on personal-use property, such as a home, are not tax deductible. The amount realized is the price minus selling expenses, so a sale above the purchase price can still be a loss.
Does the home sale exclusion apply to a rental property or a second home?
The exclusion applies only to a main home. Publication 523 says an individual has only one main home at a time. A home that was rented out or used as a second home after 2008, and later became a main home, can have periods of nonqualified use. Under 26 U.S.C. § 121, the gain allocated to those periods cannot be excluded, and gain equal to depreciation claimed after May 6, 1997, cannot be excluded either.
Do I have to buy another house to avoid capital gains tax?
No. The federal exclusion in 26 U.S.C. § 121 depends on owning and living in the home before the sale, not on what the seller does with the money afterwards. The older rule in section 1034, under which buying a new residence could leave gain unrecognized, was repealed in 1997.
Will the IRS know that I sold my house?
Often, yes. The person responsible for closing the sale, such as the settlement agent named on the Closing Disclosure, generally files Form 1099-S with the IRS. The IRS instructions excuse it for the sale of a principal residence below a price limit when the seller certifies in writing that the whole gain is excludable. A seller who receives Form 1099-S must report the sale, on Form 8949 and Schedule D, even when the gain is excludable.
Can I use the home sale exclusion more than once?
Yes, but not more often than once in any 2-year period. Under 26 U.S.C. § 121(b)(3), the exclusion does not apply to a sale if the seller used it on another sale during the 2 years ending on the date of this sale. A seller who sells sooner because of a work move, a health reason or certain unforeseen events may qualify for a reduced exclusion instead.
Does the 3.8% net investment income tax apply when I sell my home?
Only to gain that is not excluded, and only above an income threshold. The IRS says the tax does not apply to the excluded part of the gain on a principal residence, while net gains from selling real estate count as net investment income. An individual pays 3.8% of the lesser of net investment income or the amount by which modified adjusted gross income is above $250,000 on a joint return, $200,000 for a single filer, or $125,000 for married filing separately.
Compare and calculate
Work it out
Related guides
Net proceeds: what you keep after a sale
What comes out of a home's sale price before the seller is paid in the US and Canada, from the mortgage payoff and liens to commission, costs and adjustments.
Cash offer vs. listing: comparing what you net
How to set a cash offer beside what a listing would leave in the US and Canada, line by line, from price and commission to repairs, carrying costs and risk.
Selling an inherited house
Who can sell an inherited house in the United States, what happens to its mortgage or reverse mortgage, and how the IRS taxes the sale.
Real estate commissions
How US real estate commissions are agreed and paid, and what the 2024 class-action settlement changed for sellers and for pay to buyers' brokers.
Closing costs for sellers
What a home seller pays at closing in the US and Canada, who decides which side pays each cost, and how the payoff, adjustments and tax reporting work.
Sources
The documents this page relies on, in the order they are first used, with the date each was last checked.
- 26 U.S.C. § 121, Exclusion of gain from sale of principal residence. Office of the Law Revision Counsel, U.S. House of Representatives. 26 U.S.C. § 121. Primary source. Checked .
- Topic no. 701, Sale of your home. Internal Revenue Service. 26 U.S.C. § 121. Primary source. Checked .
- Publication 523 (2025), Selling Your Home. Internal Revenue Service. IRS Publication 523. Primary source. Checked .
- Topic no. 409, Capital gains and losses. Internal Revenue Service. Primary source. Checked .
- Topic no. 559, Net investment income tax. Internal Revenue Service. 26 U.S.C. § 1411. Primary source. Checked .
- Instructions for Form 1099-S, Proceeds From Real Estate Transactions (12/2026). Internal Revenue Service. Instructions for Form 1099-S (Rev. December 2026). Primary source. Checked .
- 26 CFR § 1.121-3, Reduced maximum exclusion for taxpayers failing to meet certain requirements. Office of the Federal Register, Electronic Code of Federal Regulations. 26 CFR § 1.121-3. Primary source. Checked .
- 26 CFR § 1.121-1, Exclusion of gain from sale or exchange of a principal residence. Office of the Federal Register, Electronic Code of Federal Regulations. 26 CFR § 1.121-1. Primary source. Checked .
- Internal Revenue Code, 26 U.S.C. § 121. 26 U.S.C. § 121(a), (b)(1). Primary source. Checked .
- Internal Revenue Code, 26 U.S.C. § 121. 26 U.S.C. § 121(b)(2)(A). Primary source. Checked .
Please note
General information, not tax advice
This page describes the rules in general terms as they stood on November 16, 2026. It does not apply them to your circumstances, and the rules can change. For a decision about your own sale, speak to a qualified tax professional. Read the full disclaimer.
Page history
- : Corrected how a reduced exclusion is counted. There is one method, the Treasury regulation's, which Publication 523 follows. An earlier version said the statute could give a different result.
- : Added the work-move route for someone with no previous workplace, and that on the facts-and-circumstances route the regulation treats the timing of the event as one factor.
- : First published.
Key facts
- Applies to
- United States
- Last reviewed
- November 16, 2026
- Sources cited
- 10
- Listed above, each with the date it was last checked.
Get connected with a local investor
Not sure which route fits?
Choose where the property is and what best describes your situation. On the next page you can ask to be put in touch with a local real estate investor, who may contact you about buying your home.