The main way to avoid capital gains tax on a house sale is the primary residence exclusion

If you own and live in a home as your primary residence for at least two of the five years before you sell, you can exclude up to $250,000 of gain from federal tax if you file single, or $500,000 if you file married filing jointly. This exclusion applies once every two years. For most homeowners, this single rule eliminates the tax bill entirely, because the gain on a primary residence often falls below these thresholds.

The exclusion is automatic — you do not need to do anything special to claim it beyond meeting the two-year ownership and use test. You report the sale on Schedule D (Form 1040) and then claim the exclusion on Form 8949. If your gain is less than the exclusion amount, you owe no federal capital gains tax on the sale.

This is different from investment property or a second home, where no such exclusion exists. The exclusion only applies to a home you actually lived in, not one you rented out or held purely for investment.

Key Takeaways

  • The primary residence exclusion lets you exclude $250,000 (single) or $500,000 (married) of gain if you lived in the home for two of the last five years before selling.
  • If your gain falls below the exclusion amount, you owe no federal capital gains tax, and many homeowners never owe tax on a home sale.
  • You can use the exclusion once every two years, so you can sell multiple homes over time and use it for each one if you meet the test.
  • Timing your sale to meet the two-year test, or moving back into a rental property before selling, can make the difference between owing tax and owing nothing.
  • State capital gains taxes on real estate vary widely — some states have none, while others tax the full gain regardless of the federal exclusion.

When the two-year test is broken and how to fix it

If you sell before you have lived in the home for two of the last five years, you lose the exclusion entirely and owe tax on the full gain. This happens most often when someone buys a home, gets transferred for work, and sells within a year or two. The IRS does allow exceptions for unforeseen circumstances — a job change, health crisis, or natural disaster — but you must meet specific conditions and file Form 8801 to claim the reduced exclusion.

If you own a home but have moved out and rented it to tenants, you can move back in and restart the clock. You need to live there for two years before selling to reclaim the exclusion. This is useful if you inherited a rental property or converted a primary residence to a rental: moving back in for two years before sale can save you tens of thousands in tax.

The two-year test is measured in the five years before the sale date. If you sold a home and used the exclusion two years ago, you can use it again now on a new home, as long as you meet the two-year occupancy test for this one.

How to handle a gain larger than the exclusion

If your gain exceeds $250,000 (or $500,000 if married), the excess is taxable. The tax rate depends on your total income for the year. Long-term capital gains rates are 0%, 15%, or 20% at the federal level, depending on your tax bracket. A married couple filing jointly with taxable income up to $89,250 pays 0% on long-term gains; from $89,251 to $553,850 pays 15%; and above that pays 20%.

One strategy is to spread the sale across two tax years. If you close the sale in late December but the buyer does not take possession until January, you may be able to report the gain in the following year. This shifts income to a year when your other income is lower, potentially keeping you in a lower tax bracket. Your tax professional and real estate attorney can advise whether this timing works for your situation.

Another option is to use installment sale reporting, where the buyer pays you over multiple years instead of all at once. You report the gain proportionally as you receive payments, which can spread the tax across several years and keep your annual income lower in each year.

State capital gains taxes on real estate

Federal capital gains tax is only part of the picture. Many states also tax capital gains on real estate, and the rules vary widely. Some states — including Florida, Texas, Washington, and Wyoming — have no capital gains tax at all. Others, like California and New York, tax long-term gains at the same rate as ordinary income, which can be 10% or higher.

A few states tax capital gains only on investments like stocks and bonds, not on real estate. Others have a separate capital gains tax that applies to all assets. You need to know the rule in the state where the property is located and the state where you live, because you may owe tax to both.

If you are considering a move, the state tax difference can be substantial. Selling a home with a $200,000 gain in California could cost you $20,000 or more in state tax, while the same sale in Florida costs nothing. This is worth factoring into the decision to move or to time a sale around a relocation.

Inherited homes and the step-up in basis

If you inherit a home, the cost basis is "stepped up" to the fair market value on the date of the owner's death. This means if your parent bought the home for $100,000 and it was worth $400,000 when they died, your basis is $400,000. If you sell it a few months later for $410,000, your gain is only $10,000, not $310,000.

This step-up applies whether or not you lived in the home. You do not need to meet the two-year occupancy test to use it. The step-up is one of the largest tax breaks available, and it often eliminates capital gains tax on inherited real estate entirely.

The step-up applies to the date of death, not the date you inherit or sell. If the home appreciates after the death but before you sell, that new appreciation is taxable gain. If you hold the inherited home for two years and then sell, you can also claim the primary residence exclusion if you lived there during that time, which stacks on top of the step-up benefit.

Charitable donation of appreciated property

If you own a home with a large gain and want to donate it to a may have access to charity, you can deduct the full fair market value and owe no capital gains tax on the appreciation. This works only if the charity is a may have access to organization — typically a nonprofit with 501(c)(3) status — and you itemize deductions on your tax return.

The deduction is limited to 30% of your adjusted gross income in the year of the donation, with a five-year carryforward for the excess. You will need a may have access to appraisal and a Form 8283 to claim the deduction. This strategy makes sense only if the gain is very large and you have other reasons to donate the property, because you are giving up the home itself.

Timing a sale to manage your tax bracket

Capital gains tax is tied to your total income for the year. If you are near the edge of a tax bracket, delaying or accelerating the sale by a few months can move you into a lower bracket and reduce your rate from 15% to 0%, or from 20% to 15%.

For example, if you are married filing jointly with $85,000 in other income, you have $4,250 of room before you hit the 15% bracket at $89,250. If your home sale will generate a $50,000 gain, you could sell now and pay 0% on the first $4,250 and 15% on the remaining $45,750. If you can defer the sale to next year when your other income is lower, you might pay 0% on the entire gain.

This strategy requires coordination with your accountant and real estate timeline. It works best if you have flexibility on when to close, or if you are considering selling in one year versus another. It does not work if the sale is urgent or if you have no control over the closing date.

Frequently Asked Questions

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

No. You need to have lived there for two of the five years before the sale, but those two years do not have to be consecutive or when ready before the sale. You could live there for two years, move out, rent it for three years, and then sell — you still may have access to. The test is two years of occupancy within the five-year window.

What if I am married but file separately?

If you file married filing separately, each spouse can exclude only $125,000 of gain, for a combined $250,000. Filing separately almost always costs more in tax than filing jointly, so this is rarely the right choice. Consult a tax professional if you are considering separate filing.

Can I use the exclusion on a second home or investment property?

No. The exclusion applies only to a home you owned and lived in as your primary residence for at least two of the five years before the sale. A vacation home, rental property, or home you inherited does not may have access to, even if you later move into it. The step-up in basis for inherited property is a separate benefit that can help, but it is not the same as the primary residence exclusion.

What happens if I sell at a loss?

Capital losses on personal residences cannot be deducted. If you sell your home for less than you paid for it, you straightforward report the loss and move on — it does not reduce your other income or tax. This is the opposite of investment property, where losses can offset gains.

Do I need to report the sale if my gain is below the exclusion amount?

You still report the sale on Schedule D and Form 8949, but if the gain is below your exclusion amount, you will owe no tax. Reporting it is required even if the tax is zero, because the IRS needs to see that you claimed the exclusion correctly.