Selling a House: Capital Gains Exclusion and Tax Rules
Understand the Section 121 home sale exclusion ($250k single / $500k MFJ), how to calculate your gain, and strategies to minimize taxes when selling your home.
Selling your home is likely the largest financial transaction of your life — and for most homeowners, the tax bill is zero thanks to the Section 121 exclusion. But the rules have nuances that matter, especially if you have had significant appreciation, rental use, or have not lived in the home for the full period. Understanding capital gains tax rates and how capital gains differ from ordinary income is essential before listing your property.
Key Takeaways
- Exclude up to $250,000 (single) or $500,000 (MFJ) of gain from your primary residence.
- Ownership + use test: Own and live in the home for at least 2 of the last 5 years.
- Capital improvements increase your basis and reduce your taxable gain.
- Depreciation recapture applies at 25% if the home was used as a rental.
- You can use the exclusion once every 2 years.
The Section 121 Exclusion
The most powerful tax break in real estate. If you sell your primary residence, you can exclude:
- $250,000 of gain (Single, Head of Household, Married Filing Separately)
- $500,000 of gain (Married Filing Jointly — both spouses must meet the use test; only one must meet the ownership test)
Qualification Requirements
- Ownership test: You owned the home for at least 2 of the 5 years before the sale.
- Use test: You lived in the home as your primary residence for at least 2 of the 5 years before the sale. The 2 years do not need to be consecutive.
- Frequency test: You have not used the exclusion in the past 2 years.
Partial exclusion: If you do not meet the full 2-year requirement due to a job change, health condition, or unforeseen circumstances, you may qualify for a partial exclusion (prorated based on time lived there).
Calculating Your Gain
Gain = Sale Price − Selling Expenses − Adjusted Basis
Adjusted Basis
Your basis starts as the purchase price and is adjusted:
Increases to basis (reduces gain):
- Closing costs at purchase (title insurance, attorney fees, recording fees)
- Capital improvements (new roof, kitchen renovation, room addition, new HVAC)
- Special assessments for local improvements
Decreases to basis (increases gain):
- Depreciation taken if the home was used for business or rental
- Casualty loss deductions claimed
- Certain energy credits received
Not added to basis: Routine maintenance, repairs, and insurance costs.
Example
| Item | Amount |
|---|---|
| Sale price | $800,000 |
| Selling expenses (agent, closing) | −$48,000 |
| Net sale price | $752,000 |
| Original purchase price | $350,000 |
| Closing costs at purchase | +$8,000 |
| Capital improvements (kitchen, roof) | +$45,000 |
| Adjusted basis | $403,000 |
| Gain | $349,000 |
| Section 121 exclusion (MFJ) | −$349,000 |
| Taxable gain | $0 |
When the Exclusion Is Not Enough
If your gain exceeds the exclusion amount, the excess is taxed as a capital gain:
- Long-term capital gains rate (0%, 15%, or 20%) if you owned the home for more than 1 year.
- Plus the 3.8% Net Investment Income Tax (NIIT) if your income exceeds $200,000 (single) / $250,000 (MFJ).
Example: A single filer sells for a $400,000 gain. The $250,000 exclusion covers most of it. The remaining $150,000 is taxed at 15% ($22,500) plus potentially 3.8% NIIT ($5,700) for a high earner. To understand how this fits into your overall tax bracket, see our bracket guide.
Special Situations
Home Used as Rental or Business
If you converted your primary residence to a rental property and later sold it:
- Depreciation recapture: Any depreciation you claimed (or were allowed to claim) is taxed at a flat 25% rate, even if you qualify for the Section 121 exclusion on the rest. If you claimed depreciation for a home office or rental portion (for example, using MACRS depreciation), all of that depreciation is recaptured at sale.
- Nonqualified use rule: Gain allocated to periods of non-primary-residence use after 2008 may not be excludable. The IRS uses a formula: (nonqualified use days / total ownership days) × gain = non-excludable gain. For more on rental property taxation, see our rental property tax guide.
Divorce and Home Sales
For a full overview of how divorce affects filing status, property transfers, and alimony, see our divorce and taxes guide.
- If one spouse keeps the home and later sells, they can still use their individual $250,000 exclusion.
- If the home is transferred as part of the divorce settlement, the receiving spouse inherits the transferring spouse’s basis and holding period.
- Joint filers during the year of sale can use the $500,000 exclusion.
Inherited Homes
Inherited property receives a stepped-up basis to the fair market value at the date of death. If you inherit a home worth $500,000, your basis is $500,000 — even if the decedent paid $100,000 decades ago. This eliminates gain on the pre-inheritance appreciation. For a broader look at inheritance rules, see our inheritance tax vs. estate tax guide. However, the Section 121 exclusion only applies if you live in the home as your primary residence for at least 2 of 5 years before selling. For the complete rules on ownership tests, partial exclusions, and related strategies, see our home sale capital gains exclusion guide.
Strategies to Minimize Home Sale Taxes
- Track every capital improvement. Keep receipts for renovations, additions, landscaping, and system replacements. Every dollar of improvement increases your basis.
- Time the sale. Ensure you meet the 2-year ownership and use test before selling.
- Consider a 1031 exchange if the property is an investment (not primary residence). This defers gain into a replacement property.
- Installment sale. Spread gain over multiple years to manage bracket impact.
- Harvest losses. Offset any taxable home sale gain with tax loss harvesting from your investment portfolio.
- Invest in a Qualified Opportunity Zone. If you have taxable gain, reinvesting in a Qualified Opportunity Zone fund can defer and potentially reduce the gain.
- Coordinate with your overall tax plan. Use the home sale year to evaluate Roth conversions, charitable bunching, and other strategies that interact with your capital gains. A year-end tax checklist can help you time the sale for maximum benefit.
How sharper.tax Helps
sharper.tax analyzes your tax return to identify real estate gains, evaluate your eligibility for the Section 121 exclusion, and calculate the tax impact of a home sale. We factor in depreciation recapture, NIIT exposure, and strategies to offset any taxable gain. Sophisticated tax planning used to require a high-end CPA — we make it available for free.
Sources
- IRS Topic 701: Sale of Your Home
- IRS Publication 523: Selling Your Home
- IRS Section 121: Exclusion of Gain from Sale of Principal Residence
The information above is educational and not tax advice.