How Is Capital Gains on a House Sale Calculated?
Use this premium calculator to estimate gain, home-sale exclusion, depreciation recapture, and potential federal and state tax impact.
Expert Guide: How Capital Gains on a House Sale Are Calculated
When homeowners ask, “How is capital gains on a house sale calculated?”, they are usually trying to answer a practical question: how much tax, if any, will I owe when I sell? The answer depends on your gain, your adjusted cost basis, your filing status, and whether you qualify for the home-sale exclusion under U.S. tax law. In many cases, people owe no federal capital gains tax on a primary residence sale, but not always. Understanding the math before you list your property can help you set a realistic net proceeds target, make better timing decisions, and avoid tax surprises.
The basic formula starts with your amount realized from the sale and your adjusted basis. Your amount realized is generally the contract sale price minus selling expenses. Your adjusted basis is usually what you paid for the home, plus qualified capital improvements, minus any depreciation deductions taken for business or rental use. Subtract adjusted basis from amount realized and you get your gain. From there, the IRS home-sale exclusion may reduce or eliminate taxable gain if you meet ownership and use tests.
Step 1: Calculate Amount Realized
Most people begin with sale price, but that is not the whole picture. For tax purposes, the amount realized is:
- Gross sale price
- Minus selling costs such as real estate commissions, legal fees, title fees, transfer taxes, and certain closing costs tied directly to the sale
If you sold for $750,000 and paid $45,000 in selling costs, your amount realized is $705,000. This is the number compared to your basis. A common error is forgetting that commissions and selling costs reduce gain.
Step 2: Determine Adjusted Basis
Your adjusted basis starts with the original purchase price and then changes over time. In simplified terms:
- Start with original purchase price
- Add acquisition costs that increase basis
- Add capital improvements (new roof, additions, major remodels, HVAC replacement, etc.)
- Subtract depreciation claimed if part of the property was rented or used for business
Suppose you bought for $350,000, added $70,000 in eligible improvements, and claimed $0 depreciation. Your adjusted basis would be $420,000. If depreciation had been $20,000, adjusted basis would be $400,000.
Step 3: Compute Raw Capital Gain
The raw gain is:
Raw Gain = Amount Realized – Adjusted Basis
Using the sample above:
- Amount realized: $705,000
- Adjusted basis: $420,000
- Raw gain: $285,000
At this stage, many homeowners panic and assume all gain is taxable. For a primary residence, that is often not true because of the Section 121 exclusion.
Step 4: Apply the Home Sale Exclusion (Section 121)
The IRS generally allows homeowners to exclude up to:
- $250,000 of gain for single filers
- $500,000 of gain for married filing jointly
To qualify for the full exclusion, you typically must have:
- Owned the home for at least 2 years during the 5-year period ending on the sale date, and
- Used it as your main home for at least 2 years during that same 5-year period
You also generally cannot have claimed the exclusion on another home sale within the prior 2 years. Partial exclusions may be available in specific cases, such as work relocation, health reasons, or certain unforeseen circumstances.
Step 5: Account for Depreciation Recapture
If you used a portion of the home for rental or business and claimed depreciation deductions, that amount can be taxed separately, often at a maximum federal rate of 25% under depreciation recapture rules. Importantly, gain attributable to depreciation generally is not shielded by the Section 121 exclusion. This is one of the most misunderstood parts of home sale taxation.
Example: if your total gain is $300,000 and you claimed $40,000 depreciation, that $40,000 can be taxed as recapture. The remaining gain may still be eligible for exclusion if ownership and use tests are met.
2024 Federal Long-Term Capital Gains Rate Table
After exclusion and recapture calculations, any remaining taxable long-term gain is taxed at 0%, 15%, or 20% federally depending on taxable income and filing status. The table below summarizes commonly referenced 2024 thresholds for long-term capital gains rates.
| Filing Status | 0% Rate Up To | 15% Rate Range | 20% Rate Starts Above |
|---|---|---|---|
| Single | $47,025 | $47,026 to $518,900 | $518,900 |
| Married Filing Jointly | $94,050 | $94,051 to $583,750 | $583,750 |
| Head of Household | $63,000 | $63,001 to $551,350 | $551,350 |
| Married Filing Separately | $47,025 | $47,026 to $291,850 | $291,850 |
Additional Tax Layer: Net Investment Income Tax
Some sellers also owe the 3.8% Net Investment Income Tax (NIIT), depending on modified adjusted gross income. This can apply after exclusion if enough taxable gain remains. Thresholds are not indexed in the same way as ordinary brackets, so higher-income taxpayers need to plan carefully.
| Filing Status | NIIT MAGI Threshold | Potential NIIT Rate | Planning Impact |
|---|---|---|---|
| Single | $200,000 | 3.8% | Large taxable gains can trigger NIIT quickly |
| Married Filing Jointly | $250,000 | 3.8% | Joint filers with high wages and gain may owe NIIT |
| Married Filing Separately | $125,000 | 3.8% | Threshold is comparatively low |
| Head of Household | $200,000 | 3.8% | Applies similarly to single threshold |
Common Scenarios and How the Calculation Changes
Scenario A: Primary Residence, Long Ownership, Moderate Gain
A single filer buys at $300,000, spends $40,000 on major improvements, sells at $620,000, and pays $37,000 in selling costs. Raw gain is often significantly reduced by basis adjustments and then largely eliminated by the $250,000 exclusion. In this type of case, federal capital gains tax may be low or zero.
Scenario B: Married Couple With Large Appreciation
A married couple filing jointly bought many years ago in a fast-growth market. Even with a $500,000 exclusion, they still have a large taxable remainder. Their final tax outcome depends on total taxable income, applicable long-term gains rate, possible NIIT, and state taxes. Timing the sale across tax years can sometimes reduce bracket pressure.
Scenario C: Partial Rental Use
A homeowner lived in the property but rented a basement apartment and claimed depreciation. Even if the main gain is excludable, the depreciation portion may face recapture tax. Good recordkeeping is essential, because missing depreciation records can cause overpayment or IRS challenges.
What Counts as a Capital Improvement?
Not every expense increases basis. Repairs that simply maintain the home typically do not. Improvements that add value, extend useful life, or adapt the home to new uses generally can count. Examples that often qualify include room additions, new plumbing systems, structural upgrades, and whole-home energy upgrades. Examples that often do not increase basis include painting, fixing leaks, and small routine maintenance jobs.
Because distinction between repair and improvement can be technical, keep invoices, permits, contracts, and payment records. A well-documented basis can lower taxable gain significantly, especially if you purchased years ago and completed multiple major projects.
Records You Should Keep Before and After the Sale
- Closing disclosure from original purchase
- All receipts and contracts for capital improvements
- Depreciation schedules if rental or home office deductions were claimed
- Final settlement statement from sale showing commissions and closing fees
- Evidence of occupancy dates to support the 2-out-of-5 use test
Good files do more than support a return. They also make tax planning possible before listing, when you still have options.
Strategic Planning Tips to Reduce Tax Exposure
- Confirm exclusion eligibility early: If you are near the 2-year ownership or use mark, waiting may save substantial tax.
- Document improvement history: Reconstruct missing records where possible through permits, contractor statements, and bank data.
- Estimate gain before pricing: A projected tax bill can influence listing strategy and net target.
- Coordinate with overall income: Bonuses, stock sales, and business income in the same year can push you into higher capital gains rates or NIIT exposure.
- Review state rules: Some states tax capital gains as ordinary income, while others have no state income tax.
Authoritative Sources for Verification
For official rules and updates, review government resources directly:
- IRS Publication 523: Selling Your Home
- IRS Topic No. 409: Capital Gains and Losses
- Federal Housing Finance Agency House Price Index Data
Final Takeaway
So, how is capital gains on a house sale calculated? Start with sale proceeds net of selling costs, subtract your adjusted basis, then apply exclusion rules and depreciation recapture treatment. The remaining taxable amount is subject to federal long-term capital gains rates, potentially NIIT, and applicable state taxes. If you qualify for full exclusion, tax can be minimal even with substantial appreciation. If not, your liability can be meaningful and worth planning around months before closing.
The calculator above gives you a structured estimate you can use for planning conversations with a CPA or enrolled agent. For final filing positions, always reconcile your numbers with official IRS guidance and your state tax rules.