Skip to main content

Capital Gains Tax on a Home Sale: What It Is and When You Owe It

Most sellers of a primary residence owe nothing thanks to a large exclusion. Here are the tests you must pass and how to compute the gain properly.

Written and maintained by Víctor Gil VázquezData last verified: 08/30/2026

Selling a home for far more than you paid is a taxable event in principle, and for most sellers of a primary residence it produces no federal tax at all. The reason is a specific and generous exclusion — and the reason it sometimes fails is that people misunderstand what the gain actually is.

The exclusion

Internal Revenue Code section 121 lets you exclude up to $250,000 of gain on the sale of your main home if you file single, and up to $500,000 if you are married filing jointly.

These amounts have not been indexed for inflation since they were set, which is quietly significant. A $500,000 exclusion covered essentially any residential gain when it was enacted; after decades of home price appreciation in high-cost markets, long-tenured owners increasingly exceed it.

The two tests you must pass

The ownership test: you owned the home for at least two years during the five-year period ending on the sale date.

The use test: you lived in it as your main home for at least two years during that same five-year period.

The two-year periods need not be continuous, and they need not be the same two years, as long as both fall inside the five-year window. There is also a look-back rule: you generally cannot claim the exclusion if you already claimed it on another home sale within the two years before this sale.

For married couples filing jointly, either spouse can satisfy the ownership test, but both must satisfy the use test to get the full $500,000. If only one spouse lived there, the exclusion drops to $250,000.

Computing the gain correctly

The single most common error is measuring the gain against the mortgage. The loan has nothing to do with it. A seller who owes $50,000 on a home bought for $300,000 and sold for $400,000 has a $100,000 gain, not a $350,000 one.

Start with the amount realized: sale price minus selling costs — agent commissions, transfer taxes, title fees, and similar closing charges paid by the seller.

Then compute adjusted basis: original purchase price, plus certain costs of acquisition, plus every qualifying capital improvement you made over the years of ownership.

Gain is amount realized minus adjusted basis. Work an example. Bought at $320,000, spent $75,000 across a roof, a kitchen, and central air, so adjusted basis is $395,000. Sold at $700,000 with $45,000 of selling costs, so amount realized is $655,000. Gain is $260,000 — comfortably inside a joint filer's exclusion, and $10,000 over a single filer's.

Why keeping improvement receipts pays

Capital improvements raise your basis and therefore reduce the gain dollar for dollar. Work that adds value, prolongs the home's useful life, or adapts it to new uses qualifies: additions, a new roof, a full kitchen or bathroom remodel, new HVAC, a finished basement, landscaping that is a permanent improvement.

Repairs and maintenance do not qualify: repainting, fixing a leak, replacing a broken window pane. The line is between restoring and improving.

In the example above, the $75,000 of improvements moved $75,000 straight out of the taxable gain. A single filer who lost those receipts would face a $85,000 gain instead of $10,000. Twenty years of paperwork discipline is worth real money at exactly one moment.

What you owe if you exceed the exclusion

Gain above the exclusion is a long-term capital gain, assuming you owned the home more than a year. For 2026, long-term rates are 0% on taxable income up to $49,450 for single filers and $98,900 for married filing jointly, 15% up to $545,500 and $613,700, and 20% above.

Importantly, the thresholds apply to your total taxable income including the gain, so a large home sale gain can push you into the 15% or 20% band even if your ordinary income would not.

A 3.8% net investment income tax may also apply to gain above the exclusion once modified adjusted gross income exceeds $200,000 for single filers or $250,000 for married filing jointly. And state tax is separate — some states tax capital gains as ordinary income, and a few have no income tax at all.

The special situations worth knowing

A partial exclusion is available if you fail the two-year test for a qualifying reason — a change in place of employment, a health-related move, or certain unforeseen circumstances the IRS defines. The exclusion is prorated by the fraction of the two-year period you completed, so eighteen months of a required twenty-four could still shelter three-quarters of the normal amount.

If the home was ever a rental, depreciation you claimed or could have claimed is recaptured and is not covered by the exclusion. Periods of non-qualified use after 2008 can also reduce the excludable portion.

And a loss on the sale of a personal residence is not deductible, which strikes many sellers as unfair given the gain is taxable above the exclusion. It is nonetheless the rule.

This is educational information about how the rules are structured. A sale involving rental history, a partial exclusion claim, or a gain near the threshold is worth running past a CPA before you file.

Put it into practice

Try the Capital Gains Tax on Home Sale Calculator

Frequently asked questions

How much home sale gain is excluded from tax?

Up to $250,000 of gain for a single filer and $500,000 for a married couple filing jointly, under Internal Revenue Code section 121. These amounts are set in statute and are not adjusted for inflation, which means they cover a shrinking share of a typical gain over time.

What are the ownership and use tests?

You must have owned the home for at least two of the five years before the sale, and lived in it as your main home for at least two of those same five years. The two-year periods do not have to be continuous or simultaneous. You generally cannot have used the exclusion on another home sale in the two years before this one.

How do I calculate the gain?

Sale price minus selling costs gives the amount realized. Purchase price plus qualifying capital improvements plus certain purchase costs gives the adjusted basis. The gain is the difference. Note that the gain is measured against your basis, not against your mortgage balance — the loan is irrelevant to the calculation.

What counts as a capital improvement I can add to basis?

Work that adds value, prolongs the home's life, or adapts it to new uses — a new roof, an addition, a kitchen remodel, central air, a finished basement. Routine repairs and maintenance do not count. Keeping the receipts matters, because improvements raise your basis and directly reduce a taxable gain decades later.

What if I do not meet the two-year test?

A partial exclusion may still apply if the sale was due to a change in place of employment, health, or certain unforeseen circumstances defined by the IRS. The exclusion is prorated by the fraction of the two-year period you did satisfy, which can still shelter a substantial gain.