You can usually avoid federal capital gains tax on a home sale by claiming the Section 121 primary residence exclusion, which shelters up to $250,000 of profit for single filers and $500,000 for married couples filing jointly.1Internal Revenue Service. Publication 523, Selling Your Home For most homeowners, that exclusion wipes out the entire taxable gain. If your profit runs higher, or you don’t qualify for the full exclusion, several other tools can shrink or defer what’s left: adding qualifying improvements to your cost basis, deducting selling expenses, offsetting the gain with investment losses, spreading the sale across years, or (for rental property only) rolling proceeds into a like-kind exchange.
The Section 121 Primary Residence Exclusion
Section 121 is the main event. To qualify, you have to pass two tests during the five-year period ending on the sale date:2Office of the Law Revision Counsel. 26 USC 121 Exclusion of Gain From Sale of Principal Residence
- Ownership: you owned the home for at least 24 months.
- Use: you lived in it as your primary residence for at least 24 months.
The months don’t have to be consecutive. A year in the home, a year away, then another year back can add up to a qualifying stretch. Married couples filing jointly get the full $500,000 exclusion when both spouses meet the use test and at least one meets the ownership test. You can only claim the exclusion once every two years.1Internal Revenue Service. Publication 523, Selling Your Home
If your gain fits inside these limits and you pass both tests, you owe zero federal capital gains tax.
Partial Exclusion If You Sell Before Two Years
Selling early doesn’t automatically kill the exclusion. If the reason you’re moving is a work change, a health issue, or a qualifying unforeseen event, the IRS lets you claim a prorated share.1Internal Revenue Service. Publication 523, Selling Your Home
Work Moves
You qualify if you take or are transferred to a new job located at least 50 miles farther from the home than your previous workplace. If you had no previous workplace, the new job just has to be at least 50 miles from the home. A spouse’s or co-owner’s job change counts too.
Health Moves
You qualify if you moved to get treatment for a disease or injury, to care for a sick family member, or because a doctor recommended the move. The IRS reads “family member” broadly, covering parents, children, siblings, grandparents, grandchildren, and various in-laws.
Unforeseen Circumstances
Life events that count include:
- Death of a spouse or co-owner
- Divorce or legal separation
- Destruction or condemnation of the home
- Becoming eligible for unemployment compensation
- Birth of twins or more from a single pregnancy
- Losing the ability to pay basic household expenses because of an employment change
The prorated cap is based on how much of the 24 months you completed before the qualifying event. A single filer who lived in the home for 12 of the 24 months can exclude up to $125,000; a married couple in the same spot can exclude up to $250,000.
Divorce, Separation, and Military Service
If a spouse or former spouse transferred the home to you, you can count their period of ownership toward your two-year ownership test. You still have to meet the residency requirement yourself. If a divorce or separation agreement gives your former spouse the right to keep living in the home, you can treat their time there as your own use of the property, so moving out during a settlement doesn’t cost you the exclusion.1Internal Revenue Service. Publication 523, Selling Your Home
Members of the uniformed services, Foreign Service, or intelligence community on qualified extended duty can elect to suspend the five-year test period for up to 10 years, stretching the lookback window to as long as 15 years.2Office of the Law Revision Counsel. 26 USC 121 Exclusion of Gain From Sale of Principal Residence Own and live in the home for two years, deploy for a decade, and the full exclusion is still on the table when you sell.3eCFR. 26 CFR 1.121-5 Suspension of 5-Year Period for Certain Members of the Uniformed Services and Foreign Service You make the election by filing a return for the sale year that excludes the gain; no separate form or advance approval is needed.
Shrinking the Gain Above the Exclusion
If your profit exceeds $250,000 or $500,000, two adjustments narrow what’s taxable: raising your cost basis and subtracting selling expenses.
Raise Your Cost Basis
Basis starts with the original purchase price plus certain settlement costs at purchase, such as title insurance premiums, legal fees, and recording fees.1Internal Revenue Service. Publication 523, Selling Your Home Capital improvements you make during ownership add to it. To qualify, an improvement has to add value, extend the home’s useful life, or adapt it to a new use. Examples:
- Adding a room, deck, or garage
- Replacing the roof or HVAC system
- New plumbing, electrical wiring, or insulation
- Remodeling a kitchen or bathroom
Routine maintenance like repainting or fixing a faucet doesn’t count. Every dollar of qualifying improvement reduces the taxable gain, which is why keeping receipts pays off years later.
Subtract Selling Expenses
Costs tied directly to the sale reduce the “amount realized” used to calculate gain. That includes real estate agent commissions, advertising, legal fees, and loan charges you paid on the buyer’s behalf.1Internal Revenue Service. Publication 523, Selling Your Home Since commissions alone often run 5–6% of the sale price, this can meaningfully cut, or erase, a taxable gain.
Stepped-Up Basis on an Inherited Home
If you inherited the home, your basis is generally its fair market value on the date the previous owner died, not what they originally paid.4Internal Revenue Service. Gifts and Inheritances A parent who paid $100,000 for a home worth $400,000 at death leaves you a $400,000 basis. Sell for $420,000 and your taxable gain is $20,000, not $320,000. If the property also becomes your primary residence and you meet the ownership and use tests, you can apply the Section 121 exclusion on top of that stepped-up basis.
Depreciation Recapture Isn’t Covered
The Section 121 exclusion has a limit worth knowing before you sell: it does not shelter the portion of your gain tied to depreciation you claimed, typically from a home office or a rented room. This “unrecaptured Section 1250 gain” is taxed at a maximum rate of 25%, regardless of your regular capital gains bracket.5Internal Revenue Service. Topic No. 409, Capital Gains and Losses If you claimed $14,000 in depreciation over the years, that $14,000 slice of gain is taxed at up to 25% even if the rest falls inside the exclusion. You report it on Form 4797, and it can’t be deferred or excluded even if you use an installment sale for the rest.
Section 1031 Exchange (Investment Property Only)
If you’re selling a rental or other investment property rather than your home, Section 1031 lets you defer capital gains tax by reinvesting the proceeds into a similar property.6Office of the Law Revision Counsel. 26 USC 1031 Exchange of Real Property Held for Productive Use or Investment It doesn’t apply to your primary residence or to a vacation home used purely for personal enjoyment.
Two deadlines control every exchange:
- You have 45 days from the sale of the original property to identify replacement properties in writing.
- You have 180 days from the original sale (or until your tax return’s due date with extensions, whichever comes first) to close on the replacement.7Internal Revenue Service. Like-Kind Exchanges Under IRC Section 1031
Sale proceeds must flow through a qualified intermediary; you can’t touch the money yourself. Miss either deadline and the whole gain becomes taxable that year.
Offsetting the Gain With Capital Losses
Losses from stocks, bonds, or other assets sold in the same year can offset a home-sale gain dollar for dollar. If total capital losses exceed total capital gains for the year, you can deduct up to $3,000 of the excess against ordinary income ($1,500 if married filing separately), and unused losses carry forward indefinitely.5Internal Revenue Service. Topic No. 409, Capital Gains and Losses8Internal Revenue Service. 2025 Instructions for Schedule D (Form 1040) If you know a large home-sale gain is coming, coordinating the sale of underperforming investments in the same tax year is a straightforward way to shrink the net.
Spreading the Gain Across Years
An installment sale lets you collect the purchase price over time and report the gain portion of each payment in the year you receive it.9Internal Revenue Service. Topic No. 705, Installment Sales This can hold you in a lower capital gains bracket each year and reduce exposure to the net investment income tax discussed below. You report installment income on Form 6252. The one carve-out: any gain attributable to depreciation recapture has to be reported in the sale year, even if you haven’t received the full payment yet.
The 3.8% Net Investment Income Tax
Gain above the Section 121 exclusion can trigger an extra 3.8% surtax, the net investment income tax. The portion sheltered by the exclusion is fully exempt; the NIIT only reaches the recognized gain above the limit.10Internal Revenue Service. Questions and Answers on the Net Investment Income Tax
The surtax applies when your modified adjusted gross income exceeds:11Internal Revenue Service. Topic No. 559, Net Investment Income Tax
- $250,000 for married couples filing jointly
- $200,000 for single filers and heads of household
- $125,000 for married filing separately
The tax is calculated on the lesser of your total net investment income or the amount by which your MAGI exceeds the threshold. These thresholds don’t adjust for inflation, so more sellers hit them each year.
How Long You Owned It Sets the Rate
Holding period drives the rate on any gain that isn’t excluded or deferred. Owned the home a year or less? The gain is short-term and taxed at your ordinary income rate. Owned it longer? It’s long-term, taxed at 0%, 15%, or 20% depending on taxable income.5Internal Revenue Service. Topic No. 409, Capital Gains and Losses Most homeowners who owe tax on a sale land in the 15% bracket. The bracket thresholds adjust annually for inflation, so verify the current year’s figures before planning.
When You Have to Report the Sale
Not every home sale creates paperwork. If the full Section 121 exclusion covers your gain and you didn’t receive a Form 1099-S from the closing agent, you generally don’t need to report the sale at all.12Internal Revenue Service. Important Tax Reminders for People Selling a Home
Report the sale if any of these apply:
- You received a Form 1099-S
- Your gain exceeds the exclusion
- You’re claiming a partial exclusion
- You can exclude some, but not all, of the gain
Reporting is done on Form 8949, with the result flowing to Schedule D of your Form 1040.13Internal Revenue Service. Instructions for Form 8949 Even when the exclusion swallows your entire gain, a 1099-S in your records means you need to file the paperwork to show the IRS how it netted out.