Primary Residence Capital Gains Calculator
Estimate adjusted basis, gain, Section 121 exclusion, taxable gain, and an estimated federal tax impact when selling your main home.
How to Calculate Capital Gains on Sale of Primary Residence: Expert Guide
When you sell your primary residence, the tax result can range from zero federal capital gains tax to a meaningful tax bill, depending on your gain, filing status, and whether you meet the Section 121 home sale exclusion rules. The good news is that the process is predictable when you break it into steps. This guide walks you through exactly how to calculate your gain and estimate taxable amounts with practical examples.
The short version is this: you start with your sale price, subtract selling costs, subtract your adjusted basis, and that gives your total gain. Then you apply the home sale exclusion if you qualify. For many homeowners, up to $250,000 of gain is excludable if filing single, or up to $500,000 if married filing jointly. However, depreciation claimed after May 6, 1997 is not excludable and is typically taxed as unrecaptured Section 1250 gain (up to 25%).
Step 1: Calculate Your Adjusted Basis
Your adjusted basis is generally what you have invested in the home for tax purposes. Start with your purchase price, add certain acquisition costs and capital improvements, then subtract depreciation claimed (if applicable).
- Start with: purchase price
- Add: certain closing costs and settlement fees allowed in basis
- Add: capital improvements (new roof, major remodel, room addition, HVAC replacement, etc.)
- Subtract: depreciation you claimed for business or rental use of the home after May 6, 1997
Important distinction: repairs and maintenance (painting, fixing a leak, replacing a broken appliance) generally do not increase basis. Improvements that add value, prolong useful life, or adapt the property to new uses generally do.
Step 2: Calculate Amount Realized on Sale
Your amount realized is typically the contract sale price minus selling expenses. Selling expenses can include commissions, title charges, legal fees directly tied to the sale, recording fees, and transfer taxes paid by you as seller.
- Amount realized = Sale price – Selling expenses
This step matters because sellers often overestimate taxable gain by forgetting substantial transaction costs, especially broker commissions.
Step 3: Compute Total Gain
Once you have adjusted basis and amount realized, use this formula:
Total gain = Amount realized – Adjusted basis
If the result is negative, that is a loss. For personal-use primary residences, losses are generally not deductible on your federal return.
Step 4: Determine Section 121 Exclusion Eligibility
To use the home sale exclusion under Internal Revenue Code Section 121, you generally must meet:
- Ownership test: You owned the home for at least 2 years during the 5-year period ending on the sale date.
- Use test: You used the home as your main home for at least 2 years during that same 5-year period.
- Lookback rule: You did not claim the exclusion for another home sale in the prior 2 years.
If eligible, you can usually exclude up to:
- $250,000 if single
- $500,000 if married filing jointly and both spouses satisfy use requirements (with additional joint return conditions)
Some taxpayers who fail full 2-year tests may qualify for a partial exclusion because of job change, health, or certain unforeseen circumstances, but partial exclusion calculations are case-specific.
Step 5: Separate Depreciation Recapture
If any part of the home was rented or used for business and you claimed depreciation, that amount after May 6, 1997 is generally not covered by Section 121 exclusion. This portion may be taxed as unrecaptured Section 1250 gain, typically at a maximum federal rate of 25%.
Practical method:
- Compute total gain first.
- Set aside gain attributable to post-1997 depreciation.
- Apply exclusion only to the remaining non-recapture gain.
Step 6: Estimate Your Capital Gains Rate and NIIT Exposure
For taxable long-term gain above exclusions, the federal long-term capital gains rate is generally 0%, 15%, or 20%, depending on taxable income and filing status. In addition, high-income taxpayers may owe the 3.8% Net Investment Income Tax (NIIT).
| 2024 Federal Rate Metric | Single | Married Filing Jointly | Notes |
|---|---|---|---|
| 0% long-term capital gains ceiling | $47,025 | $94,050 | Taxable income up to this level is generally in 0% LTCG bracket. |
| 15% long-term capital gains ceiling | $518,900 | $583,750 | Income above 0% ceiling and up to this ceiling generally taxed at 15%. |
| 20% long-term capital gains threshold | Over $518,900 | Over $583,750 | Taxable income above these levels generally taxed at 20% LTCG. |
| NIIT threshold (MAGI) | $200,000 | $250,000 | Potential additional 3.8% tax on net investment income. |
These are federal thresholds for 2024 and do not include state taxes. State-level treatment can materially change the total tax due.
Worked Example
Suppose a married couple bought their home for $300,000, paid $8,000 in basis-eligible closing costs, and spent $90,000 on major improvements over several years. They sell for $850,000 and pay $55,000 in selling expenses.
- Adjusted basis = $300,000 + $8,000 + $90,000 = $398,000
- Amount realized = $850,000 – $55,000 = $795,000
- Total gain = $795,000 – $398,000 = $397,000
If they meet all Section 121 tests and have no depreciation recapture, their exclusion limit is $500,000. Since gain ($397,000) is below $500,000, federal taxable gain may be zero. If they had $40,000 of depreciation recapture, that piece would generally remain taxable, even if the rest is excluded.
Market Context and Why More Sellers Need to Run the Math
Home values rose sharply in recent years, and many long-term owners now sit on substantial unrealized gains. That means sellers who previously assumed they would owe no tax may now have gains near or above exclusion limits, especially in high-cost markets or after decades of appreciation.
| National Existing-Home Median Price (NAR) | Statistic | Tax Planning Impact |
|---|---|---|
| 2020 | $296,500 | Many owners still below exclusion after modest holding periods. |
| 2021 | $346,900 | Rapid price expansion increased potential gains on sale. |
| 2022 | $386,300 | Two-year appreciation pushed more households toward exclusion ceilings. |
| 2023 | $389,800 | Elevated prices kept gain planning relevant despite lower transaction volume. |
Because the Section 121 exclusion amounts have remained fixed at $250,000/$500,000 since 1997, inflation and long-cycle home appreciation can increase the share of homeowners with partially taxable gains, particularly in coastal metros.
Documents You Should Gather Before Calculating
- HUD-1 or closing disclosure from your purchase
- Receipts and invoices for capital improvements
- Depreciation schedules from prior tax returns (if any rental/business use)
- Final closing statement from sale
- Records of periods you lived in and owned the property
Good records make a dramatic difference. Every legitimate basis adjustment you document can reduce taxable gain.
Frequent Mistakes Home Sellers Make
- Ignoring selling costs: this overstates gain.
- Confusing repairs with improvements: repairs usually do not add basis.
- Forgetting depreciation recapture: this can create tax even when exclusion applies.
- Missing the 2-out-of-5 test details: timing matters and can affect eligibility.
- Assuming no tax because “it is my primary home”: exclusion is powerful, but not unlimited.
State Taxes and Other Considerations
This calculator estimates federal treatment. Your state may tax gain differently, may not fully mirror federal exclusions, or may apply additional rates. If you moved recently, changed residency, or have mixed personal/rental use, professional review is often worth the cost.
Authoritative References
- IRS Publication 523 (Selling Your Home)
- IRS Tax Topic No. 409 (Capital Gains and Losses)
- Cornell Law School: 26 U.S. Code § 121
Bottom Line
To calculate capital gains on the sale of your primary residence, focus on four numbers: adjusted basis, amount realized, exclusion amount, and any depreciation recapture. The formula is straightforward, but details matter. If your gain is near exclusion limits, or if your home had rental/business use, running precise numbers before listing can help you set price expectations, reserve for taxes, and avoid filing surprises.