How to Calculate Capital Gains Tax on a Home Sale
Selling your home is one of the biggest financial transactions of your life — and one of the most common questions sellers ask is: how do I calculate capital gains tax on a home sale? The good news is that most homeowners owe little to nothing, thanks to a generous federal exclusion. But knowing the math matters, because the rules have exceptions, and the tax bill on a gain above the exclusion can be significant. This guide walks through exactly how to calculate your gain, apply the exclusion, and estimate what you owe.
What is capital gains tax on a home sale?
When you sell a home for more than you paid for it, the profit is called a capital gain. The IRS taxes that gain — but with a major exception for primary residences known as the Section 121 exclusion. If you qualify, you can exclude a large portion of your profit from federal income tax entirely. Understanding whether and how much you qualify for is step one before you calculate anything.
Step 1: Calculate your capital gain
Your capital gain is simply your sale price minus your adjusted cost basis.
Capital Gain = Sale Price − Selling Costs − Adjusted Cost Basis
Each piece of that formula needs careful calculation:
Sale price and selling costs
Start with the actual sale price your buyer paid. Then subtract your selling costs — these reduce the taxable gain and include:
- Real estate agent commissions (typically 5–6% of sale price)
- Closing costs paid by the seller (title fees, transfer taxes, attorney fees)
- Staging costs and pre-sale repairs required by the buyer
On a $650,000 home sale with 5.5% commission ($35,750) and $8,000 in other closing costs, your net proceeds are $606,250.
Adjusted cost basis
Your cost basis starts with what you paid for the home, then adjusts upward for:
- Purchase price — the price you actually paid
- Eligible closing costs at purchase — owner’s title insurance, recording fees, and transfer taxes (not loan origination fees, prepaid interest, or property taxes)
- Capital improvements — additions, renovations, or upgrades that add value or extend useful life (a new roof, a kitchen remodel, an addition, a new HVAC system)
Routine repairs and maintenance — painting, fixing a leaky faucet, replacing a broken appliance — do not increase your basis. Only improvements that materially add value count.
Example: You bought a home for $350,000 in 2018, paid $8,000 in purchase closing costs, and spent $42,000 on a kitchen remodel and roof replacement over the years. Your adjusted cost basis is $350,000 + $8,000 + $42,000 = $400,000.
Step 2: Apply the primary residence exclusion
Under IRS Section 121, if you owned and used the home as your primary residence for at least 2 of the last 5 years before the sale, you can exclude:
- Up to $250,000 of capital gain — single filers
- Up to $500,000 of capital gain — married filing jointly (both spouses must meet the use test; only one needs to meet the ownership test)
This exclusion can be used once every two years. You don’t have to buy a replacement home to claim it.
Full example: qualifying for the exclusion
Using the numbers above:
- Net sale proceeds: $606,250
- Adjusted cost basis: $400,000
- Capital gain: $606,250 − $400,000 = $206,250
- Exclusion (single filer): $250,000
- Taxable gain: $206,250 − $250,000 = $0 (fully excluded)
In this case, you owe no federal capital gains tax on the sale. A married couple with the same numbers would have $500,000 of exclusion available — more than enough.
Step 3: Calculate tax on gains above the exclusion
If your gain exceeds the exclusion amount, only the portion above the limit is taxed. The rate depends on how long you owned the home and your income:
Long-term capital gains rates (home owned more than 1 year)
- 0% — the portion of a single filer’s 2026 taxable income up to $49,450
- 15% — the portion above $49,450 through $545,500
- 20% — the portion above $545,500
- For married filing jointly, the 2026 boundaries are $98,900 and $613,700
These bands apply to taxable income including the gain, not the home’s sale price. Other taxable income fills the lower bands first. See the IRS 2026 thresholds.
Additionally, if modified adjusted gross income exceeds $200,000 (single) or $250,000 (married filing jointly), the 3.8% Net Investment Income Tax (NIIT) may apply to taxable investment income, including some home-sale gain. The excluded portion is not subject to NIIT.
Example: gain above the exclusion
Suppose you’re a single filer who bought a home for $300,000 (with $10,000 in eligible closing costs and $20,000 in improvements — adjusted basis $330,000) and sold it for $750,000, paying $45,000 in commissions and fees. Assume you qualify for the full exclusion and have $75,000 of other taxable income.
- Net proceeds: $750,000 − $45,000 = $705,000
- Adjusted basis: $330,000
- Total gain: $705,000 − $330,000 = $375,000
- Exclusion (single): − $250,000
- Taxable gain: $125,000
- Other taxable income plus gain: $75,000 + $125,000 = $200,000, entirely within the 15% capital-gain band
- Estimated federal capital-gain tax: $125,000 × 0.15 = $18,750, before any NIIT or state tax
The capital gains tax calculator can estimate federal tax on the remaining taxable gain after you calculate your home-sale exclusion separately. It supports holding period and filing status, but does not calculate Section 121 eligibility, NIIT, depreciation recapture, or state tax.
What counts as a capital improvement vs a repair?
Getting this distinction right can meaningfully reduce your taxable gain. The IRS distinguishes improvements (which increase your basis) from repairs (which don’t).
Capital improvements that increase your basis:
- Room additions, new garages, or finished basements
- New roof, windows, or siding
- New HVAC system, water heater, or electrical panel
- Kitchen or bathroom remodels that add lasting value
- Landscaping or a new driveway
Repairs that do not increase your basis:
- Interior and exterior painting
- Fixing a broken window, leaky pipe, or damaged floor
- Replacing individual appliances (unless part of a larger remodel)
- Pest control or standard maintenance
Keep receipts for every capital improvement you make — they’re your proof of an increased basis if the IRS ever questions your gain calculation.
The 2-of-5-year rule and partial exclusions
The ownership and use tests are separate, and there’s flexibility:
- The 2 years of ownership and 2 years of use do not need to be continuous or the same 2 years
- Rental use can change the calculation. Renting after your last period of residence is treated differently from renting before you lived there; earlier nonqualified use may make part of the gain ineligible for exclusion.
- If you don’t meet the full 2-year requirement due to a job change, health reasons, or unforeseen circumstances, you may qualify for a partial exclusion — prorated based on how long you actually lived there
Partial exclusion example
You owned and lived in your home for 18 months before a qualifying job relocation required you to sell. If you meet the IRS reduced-exclusion rules, 18/24 = 75% of the full period. As a single filer, your maximum exclusion could be 75% × $250,000 = $187,500 rather than $250,000.
Depreciation recapture if you rented the property
If you ever rented your home and claimed depreciation deductions, there’s an additional complication: the IRS recaptures that depreciation at a rate of up to 25% — even if you would otherwise qualify for the Section 121 exclusion on the rest of the gain. The exclusion does not protect you from depreciation recapture.
For example, if you converted your home to a rental for 3 years, claimed $30,000 in depreciation, and later sold it, that $30,000 is taxed as “unrecaptured Section 1250 gain” at your ordinary tax rate up to 25% — separate from the capital gain calculation. This is a scenario where consulting a tax professional pays for itself.
State capital gains taxes
Federal rules are only part of the picture. State treatment varies, and this guide does not calculate state tax. Check the rules where you file before assuming the federal result is your total tax.
For complex situations, especially rental use, depreciation, or possible NIIT, use the IRS home-sale worksheet and seek qualified tax advice. The DigiCalc income tax estimator does not model NIIT or home-sale exclusions.
Putting it all together
Calculating capital gains tax on a home sale follows a four-step process:
- Calculate your adjusted cost basis — purchase price + eligible closing costs + capital improvements
- Calculate your gain — net sale proceeds minus adjusted cost basis
- Apply the Section 121 exclusion — up to $250,000 (single) or $500,000 (married) if you meet the 2-of-5-year ownership and use tests
- Tax any remaining gain at long-term capital gains rates (0%, 15%, or 20% depending on income)
Many primary residence sellers owe no federal tax on the gain because it falls within the exclusion. A larger gain or rental history can change that result. Keep records of eligible costs and improvements, and work through the IRS worksheet before relying on a simple estimate.
For more on how capital gains rates work across different asset types, see the guide to how capital gains tax is calculated on stocks and investments.
Estimate federal tax on the gain remaining after the home-sale exclusion
Try the Capital Gains Tax Calculator →