StructureX

Home › Guides › Markets & the economy

Capital gains tax on the sale of a home

This page is for United States, federal rules (IRS); state taxes are not covered

When you sell your main home, the IRS lets you leave out up to $250,000 of the gain from your income. A married couple filing jointly can leave out up to $500,000. You must pass the tests first.

Beginner guide · 8-minute read · By Paspir · Updated 2026-11-29

The short answer

This page is about United States federal tax, from the IRS. It does not cover state tax. The rules come from IRS Publication 523, Selling Your Home (2025 edition, for 2025 returns), and IRS Tax Topic 701.

Gain on a home is what you get after costs, minus what the home cost you. For your main home, you can leave out part of that gain. The IRS says "The exclusion is increased to $500,000 for a married couple filing jointly." The base limit for everyone else is $250,000.

Try your numbers in the home sale capital gains calculator.

The limits (United States, federal)

WhoMost gain you can leave out
Single, or married filing separately$250,000
Married filing jointly$500,000

Pub 523 sets the joint rule this way: "Both spouses meet the residence and look-back requirements and one or both spouses meet the ownership requirement." These two dollar limits are the ones Pub 523 prints.

The three tests

You must pass all three to get the full exclusion.

1. Ownership. The IRS says, "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."

2. Residence (use). You must have lived in it as your main home. The IRS says, "All that is required is a total of 24 months (730 days) of residence during the 5-year period." It also says the months "can fall anywhere within the 5-year period, and it doesn't have to be a single block of time."

3. Look-back. The IRS says, "You may take the exclusion only once during a 2-year period."

On a joint return, only one spouse has to meet the ownership test. But "each spouse must meet the residence requirement individually" to get the full amount.

Topic 701 adds that you can pass the ownership and use tests in different 2-year periods, as long as you pass both "during the 5-year period ending on the date of the sale."

How to figure the gain

Pub 523 says you need three numbers: "the selling price, the amount realized, and the adjusted basis."

StepWhat it means
Sale priceEverything you got for the home
Minus selling costsSuch as "any sales commissions (for example, a real estate agent's sales commission)"
Amount realizedSale price minus selling costs
Cost basisWhat you paid, plus "any settlement fees or closing costs you paid when you bought your home, except for financing-related costs"
Plus improvementsMoney spent on "construction or other improvements that are still part of your home at the time of sale"
Minus basis reductionsSuch as insurance payments for casualty losses
Adjusted basisThe result
GainAmount realized minus adjusted basis

The IRS defines an improvement this way: "Improvements add to the value of your home, prolong its useful life, or adapt it to new uses."

Higher basis means lower gain. Keep the closing papers and receipts for big projects.

What if you have a loss?

On your main home, the IRS is blunt: "You can't deduct this loss, but you don't need to pay any tax on the money you received from selling your home."

Hypothetical: a gain under the limit

This is a made-up example in US dollars, not a forecast.

A single owner sells for $500,000. Selling costs are $30,000, so the amount realized is $470,000. They paid $250,000, paid $5,000 in closing costs and spent $45,000 on a new kitchen. Adjusted basis is $300,000.

StepAmount (United States, federal)
Amount realized$470,000
Adjusted basis$300,000
Gain$170,000
Exclusion (single)$250,000
Taxable gain$0

The whole $170,000 fits under the $250,000 limit.

Hypothetical: a gain over the limit

Same idea, bigger numbers, and a single filer in tax year 2027. The gain is $318,000. The exclusion covers $250,000. The other $68,000 is taxable as a long-term gain.

Where it lands depends on your other income. Long-term gains are taxed at 0%, 15% or 20%, using the 2027 capital gains thresholds. Say the filer has $80,000 of other taxable income. That is already past the $51,050 line where the 0% rate ends for a single filer, so the whole $68,000 is taxed at 15%. Our arithmetic, income tax only: $68,000 × 15% = $10,200.

Fail a test and the gain is taxable

Say the same $318,000 gain on a home owned for years, but the owner lived in the home only 18 of the last 60 months. The use test fails. With no exclusion, the full $318,000 is taxable. Our arithmetic, same filer, income tax only: $318,000 × 15% = $47,700.

Some people can still get a smaller exclusion. See the next part.

A partial exclusion

Pub 523 says, "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."

The IRS gives three steps:

  1. Find the shortest of three periods: your time in the home, your time owning it, or the time since you last took the exclusion on another home.
  2. Take the smallest period, and "divide that number by 730 (if using days) or 24 (if using months)."
  3. "Multiply the result from Step 2 by $250,000. This is the amount of your reduced exclusion."

Say a single owner lived in and owned the home for 12 months, and the sale qualifies. 12 ÷ 24 = 0.5, and 0.5 × $250,000 = $125,000. This is our arithmetic using the IRS steps. For a married couple, follow Worksheet 1 in Pub 523.

A surviving spouse

The IRS says, "you may be able to increase your exclusion amount from $250,000 to $500,000." Two of its conditions are that you sell "within 2 years of the death of your spouse" and haven't remarried when you sell. Read all four in Pub 523.

Rental or business use

If you rented out part of the home or took depreciation, the exclusion shrinks. The IRS says you cannot exclude "the part of your gain equal to any depreciation allowed or allowable." The details are on capital gains on rental property.

Pub 523 also says gain tied to "nonqualified use" after 2008 isn't excludable. It defines that as any period when neither you nor your spouse used the home as a main home, with some exceptions.

Reporting the sale

Topic 701 says that if you get Form 1099-S, "you must report the sale of the home even if the gain from the sale is excludable." You also report it "if you can't exclude all of your capital gain from income." The forms are Schedule D (Form 1040) and Form 8949.

Where to go next

If you inherited the home, your basis starts somewhere else. See capital gains on inherited property. The 3.8% tax on high-income investors is on the net investment income tax page.

Questions

How much of my home sale gain is tax free in the United States?

Up to $250,000, or $500,000 for a married couple filing jointly, if you pass the ownership, use and look-back tests.

How long must I live in a home before I sell?

The IRS says a total of 24 months (730 days) in the 5 years before the sale. The months do not have to be in a row.

Can I use the exclusion every year?

No. The IRS says "You may take the exclusion only once during a 2-year period."

Do selling costs lower my gain?

Yes. Sales commissions are subtracted from the sale price to get the amount realized.

Can I deduct a loss on my main home?

No. The IRS says you can't deduct the loss on your main home.

Do I report the sale if all the gain is excluded?

If you get Form 1099-S, yes. Topic 701 says you must report it even if the gain is excludable.

Reminder: this page is for United States, federal rules (IRS); state taxes are not covered

Follow along

XTradingViewFacebook