Guides

Capital Gains Tax When You Sell Your Home

One of the first questions sellers ask is whether the IRS gets a slice of the profit. For most people selling a primary residence, the answer is no — but the rules have edges, and the math is not as intuitive as 'sale price minus what I paid.'

Data last reviewed: June 2026

What capital gains tax actually taxes

Capital gains tax applies to the gain on the sale of a capital asset, not the sale price. For a home, the gain is what's left after you subtract your adjusted cost basis and your selling costs from the price the buyer pays. Your remaining mortgage balance does not enter the calculation at all — paying off a loan is not a taxable event.

The headline rule for homeowners is Section 121 of the Internal Revenue Code, often called the "home sale exclusion." If the home is your primary residence and you meet the ownership and use tests, you can exclude up to $250,000 of gain if you file single and $500,000 if married filing jointly. Anything above that is taxed at long-term capital gains rates (0%, 15%, or 20% federal, plus state tax where applicable).

The ownership and use tests

To claim the full exclusion you generally must satisfy both of these during the five years ending on the sale date:

  • Ownership test. You owned the home for at least two years (730 days). The two years do not have to be continuous.
  • Use test. You used the home as your main residence for at least two years. Time as a vacation home or rental does not count.
  • Frequency limit. You haven't excluded gain on the sale of another home in the two years immediately before this sale.

Married couples filing jointly need only one spouse to meet the ownership test, but both must meet the use test to claim the full $500,000.

Partial exclusion for life-event sales

If you sell before hitting two years, you may still qualify for a prorated exclusion when the move is driven by a qualifying reason — a job relocation that meets the IRS distance test, a health-related move, or certain unforeseen circumstances (divorce, the birth of twins, a natural disaster, job loss with unemployment benefits, etc.). The exclusion is reduced in proportion to how much of the two-year period you completed.

How to compute your taxable gain

The arithmetic, in order:

  • Start with the sale price. The contract price the buyer pays.
  • Subtract selling expenses. Agent commission, transfer taxes you paid, owner's title insurance if you paid for it, attorney fees, and other reasonable closing costs. This gives your amount realized.
  • Subtract your adjusted basis. Original purchase price, plus qualifying closing costs from the purchase, plus the cost of capital improvements (a new roof, an addition, a kitchen remodel) — not ordinary repairs.

Whatever is left is your gain. Apply the exclusion. Tax the rest at long-term capital gains rates (assuming you owned more than one year). Add state income tax in states that have one, and the 3.8% Net Investment Income Tax if your income is high enough.

Why keeping improvement records matters

Every dollar of capital improvement you can document raises your basis and lowers your gain. After a couple of decades of ownership in an appreciating market, this can be the difference between comfortably under the exclusion and owing real tax. Receipts, contracts, and permits are worth keeping for as long as you own the property plus three to seven years after the sale.

Common situations that complicate the calculation

  • Inherited home. Your basis is generally the fair market value on the date of death (a "stepped-up basis"), which often wipes out most or all of the gain.
  • Gifted home. Your basis is generally the giver's basis — there's no step-up — so the gain can be much larger.
  • Divorce sale. Transfers between spouses incident to divorce are not taxable, and the receiving spouse takes the other's basis. Selling after divorce may affect which exclusion limit you use.
  • Home office or rental use. Depreciation claimed (or allowable) while part of the home was used for business or rented out is recaptured at up to 25% — even if your gain is otherwise excluded.
  • Second homes and investment property. No Section 121 exclusion. The full gain is taxable, though a 1031 exchange may defer it for true investment property.

How this fits with your net proceeds

Capital gains tax is filed with your return the year after the sale — it does not come out of your closing statement. Our home seller net proceeds calculator shows what actually hits your bank account at closing: sale price minus commission, transfer taxes, title costs, and your mortgage payoff. If you expect to owe capital gains, set aside the estimated tax from those proceeds rather than spending the full wire. For a worked example with state-specific defaults, try the California calculator or the Texas calculator.

When to talk to a tax professional

The exclusion handles a clean sale of a long-held primary residence. Talk to a CPA or enrolled agent if any of the following apply: you've rented the home, taken a home-office deduction, inherited or been gifted the property, are selling shortly after buying, or expect gain well above the exclusion. The cost of an hour of professional advice is small compared to a tax bill you didn't plan for. For broader seller costs, our companion guide on seller closing costs walks through everything else that comes out of your proceeds.

This article is general information, not tax advice. Verify your specific situation with a qualified tax professional or the current IRS guidance.

Frequently asked questions

Do I have to pay capital gains tax when I sell my house?

Most homeowners selling a primary residence don't. If you qualify for the IRS Section 121 exclusion, the first $250,000 of gain ($500,000 for married filing jointly) is excluded from federal income tax. Only gain above that threshold is taxed.

How is the gain on my home sale calculated?

Gain equals your amount realized (sale price minus selling costs) minus your adjusted cost basis (original purchase price plus capital improvements and certain closing costs from the purchase). It is not the difference between your sale price and your mortgage payoff.

What is the 2-out-of-5-year rule?

To use the full exclusion, you generally must have owned the home and used it as your main home for at least two of the five years ending on the sale date. Partial exclusions exist for moves due to a change in employment, health, or unforeseen circumstances.

Does the home sale exclusion apply to rental property?

Not directly. A pure rental or investment property doesn't qualify, and depreciation taken (or allowed) while it was a rental is recaptured. A home that was a rental and later your primary residence gets a prorated exclusion.

See what you'd actually walk away with

Plug your numbers into our free home seller net proceeds calculator to get a state-specific estimate in seconds.