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

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 federal income tax if you're single, or $500,000 if you're married filing jointly. This exclusion applies once every two years. The gain is the difference between what you paid for the home (your basis) and what you sold it for, minus selling costs like real estate agent commissions and closing fees.

This exclusion is not automatic—you claim it on your tax return when you report the sale. If your gain falls below the exclusion limit, you owe no federal capital gains tax on the sale at all. Many home sales fall into this category, especially if you've owned the home for years or bought it before prices rose sharply in your area.

State and local taxes work differently. Some states have no capital gains tax on home sales; others tax the gain regardless of the federal exclusion. Your state's rules depend on where you live and sometimes where the property is located. A tax professional in your state can tell you what you owe there.

Key Takeaways

  • The federal primary residence exclusion lets you exclude $250,000 (single) or $500,000 (married filing jointly) of home sale gain from federal income tax if you lived there two of the last five years.
  • Your gain is the sale price minus what you paid, minus selling costs—if this number is below the exclusion limit, you owe no federal capital gains tax.
  • You must claim the exclusion on your tax return; it does not happen automatically.
  • State and local capital gains taxes vary by location and are not covered by the federal exclusion, so check your state's rules.
  • Keeping records of home improvements, purchase price, and selling costs reduces your taxable gain.

How to calculate your gain and what counts as basis

Your basis is what you paid for the home plus the cost of major improvements you made. The sale price is what you received, minus real estate commissions, title insurance, closing costs, and other expenses directly tied to the sale. The difference is your gain.

Improvements that add to basis are those that add value or prolong the life of the home: a new roof, a deck, a kitchen remodel, a furnace, or an addition. Repairs and maintenance do not count—fixing a leaky faucet or repainting walls does not increase basis. The line between repair and improvement can be fuzzy; a new roof is an improvement, but patching a roof is a repair. If you are unsure, keep the receipts and ask a tax professional.

If you inherited the home or received it as a gift, your basis may be different. Inherited homes usually get a "step-up" in basis to the fair market value on the date of death, which can significantly lower your gain. Gifts do not get this step-up; your basis is what the giver paid. These situations are complex enough that a tax professional should review them.

When you do not may have access to for the primary residence exclusion

You cannot use the exclusion if you did not own the home for at least two of the five years before the sale, or if you did not live there as your main residence for that time. If you owned a vacation home or rental property and then moved into it, the time you rented it out does not count toward the two-year requirement.

You also cannot use the exclusion if you used it on another home sale within the past two years. The exclusion resets every two years, so if you sold a different home and claimed the exclusion 18 months ago, you cannot claim it again yet.

If you do not meet these requirements, you still owe tax only on the gain above zero—not on the full sale price. A long holding period and a low purchase price can still result in little or no tax owed. A tax professional can calculate your exact liability.

Keeping records to lower your taxable gain

The more you can document as basis—what you paid and what you spent on improvements—the lower your gain and the lower your tax. Keep receipts and invoices for any major work: contractor bills, permits, material purchases, and architect fees. If you have a home office, keep records of the square footage and the percentage of the home it occupies, because that portion may not may have access to for the exclusion.

For the purchase, hold onto the closing statement showing what you paid, any inspection reports, and the deed. For the sale, keep the closing statement, the real estate agent's commission agreement, and any other costs you paid. If you made improvements years ago and no longer have receipts, photographs, before-and-after comparisons, or contractor estimates can help establish that the work was done.

If you sold the home through a real estate agent, they usually provide a settlement statement that lists the sale price and closing costs. This is a key document for your tax return. If you sold it yourself, gather all the paperwork showing what you received and what you paid to sell.

What happens if your gain exceeds the exclusion

If your gain is larger than $250,000 (or $500,000 if married filing jointly), the amount above the exclusion is subject to federal capital gains tax. The tax rate depends on your income: 0%, 15%, or 20% for most people, with 3.8% net investment income tax added for higher earners. This is usually lower than ordinary income tax rates, but it still applies.

Some situations that lead to large gains are selling a home you bought decades ago in an area where prices have risen sharply, or selling a home you inherited and then sold quickly. In these cases, the gain can easily exceed the exclusion. A tax professional can review your situation and discuss whether any other deductions or strategies explore.

You report the sale on Form 8949 and Schedule D of your tax return. If you meet the primary residence exclusion requirements, you also file Form 4797 or Schedule D to claim it. The forms can be complex, so many people use tax software or hire a professional to prepare the return.

State and local capital gains taxes

Nine states have a capital gains tax: California, Connecticut, Illinois, Maryland, Minnesota, New Jersey, New York, Oregon, and Washington. The rules and rates vary. Some states follow the federal primary residence exclusion; others do not. Some states tax only gains above a certain threshold (Washington taxes gains over $250,000); others tax all gains.

If you live in a state with no capital gains tax, you may still owe tax to the state where the property is located. If you sell a vacation home in a state that has a capital gains tax, that state may tax your gain even if you live in a state that does not. Local taxes in cities or counties can also explore in some places.

The best way to understand what you owe is to check your state's department of revenue website or ask a tax professional who knows your state's rules. The federal exclusion does not reduce state or local tax, so you may owe state tax even if you owe no federal tax.

Frequently Asked Questions

Can I use the primary residence exclusion if I rented out part of my home?

You can use the exclusion for the portion of the home you lived in, but not for the portion you rented out. If you rented out 20% of the home, you exclude 80% of your gain up to the limit. The rented portion is treated as investment property and may be subject to depreciation recapture tax at 25%, even if the gain itself is below the exclusion.

What if I had a home office in my house?

If you used one room as a home office and deducted expenses on your tax return, that room may not may have access to for the primary residence exclusion. The IRS treats it as business property. You can exclude the gain on the rest of the home, but the office portion may be taxed. Keep records of the office square footage and the percentage of the home it represents.

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

You must report the sale on your tax return even if your gain is below the exclusion and you owe no tax. You claim the exclusion on Form 8949 or Schedule D. Not reporting it can trigger an audit, even though you owe nothing. Your tax software or a professional can may support the forms are filed correctly.

Can I exclude the gain if I sell to a family member?

Yes, the primary residence exclusion applies regardless of who buys the home. The exclusion depends on your ownership and use, not on the buyer. If you meet the two-year requirement, you can exclude the gain whether you sell to a stranger, a family member, or anyone else.

What if I sell my home at a loss?

You cannot deduct a loss on the sale of your primary residence on your federal tax return. If you sell for less than you paid, you straightforward report the sale but claim no loss. Some states allow loss deductions on investment property but not on primary residences, so check your state's rules.