Most people who sell their home pay no federal capital gains tax on the primary residence at all. A longstanding rule under Section 121 of the Internal Revenue Code lets a single filer exclude up to $250,000 of profit from the sale, and a married couple filing jointly can exclude up to $500,000, provided you owned and lived in the home for at least two of the five years before the sale.1Office of the Law Revision Counsel. 26 U.S.C. 121 – Exclusion of Gain From Sale of Principal Residence Anything above the exclusion, or gain on a home that doesn’t meet the residency rules, is taxed at long-term capital gains rates topping out at 20%, and a 3.8% surtax can apply for higher earners.
Figuring Out Your Gain
The taxable event is your gain, not your sale price. Gain is what you received for the home minus your adjusted basis in it.
The amount you received is the sale price reduced by direct selling costs: agent commissions, seller-paid title insurance, and legal fees connected to the sale. Anything the buyer paid does not reduce it.
Your adjusted basis begins with what you paid to buy the home, including non-deductible closing costs like title fees, recording fees, and transfer taxes. Then you add capital improvements made during ownership. A capital improvement adds value, extends the home’s useful life, or adapts it to a new purpose — think a new roof, an added bathroom, a full kitchen renovation. Routine maintenance like repainting or patching drywall does not qualify.
If you claimed federal residential energy tax credits for something like solar panels or added insulation, reduce the basis by the credit amount. Spend $10,000 on panels and take a $3,000 credit, and only $7,000 gets added to basis.2Internal Revenue Service. Instructions for Form 5695 Keep receipts and contractor invoices. A higher basis means a smaller taxable gain.
If you inherited the home, your basis is not what the previous owner paid. It’s the fair market value on the date of that person’s death.3Office of the Law Revision Counsel. 26 U.S. Code 1014 – Basis of Property Acquired From a Decedent That stepped-up basis often erases most of the built-in gain before Section 121 ever comes into play.
Who Qualifies for the Full Exclusion
Two tests decide whether you get the full $250,000 or $500,000 exclusion, and both look at the five-year window ending on the sale date.
- The ownership test: you owned the home for at least 24 months during the five years before the sale.
- The use test: you lived in it as your main home for at least 24 months during that same five-year window.
The 24 months don’t have to be consecutive, and the ownership months and use months don’t have to overlap.4Internal Revenue Service. Topic No. 701, Sale of Your Home You also cannot have claimed a Section 121 exclusion on a different home sale in the two years before this one.1Office of the Law Revision Counsel. 26 U.S.C. 121 – Exclusion of Gain From Sale of Principal Residence
For a joint return with the full $500,000 exclusion, only one spouse needs to pass the ownership test, but both must pass the use test, and neither can have used the exclusion in the prior two years. If only one spouse meets the use test, the couple is capped at that spouse’s $250,000.1Office of the Law Revision Counsel. 26 U.S.C. 121 – Exclusion of Gain From Sale of Principal Residence
Selling Before Two Years
Selling early doesn’t automatically kill the exclusion. If the sale was driven by a qualifying reason, you can claim a prorated exclusion. The IRS recognizes three broad categories — a change in place of employment, a health-related reason, or unforeseen circumstances — and lists specific safe harbors within them.5eCFR. 26 CFR 1.121-3 – Reduced Maximum Exclusion for Taxpayers Failing to Meet Certain Requirements These automatic qualifiers include:
- A new workplace at least 50 miles farther from the home than the old one.
- A physician’s recommendation to change residences for health reasons.
- Death of a qualifying individual during the ownership period.
- Job loss making a qualifying individual eligible for unemployment compensation.
- A change in employment leaving you unable to cover housing and basic living expenses.
- Divorce or legal separation.
- Multiple births from the same pregnancy.
- Damage from natural disaster, act of war, or terrorism.
- Condemnation or destruction of the home.
The reduced exclusion is the full $250,000 or $500,000 multiplied by a fraction. The numerator is the shorter of the time you owned the home, the time you used it as your main home, or the time since your last Section 121 exclusion. The denominator is two years (24 months).6Office of the Law Revision Counsel. 26 U.S. Code 121 – Exclusion of Gain From Sale of Principal Residence A single filer who lived in the home for 15 months before a qualifying job move would get $250,000 × (15/24), or $156,250.
Gain the Exclusion Won’t Cover
Even when Section 121 applies, two situations carve out gain that stays taxable.
Depreciation Recapture
If you took depreciation deductions on the home — most commonly for a home office or for renting part of it — gain equal to the depreciation you claimed after May 6, 1997 is not eligible for the exclusion.7Office of the Law Revision Counsel. 26 U.S.C. 121 – Exclusion of Gain From Sale of Principal Residence That amount is taxed as unrecaptured Section 1250 gain at a maximum rate of 25%.8Internal Revenue Service. Topic No. 409, Capital Gains and Losses Claimed $15,000 in home-office depreciation over the years? That $15,000 is taxable at up to 25% no matter how much of the rest of your gain the exclusion covers.
A home office inside the living area doesn’t require you to split the sale into two transactions, but a separate business structure or rental unit does. The business portion gets reported on Form 4797 rather than through the regular home sale exclusion.9Internal Revenue Service. Publication 523 (2025), Selling Your Home
Non-Qualified Use
If you used the home as something other than a primary residence during part of your ownership — for example, you bought it as a rental and later moved in — the gain tied to that non-residential period cannot be excluded. The IRS prorates based on the ratio of non-qualified use time to total ownership time.7Office of the Law Revision Counsel. 26 U.S.C. 121 – Exclusion of Gain From Sale of Principal Residence
Only non-qualified use after December 31, 2008 counts. And any period after you stop using the home as your primary residence — moving out and renting it during the last year, for instance — does not count against you. The rule targets non-residential use before you moved in, not after you moved out.
Special Situations
Divorce
If a divorce or separation agreement grants one former spouse the right to live in the home, the other former spouse still gets credit for that continued use, and the home is treated as their principal residence for as long as the ex-spouse lives there under the agreement.6Office of the Law Revision Counsel. 26 U.S. Code 121 – Exclusion of Gain From Sale of Principal Residence Without that explicit language in the agreement, a spouse who moved out more than three years before the sale would fail the use test on their share of the gain. If the home was transferred between spouses as part of the divorce, the receiving spouse’s ownership period includes the time the transferring spouse owned it.
Surviving Spouses
You can still claim the $500,000 exclusion after your spouse’s death if you sell within two years of the death, haven’t remarried, neither of you used the exclusion in the two years before the sale, and you meet the ownership and use requirements counting your late spouse’s time.9Internal Revenue Service. Publication 523 (2025), Selling Your Home Miss the two-year window or remarry first, and you’re limited to $250,000.
Military and Similar Service
Members of the uniformed services, the Foreign Service, and the intelligence community can elect to suspend the five-year testing period during qualified official extended duty. Qualified duty means active duty of more than 90 days or an indefinite period at a station at least 50 miles from the home.1Office of the Law Revision Counsel. 26 U.S.C. 121 – Exclusion of Gain From Sale of Principal Residence The suspension can stretch the five-year window to as much as 15 years. A service member who lived in a home for two years, deployed for eight, and then returned and sold it could still pass the use test.
What You’ll Pay on the Taxable Portion
Any gain above the exclusion, and any gain from non-qualified use, is taxed at long-term capital gains rates because virtually every home sale exceeds the one-year holding period. The brackets run 0%, 15%, and 20%. Most homeowners with taxable gain fall into the 15% bracket. The 20% rate applies to higher-income filers.8Internal Revenue Service. Topic No. 409, Capital Gains and Losses
On top of that, a 3.8% Net Investment Income Tax can apply if your modified adjusted gross income exceeds certain thresholds: $250,000 for joint filers and surviving spouses, $200,000 for single filers and heads of household, and $125,000 for married filing separately.10Internal Revenue Service. Questions and Answers on the Net Investment Income Tax Gain covered by the Section 121 exclusion is not subject to NIIT; only recognized gain above the exclusion counts. The tax is 3.8% of the lesser of your net investment income or the amount by which MAGI exceeds the threshold.11Internal Revenue Service. Topic No. 559, Net Investment Income Tax
A married couple with a $600,000 gain excludes $500,000 and recognizes $100,000. If their MAGI exceeds $250,000 by $50,000, the NIIT hits $50,000 (the smaller of the two figures) for a $1,900 surtax on top of the regular capital gains tax.10Internal Revenue Service. Questions and Answers on the Net Investment Income Tax Stacked with the 20% long-term rate, the effective rate on that layer of gain can reach 23.8%.
Reporting the Sale
You don’t always have to put the sale on your return. If the exclusion covers your entire gain and you did not receive a Form 1099-S from the settlement agent, no reporting is required.12Internal Revenue Service. Tax Considerations When Selling a Home If you did receive a 1099-S, you must report the sale even if none of the gain is taxable, because the IRS already has a record of the gross proceeds.13Internal Revenue Service. Instructions for Form 1099-S (04/2025)
When reporting, the sale goes on Form 8949 — sale price, adjusted basis, and the excluded amount entered as a negative adjustment. Totals from Form 8949 flow to Schedule D of Form 1040.14Internal Revenue Service. About Form 8949, Sales and Other Dispositions of Capital Assets Depreciation recapture on a separately identifiable business portion of the property goes on Form 4797.9Internal Revenue Service. Publication 523 (2025), Selling Your Home
A Note on State Taxes
Section 121 is a federal rule. Most states with an income tax follow the federal exclusion, but not all conform completely, and some impose transfer taxes on top. Check your state’s treatment before assuming the federal exclusion clears you entirely.