Do You Pay Capital Gains Tax When You Sell Your House?
By Personal Finance DeskUpdated Nov 10, 2026

Key takeaways
- To claim the exclusion, you must own the home and live in it for two of the five years before the sale.
- A married couple gets the $500,000 limit only if both spouses meet the two-year use test.
- Capital improvements such as a new roof or an added bathroom raise your basis and shrink your gain.
- A loss on the sale of your personal residence is not deductible, even though a gain can be taxed.
Usually not, if the house is your main home and your profit fits within the exclusion. Federal tax law (Section 121 of the Internal Revenue Code) lets you exclude up to $250,000 of gain from the sale of your principal residence, or up to $500,000 if you are married and file jointly. To qualify, you generally must have owned the home and lived in it as your main home for at least two of the five years before the sale, and you must not have used the exclusion on another home sale in the prior two years.
You pay capital gains tax on a house sale when the gain is larger than your exclusion, when you fail the ownership or use tests, or when the property is a second home, vacation home or rental rather than your principal residence. The tax applies to the gain, not to the sale price. A $900,000 sale of a home with a $700,000 adjusted basis produces a $200,000 gain, and that gain is the number the exclusion is measured against.
Why a home sale can create a taxable gain
A house is a capital asset. When you sell a capital asset for more than your basis in it, the difference is a capital gain, and capital gains are taxable unless a specific rule excludes them. For a home you live in, that rule is the Section 121 exclusion, created in its current form by the Taxpayer Relief Act of 1997.
The basic formula is:
Gain = Amount realized − Adjusted basis
- Amount realized is the sale price minus selling expenses, such as real estate commissions, attorney fees, title and escrow fees you pay as the seller, and transfer taxes.
- Adjusted basis starts with what you paid for the home, adds certain purchase costs and capital improvements, and subtracts items that return part of your cost to you, such as insurance reimbursements for casualty losses or depreciation you claimed.
Your mortgage balance has nothing to do with the gain. Paying off a $300,000 loan at closing reduces the cash you walk away with, but it does not reduce your taxable gain. Likewise, a seller who receives very little cash at closing can still have a large gain on paper if the home has appreciated well above its basis.
How the home sale exclusion works
The ownership and use tests
To claim the full exclusion, you must meet two tests during the five-year period that ends on the date of the sale:
- Ownership test: you owned the home for at least two years (24 months, or 730 days).
- Use test: you lived in the home as your main home for at least two years.
The two periods do not have to overlap, and neither has to be continuous. Someone who rented a house for three years and then bought it and lived there for two more could meet both tests at the end of that fifth year. Someone who lived in a home for 14 months, moved out for a year, then moved back for 10 months also meets the use test, because the months add up to 24 within the window.
Short temporary absences, such as vacations or seasonal trips, count as time living in the home even if you rent it out while you are away. A long absence, such as a year-long sabbatical, generally does not.
Which home is your principal residence
The exclusion applies only to your main home. If you own more than one residence, the one you live in most of the time is usually treated as your principal residence. Other facts can support that conclusion: the address on your tax returns, driver’s license, voter registration and car registration; where you work; where your bank is; and where your family lives. You can have only one main home at a time, but over a five-year window, two different houses can each meet the two-year use test, as long as the periods do not overlap.
The once-every-two-years limit
You cannot claim the exclusion if you excluded gain from the sale of another home during the two years before the current sale. This matters for people who own two homes that both meet the residence tests. If you sell the first one and exclude the gain, you have to wait until more than two years have passed before selling the second one with a full exclusion.
The $500,000 exclusion for married couples
Married taxpayers filing a joint return can exclude up to $500,000 if all of the following are true:
- Either spouse meets the ownership test.
- Both spouses meet the use test.
- Neither spouse excluded gain from another home sale in the two years before this sale.
Ownership by one spouse is enough, but residence by one spouse is not. Two short scenarios show the difference:
- A married couple sells a house owned only by one spouse. Both have lived in it for at least 24 of the last 60 months. They can exclude up to $500,000.
- A recently married couple sells a house owned only by one spouse. The owner has lived there for four years, but the other spouse moved in 12 months ago. Filing jointly, they can exclude up to $250,000, the amount attributable to the spouse who meets both tests.
If each spouse separately qualifies for a $250,000 exclusion on a home they each own and sell, the amounts are figured per person. Married couples who file separately each have their own $250,000 limit, subject to their own ownership and use history.
Widowed sellers
A surviving spouse can still claim the $500,000 maximum, rather than $250,000, if all of these conditions are met:
- The home is sold within two years after the date of the spouse’s death.
- The surviving spouse has not remarried at the time of the sale.
- Neither the surviving spouse nor the late spouse excluded gain from another home sold in the two years before this sale.
- The ownership and use requirements for the $500,000 exclusion were met immediately before the spouse’s death.
A surviving spouse can also count the deceased spouse’s period of ownership and residence toward the two-year tests. This is separate from the basis adjustment that may apply to the inherited share of the home, discussed later.
When a home sale is taxable
Gain on a home sale is taxable, at least in part, in these situations:
- The gain exceeds the exclusion. Only the excess is taxable, but it is taxable.
- The home is not your principal residence. Second homes, vacation homes and rentals do not qualify on their own.
- You did not meet the two-year ownership and use tests, unless you qualify for a partial exclusion or a special rule.
- You used the exclusion on another home within two years.
- You acquired the home through a 1031 like-kind exchange within the past five years. A property received in an exchange has to be held for at least five years before its sale can qualify for the exclusion, a rule added by the American Jobs Creation Act of 2004.
- You are subject to the expatriate tax rules. Certain people who give up U.S. citizenship or long-term residency cannot claim the exclusion.
- Part of the gain comes from depreciation you claimed (or could have claimed) after May 6, 1997, for business use or rental of the home.
- Part of the gain is allocated to nonqualified use, a rule that mainly affects former second homes and rentals converted to a main residence, covered below.
Partial exclusion when you sell before two years
If you sell before meeting the two-year tests, you may still exclude part of the gain if the main reason for the sale was one of the following:
- A work-related move. The usual safe harbor applies when your new place of work is at least 50 miles farther from the home than your old workplace was (or, if you had no prior workplace, at least 50 miles from the home).
- Health. The move is to obtain, provide or facilitate diagnosis, cure or treatment of a disease, illness or injury for you or a family member, or a doctor recommends a change of residence for health reasons.
- Unforeseeable events. IRS rules list events such as the death of a resident, divorce or legal separation, multiple births from the same pregnancy, becoming eligible for unemployment compensation, a job change that leaves you unable to pay basic living costs, a natural or man-made disaster that damages the home, or condemnation of the property.
The partial exclusion is a fraction of the full limit, not a fraction of your gain. In its simplest form:
Reduced maximum exclusion = Full exclusion × (months you qualified ÷ 24)
Assume a single seller who owned and lived in a home for 12 months, then sold because of a qualifying job transfer. The maximum exclusion would be $250,000 × 12/24 = $125,000. If the gain was $40,000, all of it is still excludable, because $40,000 is below the reduced limit. If the gain was $160,000, $35,000 would be taxable. (The IRS computation uses the shorter of the ownership period, the use period, or the time since you last used the exclusion, and can be figured in days as well as months.)
How much tax you pay on the taxable portion
Short-term vs. long-term gain
How long you owned the home determines the type of gain:
- Owned one year or less: the gain is short-term and taxed at your ordinary income tax rates, which reach 37% at the highest bracket.
- Owned more than one year: the gain is long-term and taxed at the long-term capital gains rates.
A homeowner who buys a house, sees it jump in value and sells within 12 months gets no exclusion under the regular two-year rule and is taxed at ordinary rates unless a partial exclusion applies. The difference between short-term and long-term capital gains works the same way for a house as for stocks.
Long-term capital gains rates
Long-term gains are taxed at 0%, 15% or 20%, with the rate determined by your taxable income and filing status. The income thresholds for each rate are adjusted for inflation every year. The rates are not applied to the gain in isolation: the taxable gain is added on top of your other taxable income, and the portion that falls into each income range gets that range’s rate. A seller whose other income places them in the 15% range could find that part of a large taxable gain spills into the 20% range.
Two additional layers can apply:
- Unrecaptured Section 1250 gain. Gain attributable to depreciation on real property (for example, from renting the home or using part of it as a home office) is taxed at a maximum rate of 25% rather than the regular long-term rates.
- Net investment income tax (NIIT). A 3.8% surtax applies to net investment income for taxpayers with modified adjusted gross income above $200,000 (single or head of household), $250,000 (married filing jointly) or $125,000 (married filing separately). Gain you exclude under Section 121 is not net investment income, but taxable gain above the exclusion can be. These NIIT thresholds are set by statute and are not indexed for inflation.
State income tax may also apply to the taxable portion, depending on where you live. States set their own rules for capital gains and for whether they follow the federal exclusion.
Using other capital losses
Capital losses from selling other assets during the year, such as stocks or investment property, offset capital gains, including the taxable part of a home sale gain. If your total capital losses exceed your total capital gains, you can deduct up to $3,000 of the net loss against other income ($1,500 if married filing separately) and carry the rest forward to future years. Losses carried forward from earlier years can offset a home sale gain in the year you sell.
Calculating your home’s cost basis
Basis is where a lot of tax can be saved, because every dollar you can document adds to basis and reduces gain dollar for dollar.
What goes into the starting basis
For a home you bought, the starting basis is the purchase price plus certain settlement and closing costs, such as:
- Title insurance and abstract fees
- Legal fees for the purchase, including title searches and preparing the deed
- Recording fees
- Survey costs
- Transfer taxes you paid as the buyer
- Charges for installing utility services
- Amounts the seller owed that you agreed to pay, such as back taxes
Costs tied to getting a mortgage, such as mortgage insurance premiums, appraisal fees required by the lender, and loan points, are generally not added to basis. Neither are prepaid items like homeowners insurance or rent for occupancy before closing.
If you built the home, basis includes the land and the cost of construction, including labor and materials paid to contractors, architect fees and permits.
Improvements vs. repairs
Capital improvements increase basis. An improvement adds value, extends the home’s useful life or adapts it to new uses. Examples include an addition, a new bathroom, a finished basement, a new roof, central air conditioning, a new furnace, new plumbing or wiring, a deck, landscaping or a new driveway. Spend $15,000 adding a bathroom, and basis rises by $15,000.
The following do not increase basis:
- Repairs and maintenance that keep the home in normal condition without adding value, such as fixing a leak, repainting a room or replacing a broken window pane (unless done as part of a larger remodeling project).
- Improvements with a useful life of less than one year.
- Improvements that are no longer part of the home. If you installed carpet 20 years ago and replaced it 10 years ago, only the current carpet counts.
Adjustments that reduce basis
Basis goes down when part of your cost is returned to you or written off. Common reductions include:
- Insurance reimbursements for casualty losses. Assume you paid $250,000 for a home and later received a $100,000 insurance payment after fire damage. Your basis drops to $150,000. (Money you then spend restoring the home is added back as an improvement.)
- Casualty loss deductions you took on a prior return.
- Depreciation allowed or allowable for business or rental use of the home.
- Energy credits and certain subsidies that reduced the cost of improvements.
- Easements sold or granted.
- Gain postponed under the pre-1997 rollover rule, which reduced the basis of the replacement home for sellers who used it.
Selling expenses
Selling expenses reduce the amount realized rather than increasing basis, but the effect on your gain is the same. These include real estate agent commissions, advertising, legal fees, title fees paid by the seller, escrow fees, transfer and stamp taxes paid by the seller, and loan charges you paid on the buyer’s behalf, such as points.
Putting the pieces together, the gain on a home can be far below the simple “sold for minus paid” figure. A seller who paid $400,000, spent $8,000 on qualifying closing costs and $90,000 on improvements, and paid $45,000 in commissions and other selling costs on a $750,000 sale has a gain of $207,000, not $350,000.
Basis when you inherit a home
An inherited home generally gets a basis equal to its fair market value on the date of the previous owner’s death, often called a step-up in basis. If the executor files an estate tax return and elects the alternate valuation date, basis is the value six months after death (or on the date of sale or distribution, if earlier).
Assume someone paid $50,000 for a house decades ago, and it was worth $400,000 when they died. You inherit it and sell six months later for $500,000. Your taxable gain is $100,000 ($500,000 − $400,000), before selling expenses. The $350,000 of appreciation during the original owner’s life is never taxed. Inherited property is also treated as held long-term regardless of how long you actually own it.
You will not qualify for the Section 121 exclusion on an inherited home unless you meet the ownership and use tests yourself, so a quick sale after inheritance relies on the step-up, not the exclusion, to keep the gain small.
For married couples, the deceased spouse’s share of a jointly owned home usually gets a stepped-up basis. In community property states, both halves of community property can receive the adjustment when one spouse dies.
Basis when you receive a home as a gift
A gifted home generally carries over the donor’s basis. If a parent paid $150,000 for a house and gives it to a child when it is worth $600,000, the child’s basis for figuring gain is $150,000, plus any improvements the parent made. Selling a home to a relative for less than market value can be treated as part sale and part gift, with the buyer’s basis depending on both the price paid and the donor’s basis.
Worked examples
Both examples are hypothetical and ignore state tax. They assume the sellers meet the ownership and use tests.
Example 1: Gain within the exclusion
A single owner buys a condo for $300,000, lives in it for three years, and sells it for $450,000. Ignoring closing costs and improvements, the gain is $150,000. That is below the $250,000 exclusion, so no capital gains tax is due.
Change one fact: local prices rise sharply, and the condo sells for $600,000. The gain is now $300,000. After the $250,000 exclusion, $50,000 is taxable as long-term capital gain, at 0%, 15% or 20% depending on the owner’s taxable income.
Example 2: Married couple with a large gain
A married couple buys a home for $500,000 and sells it 12 years later for $1.2 million. Without any adjustments, the gain is $700,000. Filing jointly and meeting all requirements, they exclude $500,000, leaving $200,000 potentially taxable.
Now add their records. They paid $10,000 in qualifying closing costs at purchase, spent $120,000 on a kitchen remodel and a new roof, and paid $70,000 in commissions and other selling costs.
- Adjusted basis: $500,000 + $10,000 + $120,000 = $630,000
- Amount realized: $1,200,000 − $70,000 = $1,130,000
- Gain: $1,130,000 − $630,000 = $500,000
- Taxable gain after the $500,000 exclusion: $0
The records turned a $200,000 taxable gain into none at all.
Second homes, vacation homes and rental property
Residence vs. rental for tax purposes
The IRS treats a dwelling as a residence (rather than a pure rental) for a given year if you use it personally for more than the greater of 14 days or 10% of the days it is rented at a fair rental price. If you rent a beach house for 280 days, you must use it personally for more than 28 days for it to count as a residence that year.
Being a residence under this rule is not the same as being your principal residence. A vacation home you use for a month each summer is a second home, and a property used solely as an investment never qualifies for the exclusion on its own. Either qualifies only if it becomes your main home and you meet the two-year tests.
Converting a second home or rental into your main home
Because the use test counts cumulative time, you can move into a former vacation home or rental, live there as your main home for two years, and then sell it with an exclusion. Two rules limit how much gain that strategy can shelter.
Nonqualified use. Under the Housing and Economic Recovery Act of 2008, gain allocated to periods of “nonqualified use” after 2008 cannot be excluded. Nonqualified use is any period when neither you nor your spouse (or former spouse) used the property as a main home. The allocation is based on time:
Nonexcludable gain = Gain × (nonqualified use after 2008 ÷ total ownership period)
Important exceptions: time after the last date you used the property as your main home does not count as nonqualified use (as long as that period falls within the five-year window), and neither do certain periods of qualified official extended duty or temporary absences of up to two years for job changes, health or unforeseen circumstances.
Assume a hypothetical owner buys a vacation home, uses it as a second home for six years, then moves in full time for four years and sells after 10 years of ownership with a $300,000 gain. Six of the 10 years were nonqualified use, so 60% of the gain ($180,000) cannot be excluded. The remaining $120,000 is eligible for the exclusion.
Now reverse the order: the owner lives in the home as a main residence for four years, then moves out and rents it for two years before selling. The rental period comes after the last use as a main home and falls within the five-year window, so it is not nonqualified use. The owner meets the two-of-five test and can apply the exclusion to the full gain, except for depreciation.
Depreciation. Any depreciation allowed or allowable for rental or business use after May 6, 1997, must be recaptured and taxed, even if the rest of the gain is excluded. “Allowable” means the IRS treats the depreciation as taken whether or not you actually claimed it.
1031 exchanges for investment real estate
A 1031 exchange, named for Section 1031 of the Internal Revenue Code, lets you defer capital gains tax when you exchange real property held for business or investment for other like-kind real property. You must identify replacement property in writing within 45 days of the sale and acquire it within 180 days, or by the due date of your tax return for that year if earlier. Proceeds generally must be held by a qualified intermediary, and any cash you receive (called boot) is taxable. The tax is deferred, not forgiven: your basis in the old property carries into the new one.
Personal residences do not qualify. A second home qualifies only if it is treated as investment property. Under the Revenue Procedure 2008-16 safe harbor, you must own it for at least 24 months before the exchange and, in each of the two 12-month periods, rent it at a fair rental for at least 14 days while limiting personal use to the greater of 14 days or 10% of the days rented. If you later move into a property acquired through an exchange, you must own it for at least five years before selling it with the home sale exclusion, and the nonqualified use and depreciation rules still apply.
Installment sales
In an installment sale, the buyer pays you over time, often through seller financing. You report the gain as you receive payments, which can spread it across several tax years and may keep more of it in a lower capital gains bracket. Each payment is partly an untaxed return of basis, partly capital gain and partly interest taxed as ordinary income. Depreciation recapture may have to be reported in the year of sale regardless of when you are paid. The approach mainly helps sellers of rentals and second homes with gains that cannot be excluded, and it carries the risk that the buyer stops paying.
Ways to reduce or avoid capital gains tax on a home sale
For a principal residence, the practical options come down to timing and records:
- Meet the two-year tests before you sell. Selling at 22 months instead of 24 can turn a fully excluded gain into a taxable one, unless you qualify for a partial exclusion.
- Mind the two-year lookback. If you excluded gain on another home recently, wait until more than two years have passed.
- Make sure both spouses meet the use test if you need the $500,000 limit.
- Document basis. Purchase closing costs, capital improvements and selling expenses all reduce the gain.
- Offset taxable gain with capital losses realized in the same year or carried forward.
- Check partial exclusion eligibility if a job move, health issue or unforeseen event forces an early sale.
For second homes and investment property, the main tools are a 1031 exchange, converting the property to your main home, and an installment sale, each with the limits described above.
What happens if you lose money on a home sale
A loss on the sale of your personal residence is not deductible and cannot be used as a capital loss. That is true even though a gain on the same home would be taxable to the extent it exceeds the exclusion.
A loss on rental or investment property is treated differently: it can generally be deducted, subject to the capital loss limits described earlier. Losses on business property used in a trade or business may receive different treatment under Section 1231.
If a home was converted from personal use to a rental, the basis for figuring a loss is the lower of your adjusted basis or the property’s fair market value when you converted it. This prevents a homeowner from deducting a decline in value that happened while they lived there.
Special situations
Divorce
Divorce affects both ownership and use. If a home is transferred to you from your spouse or former spouse as part of a divorce, you can count the time your former spouse owned it toward your ownership test. And if you still own the home but your former spouse lives there under a divorce or separation instrument, you are treated as using it as your main home during that time, until the date of sale. These rules let a spouse who moved out still qualify for the exclusion on a later sale.
Transfers of property between spouses, or between former spouses incident to a divorce, are generally not taxable events. The receiving spouse takes over the transferring spouse’s basis.
Military, Foreign Service and certain government employees
Members of the uniformed services, the Foreign Service and the intelligence community, and certain Peace Corps volunteers and employees, can elect to suspend the five-year test period for up to 10 years while on qualified official extended duty. Qualified duty generally means being stationed at least 50 miles from the home or living in government quarters under orders for more than 90 days. A spouse can make the election as well.
In effect, the lookback period can stretch to as long as 15 years.
Home offices and mixed-use property
If you used part of your home for business or as a rental, how you handle the sale depends on where that space was:
- Within the house itself, such as a spare bedroom used as an office, you do not need to split the sale into business and residential parts. The full gain can be eligible for the exclusion, except for depreciation claimed after May 6, 1997.
- In a separate structure, such as a detached studio or a separate rental unit on the property, you generally have to allocate basis and sale price between the residential part and the business part. Only the residential part qualifies for the exclusion.
Vacant land
Selling land next to your home can qualify for the exclusion if you owned and used it as part of your residence, and you sell it within two years before or after the sale of the home itself. The land and the home are treated as one sale for the exclusion limit.
Reporting a home sale to the IRS
You must report the sale on your tax return if either of these is true:
- You have gain that is not excludable.
- You received Form 1099-S, Proceeds From Real Estate Transactions.
If neither applies, you generally do not need to report the sale at all. Form 1099-S is usually issued by the closing agent, title company, settlement attorney or mortgage lender handling the closing. When you do report, the sale goes on Form 8949 and Schedule D, attached to Form 1040. If you received a 1099-S but your gain is fully excluded, you still report the sale and show the exclusion as an adjustment.
The person responsible for closing does not have to issue a 1099-S in several situations, including:
- The sale price is $250,000 or less ($500,000 or less for married sellers), and the seller provides written certification that the full gain is excludable and that the home was their principal residence. Telling the closing agent early that you qualify allows the certification to be handled before closing.
- The seller is a corporation, a governmental unit or an exempt volume transferor.
- The transfer is not a sale, such as a gift, or it satisfies a debt secured by the property, such as a foreclosure or deed in lieu.
- The total consideration is $600 or less.
A seller who claims the exclusion should keep records showing ownership dates, residence dates and basis, since the 1099-S reports gross proceeds and says nothing about basis or eligibility.
How the rules changed in 1997
Before the Taxpayer Relief Act of 1997, sellers could postpone gain under the rollover rule (former Section 1034) by buying a replacement home costing at least as much within two years, with the postponed gain reducing the new home’s basis. Sellers aged 55 or older could also exclude up to $125,000 of gain once in a lifetime. The current exclusion replaced both for sales after May 6, 1997. You no longer have to buy another home, you can spend the proceeds however you choose, the exclusion can be used once every two years, and age no longer matters.
The $250,000 and $500,000 limits have not changed since 1997 and are not indexed for inflation, while the income thresholds for the capital gains rates are adjusted every year. As home prices rise with inflation and market appreciation, a fixed exclusion covers a smaller share of the gain on a long-held home. Sellers who owned the same house for decades, or who carried reduced basis forward from pre-1997 rollovers, are the ones most exposed to gains above the limit.
FAQs
Does the exclusion apply to a co-op, condo or mobile home?
Yes, if it is your main home. A principal residence can be a house, condominium, cooperative apartment, mobile home or houseboat, provided you meet the ownership and use tests. For a co-op, owning the stock in the cooperative housing corporation counts as ownership.
The Bottom Line
Homeowners planning to sell a main home have the most at stake, especially those who bought long ago in rising markets. Because the $250,000 and $500,000 limits are not indexed for inflation, records of closing costs, improvements and selling expenses can decide whether any gain is taxable. Selling after the two-year tests are met, and checking the partial exclusion rules after a forced move, helps protect the exclusion.













