The primary residence exemption is the main legal way to avoid capital gains tax on a home sale

If you owned and lived in your home as your main residence for at least two of the five years before you sold it, you can exclude up to $250,000 of gain from your taxable income (or $500,000 if you are married filing jointly). This is not a deduction or a deferral — the gain simply does not count as income that year. For most homeowners, this exemption covers the entire profit, which means no federal capital gains tax at all.

The exemption applies only to your primary residence, not to investment properties, vacation homes, or rental units. The IRS defines primary residence as the place where you lived for the majority of the time during the two-year window. You do not have to own the home for two years continuously — you can have owned it for two years total within the five years before sale, with gaps in between.

The gain itself is calculated as the sale price minus your adjusted basis (usually what you paid plus the cost of major improvements, minus depreciation if you ever rented part of it). If your gain is less than $250,000 (or $500,000 if married), you owe no federal capital gains tax on the sale. If your gain exceeds that amount, you pay capital gains tax only on the excess.

Key Takeaways

  • You must have owned and lived in the home as your primary residence for at least two of the five years before sale to use the exemption.
  • The exemption excludes up to $250,000 of gain for single filers or $500,000 for married couples filing jointly from federal income tax.
  • The gain is the sale price minus what you paid plus improvements, so knowing your basis and keeping records of upgrades reduces the taxable amount.
  • Some states also tax capital gains on home sales, so state tax may still apply even if federal tax does not.
  • You can use the exemption only once every two years, so selling multiple properties in quick succession may trigger tax on later sales.

How to calculate whether you owe tax on your home sale

Start with your sale price. Subtract your adjusted basis — what you paid for the home plus the cost of capital improvements (new roof, addition, major renovation) minus any depreciation you claimed if you rented out part of the home. The result is your gain.

If you are single and your gain is $250,000 or less, you owe no federal capital gains tax. If you are married filing jointly and your gain is $500,000 or less, you owe no federal capital gains tax. If your gain exceeds those thresholds, you pay long-term capital gains tax (15% or 20%, depending on your income) only on the amount above the exemption.

Example: You bought a house for $300,000, spent $50,000 on a kitchen and bathroom, and sold it for $600,000. Your basis is $350,000. Your gain is $250,000. If you are single and meet the ownership and residence test, you owe zero federal capital gains tax. If you are married filing jointly, you still owe zero because $250,000 is under the $500,000 limit.

Keep records of what you paid for the home and receipts for any major improvements. The IRS may ask for proof if your gain is close to the exemption limit or if you claim a large basis.

Ownership and residence requirements you must meet

You must have owned the home for at least two of the five years before the sale. Those two years do not have to be consecutive. If you bought the home five years ago and lived in it for two years, then rented it out for three years, you still meet the ownership test as long as you owned it the whole time.

You must have lived in the home as your primary residence for at least two of the five years before the sale. Primary residence means the place where you spent the majority of your time. If you lived there for one year, moved to another state for three years, then moved back and lived there for one more year, you meet the two-year residence test.

You can use the exemption only once every two years. If you sold a home and used the exemption two years ago, you can use it again on a new home sale now. If you sold a home one year ago and used the exemption, you cannot use it again until two years have passed from that sale.

If you did not meet the two-year test because of a job change, health condition, or unforeseen circumstance, you may be able to claim a reduced exemption (a fraction of $250,000 or $500,000). This requires filing Form 8949 and attaching a statement explaining the circumstance. The IRS has specific rules about what qualifies, so consult a tax professional if this applies to you.

State capital gains taxes on home sales

Federal capital gains tax is only part of the picture. Some states also tax capital gains on home sales, and the primary residence exemption does not apply to state tax.

California, New York, Oregon, and several other states tax long-term capital gains as ordinary income. If you live in one of these states and your gain exceeds the federal exemption, you will owe state tax on the gain even if you owe no federal tax. The state tax rate depends on your total income and the state's tax brackets.

A few states — including Washington, Tennessee, and Illinois — tax capital gains but may have their own exemptions or different rules for home sales. Check your state's tax authority website or speak with a tax professional in your state to learn what applies to you.

If you are moving out of state before or after the sale, the state where you lived when you sold the home is the one that taxes the gain. If you lived in California when you sold and are moving to Texas (which has no capital gains tax), California still taxes the gain from the sale.

When you cannot use the primary residence exemption

If you did not own the home for two of the five years before sale, you cannot use the exemption. If you bought the home one year ago and are selling now, you do not may have access to. If you inherited the home and sold it within a year, you do not may have access to.

If you did not live in the home as your primary residence for two of the five years before sale, you cannot use the exemption. If you bought the home as an investment property and rented it out the whole time, you do not may have access to. If you lived there for one year and then rented it out for four years, you do not may have access to.

If you already used the exemption on another home sale within the past two years, you cannot use it again. You must wait two years from the date of the previous sale to use the exemption on a new sale.

If you excluded gain from a home sale under the old rules (before 1997) or used a one-time exclusion for people over 55, you may not be able to use the current exemption. The rules changed in 1997, and older exclusions do not carry over. A tax professional can review your history if you are unsure.

What happens if your gain exceeds the exemption

If your gain is more than $250,000 (single) or $500,000 (married), you pay long-term capital gains tax on the excess. Long-term capital gains rates are 0%, 15%, or 20%, depending on your total income for the year. These rates are lower than ordinary income tax rates, which is why the exemption is valuable — even the taxable portion is taxed at a favorable rate.

The tax is due when you file your federal income tax return for the year of the sale. You report the sale on Form 8949 (Sales of Capital Assets) and Schedule D (Capital Gains and Losses), then transfer the result to your main tax return (Form 1040).

If you owe state capital gains tax, you report and pay that separately on your state return. State deadlines usually match federal deadlines (April 15 of the following year, or later if you file an extension).

Strategies to reduce the taxable gain

Keep detailed records of what you paid for the home and every major improvement you made. Capital improvements (new roof, addition, major renovation, new HVAC system) add to your basis and reduce your gain. Repairs and maintenance (painting, fixing a leak, replacing a broken window) do not count as improvements and do not reduce your gain. The difference matters: a $20,000 kitchen renovation counts; a $5,000 repair does not.

If you rented out part of the home or used part of it for business, you may have claimed depreciation on your tax returns. That depreciation reduces your basis and increases your gain. When you sell, you will owe tax on the depreciation you claimed, even if you used the primary residence exemption on the rest of the gain. This is called depreciation recapture and is taxed at 25% (higher than the long-term capital gains rate). If you are considering renting out part of your home, understand this cost before you do.

If your gain is close to the exemption limit, timing the sale can matter. If you are near the end of the two-year ownership or residence window, waiting a few months to cross the threshold ensures you may have access to. If you are near the two-year mark since your last home sale, waiting to cross that mark lets you use the exemption again.

Frequently Asked Questions

Do I have to live in the home for two full years before I sell?

No. You must have lived in it for two of the five years before the sale, but those years do not have to be consecutive or recent. You could have lived there for two years, moved away for three years, and sold it now — you still may have access to. The five-year window looks back from the sale date.

What if I inherited my home and sold it right away?

You do not meet the two-year ownership or residence test, so you cannot use the primary residence exemption. However, inherited property receives a "step-up in basis," meaning your basis is the home's fair market value on the date of death, not what the previous owner paid. If you sell shortly after inheriting, your gain is usually small or zero, so you may owe little or no tax anyway.

Can I use the exemption if I'm selling a rental property I used to live in?

Only if you lived in it as your primary residence for at least two of the five years before the sale. If you lived there for three years and then rented it out for two years before selling, you may have access to. If you lived there for one year and rented it out for four years, you do not. Any depreciation you claimed while renting it out is recaptured and taxed at 25%, even if the rest of the gain is exempt.

What if I'm married but filing separately?

If you are married and file separately, each spouse can exclude only $250,000, not $500,000. Filing separately usually costs more in taxes overall, so consult a tax professional before choosing this route.

Do I have to report the sale to the IRS even if I owe no tax?

Yes. You report the sale on Form 8949 and Schedule D, even if the entire gain is exempt. The IRS wants to see the calculation and confirm you meet the exemption requirements. Failing to report it can trigger an audit.