How to Avoid Capital Gains Tax on a House Sale

The cleanest way to avoid capital gains tax on a house sale is the federal primary residence exclusion: if you owned and lived in the home as your main residence for at least two of the five years before selling, you can exclude up to $250,000 of profit from your taxable income, or up to $500,000 on a joint return.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence When your profit runs higher than that, you can still shrink the taxable portion by adding qualifying improvements to your cost basis, subtracting selling expenses, and paying attention to the year you sell.

The Section 121 Primary Residence Exclusion

The exclusion is the single largest tax break most homeowners will ever use. A single filer keeps up to $250,000 of gain off the return. Married couples filing jointly keep up to $500,000, provided both spouses meet the two-year use test and at least one meets the two-year ownership test.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence

The two years of residency don’t have to be back-to-back. Twelve months, a year away, another twelve months back — that works. What the law asks is that your time living in the home as your primary residence adds up to 24 months inside the five-year window ending on the sale date.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence

One caveat: you can only use this exclusion once every two years. If you already excluded gain from a different home sale in the past 24 months, you cannot use it again until that window closes.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence Anything above the exclusion limit is taxed at long-term capital gains rates.

Partial Exclusion When Life Forces an Early Sale

If you sell before hitting the full two years, a partial exclusion may still be available when the sale is driven by a job move, a health issue, or an unforeseen event.2Internal Revenue Service. Publication 523 – Selling Your Home The amount you can exclude is prorated: live in the home for 12 of the required 24 months, and you get half the maximum, meaning $125,000 for a single filer or $250,000 for a joint return.

Each reason has its own test. A qualifying job change means your new workplace is at least 50 miles farther from the home than your old one was, or, if you had no previous job, at least 50 miles from the home. A qualifying health reason is a move for the diagnosis, treatment, or care of a disease or injury affecting you, your spouse, a co-owner, or certain family members. Unforeseen circumstances include divorce or legal separation, the death of a resident, multiple births from a single pregnancy, a natural disaster that destroys or condemns the home, and becoming eligible for unemployment compensation.2Internal Revenue Service. Publication 523 – Selling Your Home

IRS Publication 523 includes worksheets that walk through the exact partial exclusion calculation for your situation.

Extra Time for Military and Foreign Service

Members of the uniformed services, the Foreign Service, and the intelligence community can suspend the five-year lookback for up to 10 years while on qualified official extended duty. Qualified extended duty means being stationed at least 50 miles from your main home, or living in government housing under orders, for more than 90 days.3Internal Revenue Service. Topic No. 701 – Sale of Your Home With the suspension, you effectively have up to 15 years to accumulate the two years of use required for the full exclusion.4eCFR. 26 CFR 1.121-5 – Suspension of 5-Year Period for Certain Members of the Uniformed Services and Foreign Service

Shrink the Gain Before You Apply the Exclusion

Your taxable gain is not the raw sale price minus what you originally paid. Two adjustments can bring the number down meaningfully, and both are worth documenting before the closing.

Capital Improvements Raise Your Basis

Cost basis starts with the purchase price and certain closing costs. Every qualifying improvement you make while you own the home adds to that basis, and a higher basis means a smaller gain. The IRS separates improvements, which add value, extend the home’s useful life, or adapt it to a new use, from routine repairs and maintenance, which do not.2Internal Revenue Service. Publication 523 – Selling Your Home

Qualifying work typically includes:

  • Adding a bedroom, bathroom, deck, garage, or porch
  • Replacing the roof or siding
  • Installing central air conditioning, a new heating system, or a security system
  • Kitchen modernization or new built-in appliances
  • Paving a driveway, adding a fence, or landscaping
  • Adding insulation, storm windows, or new flooring2Internal Revenue Service. Publication 523 – Selling Your Home

Say you bought a home for $300,000, put $50,000 into a kitchen remodel, and spent $15,000 on a new roof. Your adjusted basis is $365,000. Sell for $600,000, and your gain is $235,000 rather than $300,000. For a single filer, that entire gain now sits under the $250,000 exclusion. Keep receipts, contracts, and permits for every improvement at least three years past the return that reports the sale.

Selling Expenses Come Off the Sale Price

Selling expenses reduce the amount realized before any gain is calculated. Deductible items include real estate agent commissions, legal fees connected to the sale, advertising costs, transfer or stamp taxes paid by the seller, and mortgage points or loan charges you paid that would normally fall on the buyer.2Internal Revenue Service. Publication 523 – Selling Your Home

On a $600,000 sale with $36,000 in commissions and $3,000 in legal fees and transfer taxes, your amount realized is $561,000, not $600,000. That $39,000 reduction can be what keeps the whole transaction inside the exclusion.

Inherited Homes and the Step-Up in Basis

An inherited home gets a fresh basis equal to the fair market value on the date the previous owner died, not the price that owner originally paid. This is the step-up in basis.5Office of the Law Revision Counsel. 26 USC 1014 – Basis of Property Acquired From a Decedent A parent’s $100,000 purchase decades ago that was worth $400,000 at death gives you a $400,000 starting basis. Decades of appreciation before the inheritance effectively wash out.

Selling shortly after inheriting usually produces a small gain because the sale price and stepped-up basis are close. The executor may instead elect a valuation date up to six months after death if that produces a better result for the estate.6Internal Revenue Service. Gifts and Inheritances Inherited property is also treated as long-term for capital gains purposes no matter how briefly you hold it before selling.

Rental Conversions and Depreciation Recapture

You can convert a rental property into your primary residence and then use Section 121 when you sell, but the exclusion does less work than it does for a straightforward home. You still need two of five years of use as your main home.2Internal Revenue Service. Publication 523 – Selling Your Home On top of that, any period after 2008 when the property was not used as your main home counts as “nonqualified use,” and a proportionate share of the gain tied to that time is not excludable.7Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence Rent for eight years, live there for two, and roughly 80 percent of the gain remains taxable.

The rule has a favorable edge. Time after you stop using the home as your primary residence — for example, moving out and renting it briefly before selling — does not count as nonqualified use. The provision targets rental-first, residence-second patterns, not the reverse.7Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence

Depreciation is its own carve-out. If you claimed depreciation on any part of the home — a home office, a rented-out unit — gain equal to the depreciation you took after May 6, 1997 must be recaptured and reported as ordinary income, at a rate capped at 25 percent. The Section 121 exclusion does not cover it.2Internal Revenue Service. Publication 523 – Selling Your Home8Internal Revenue Service. Topic No. 409 – Capital Gains and Losses Skipping the deduction does not help: the recapture applies to depreciation “allowed or allowable,” so the IRS treats you as if you took what you were entitled to whether you claimed it or not.

One boundary worth noting: like-kind exchanges under Section 1031, which let sellers defer gain by rolling proceeds into another property, apply to real estate held for investment or business use. They are not available for the sale of a personal residence.9Office of the Law Revision Counsel. 26 USC 1031 – Exchange of Real Property Held for Productive Use or Investment

What You Owe on Any Leftover Gain

Profit that exceeds the exclusion, or that never qualified for one, is taxed at federal long-term capital gains rates when you owned the home for more than a year.8Internal Revenue Service. Topic No. 409 – Capital Gains and Losses The rate depends on your total taxable income and filing status. For 2026:

  • 0 percent on taxable income up to $49,450 (single), $98,900 (married filing jointly), or $66,200 (head of household)
  • 15 percent above those thresholds and up to $545,500 (single), $613,700 (married filing jointly), or $579,600 (head of household)
  • 20 percent above the 15 percent ceiling

The 0 percent bracket is easy to overlook. A retiree with modest other income can see part or all of the non-excluded gain taxed at nothing. Timing a sale for a low-income year is one of the more effective planning moves left after the exclusion is applied. These thresholds adjust each year for inflation.

Homes owned a year or less produce short-term gain, taxed at your ordinary income rates.

The 3.8 Percent Net Investment Income Tax

A separate 3.8 percent tax on net investment income applies when your modified adjusted gross income exceeds $250,000 (married filing jointly), $200,000 (single or head of household), or $125,000 (married filing separately). These thresholds do not adjust for inflation.10Office of the Law Revision Counsel. 26 USC 1411 – Imposition of Tax

Gain excluded under Section 121 is not hit by this tax. Only the portion of gain that ends up in your taxable income can be. And the tax applies to the lesser of net investment income or the amount by which income exceeds the threshold.11Internal Revenue Service. Questions and Answers on the Net Investment Income Tax A married couple with $275,000 in modified adjusted gross income and $100,000 of non-excluded gain owes 3.8 percent on $25,000, or $950.

When You Have to Report the Sale

Not every home sale needs to appear on your return. If the exclusion covers the entire gain, you did not receive a Form 1099-S at closing, and you are not choosing to report voluntarily, you can leave the sale off the return.2Internal Revenue Service. Publication 523 – Selling Your Home

You do need to report the sale if any of these apply:

  • Part of the gain is taxable because it exceeds the exclusion.
  • You received a Form 1099-S, even if all the gain is excludable.
  • You want to report the gain — for example, to offset capital losses.2Internal Revenue Service. Publication 523 – Selling Your Home

Reportable sales go on Form 8949 with the purchase date, sale date, sale price, and adjusted basis. Excluded gain is entered with adjustment code “H” and shown as a negative number.12Internal Revenue Service. Instructions for Form 8949 Form 8949 totals carry to Schedule D of Form 1040, where the year’s overall capital gain or loss is calculated.13Internal Revenue Service. About Form 8949 – Sales and Other Dispositions of Capital Assets Hold on to the settlement statement, improvement receipts, and records of selling expenses for at least three years after you file the return that includes the sale.