Gain is not profit, and basis is not price
The single most common mistake in home-sale tax planning is computing gain as sale price minus purchase price. The actual calculation has four moving parts, and two of them are usually forgotten.
Amount realized is the sale price minus your selling costs — commission, transfer or excise tax, title and escrow fees, legal fees. These reduce what you are treated as having received, which is why a seller paying 7% of the price in costs is not taxed on that 7%.
Adjusted basis starts at what you paid, adds the buying costs you capitalised at purchase, adds every capital improvement over the whole holding period, and subtracts any depreciation you claimed. A homeowner who bought at $300,000, paid $4,000 of title and legal fees, and put in a $60,000 kitchen and roof over twelve years has a basis of $364,000, not $300,000.
Gain is the difference. On a $700,000 sale with $45,000 of costs, the amount realized is $655,000 and the gain is $291,000.
The exclusion then removes up to $250,000 of that gain for a single filer or $500,000 for a married couple filing jointly, provided the ownership and use tests are met. In the example, a single filer excludes $250,000 and is taxed on $41,000; a married couple filing jointly excludes the whole $291,000 and owes nothing.
Notice how much rides on basis. Every dollar of documented capital improvement is a dollar removed from the taxable gain, worth 15 or 20 cents of federal tax plus state. Receipts kept for twenty years pay for themselves at exactly this moment.
The Section 121 tests, and what breaks them
To claim the exclusion you must satisfy two tests, both measured over the five years ending on the date of sale.
Ownership. You must have owned the home for at least two years of that five-year window. Use. You must have lived in it as your principal residence for at least two years of that window. The two-year periods need not be continuous and need not coincide, which is what lets someone who rented the property out for part of the period still qualify.
A third rule limits frequency: the full exclusion is generally available only once in a two-year period. Selling two homes in eighteen months usually means the exclusion is available on one of them.
For a married couple filing jointly to claim the full $500,000, either spouse may satisfy the ownership test but both must satisfy the use test, and neither may have excluded gain on another sale within the preceding two years. A couple where only one spouse lived in the home is limited to $250,000.
Failing the tests does not always mean zero relief. A reduced exclusion is available where the sale is caused by a change in place of employment, by health, or by another unforeseeable circumstance the regulations recognise. It is prorated by the fraction of the two-year requirement actually satisfied, so a qualifying sale after twelve months gives half the cap. This calculator does not compute the reduced exclusion — if your situation might qualify, that is a conversation for your tax adviser.
Two more restrictions catch people with mixed-use history. Gain allocable to periods of non-qualified use after 2008 — time the property was not your principal residence — is generally not excludable, and is prorated by time. And depreciation claimed since 6 May 1997 is never excludable, whatever the tests say.
Worked example: a $700,000 sale by a single filer
You bought in 2014 for $300,000, paying $4,000 in title, legal and recording costs. Over twelve years you replaced the roof, added a bathroom and rebuilt the kitchen, spending $60,000 in total on work that qualifies as capital improvement. You never rented the property and never claimed a home-office deduction, so depreciation is zero. You sell for $700,000 with $45,000 of selling costs. You file as a single taxpayer in the 15% bracket, your income is below the net investment income tax threshold, and your state taxes capital gains at 5%.
- Adjusted basis. $300,000 + $4,000 + $60,000 − $0 = $364,000.
- Amount realized. $700,000 − $45,000 = $655,000.
- Realized gain. $655,000 − $364,000 = $291,000.
- Recapture. No depreciation was claimed, so $0.
- Exclusion. Both two-year tests are met and you file single, so the cap is $250,000. The exclusion is the lesser of $250,000 and $291,000 = $250,000.
- Taxable gain. $291,000 − $0 − $250,000 = $41,000.
- Federal tax. 15% × $41,000 = $6,150.
- State tax. 5% × $41,000 = $2,050.
- Total tax. $6,150 + $2,050 = $8,200.
- Proceeds after tax. $655,000 − $8,200 = $646,800.
Two counterfactuals show what the levers are worth. Married filing jointly, the cap is $500,000, the whole $291,000 is excluded, and the tax is zero. And had you not documented the $60,000 of improvements, the basis would be $304,000, the gain $351,000, the taxable gain $101,000, and the tax 20% × $101,000 = $20,200 — $12,000 more, purely for lack of receipts.
Reading the result and what to do about it
If the tax is zero, check why. The exclusion covering your whole gain is the normal outcome for an ordinary owner-occupied sale, and it is why most home sales generate no tax at all. If your gain is close to the cap, that is a signal to look harder at basis before you file.
If there is a taxable amount, attack the basis first. Improvements are the only input you can still change through documentation rather than through a transaction. Additions, a new roof, replacement windows, HVAC systems, a finished basement, landscaping that is permanent, and assessments for local improvements all count. Repairs, repainting and routine maintenance do not — but a repair done as part of a larger remodel can be included in the improvement.
Depreciation is the trap for former landlords. If you ever rented the home or claimed a home-office deduction, the depreciation allowed or allowable since May 1997 reduces your basis — whether or not you actually claimed it. It is then taxed as unrecaptured Section 1250 gain at up to 25%, and no amount of Section 121 exclusion shelters it. In the third test vector, a couple with a $250,000 gain and $80,000 of depreciation excludes $170,000 and still writes a $20,000 cheque.
The 3.8% net investment income tax applies to the taxable portion of the gain when your modified adjusted gross income exceeds the statutory threshold for your filing status. Excluded gain is not net investment income, so the exclusion protects you from NIIT as well — one more reason the exclusion is worth so much more than its face rate suggests.
State treatment varies enormously. Several states levy no income tax at all; several tax capital gains at ordinary income rates; and states differ in whether they conform to the federal exclusion. Check your own state rather than assuming conformity.
Tax at different sale prices for the worked example
| Sale price | Realized gain | Exclusion applied | Taxable gain | Tax at 20% combined |
|---|---|---|---|---|
| $600,000 | $191,000 | $191,000 | $0 | $0 |
| $659,000 | $250,000 | $250,000 | $0 | $0 |
| $700,000 | $291,000 | $250,000 | $41,000 | $8,200 |
| $800,000 | $391,000 | $250,000 | $141,000 | $28,200 |
| $900,000 | $491,000 | $250,000 | $241,000 | $48,200 |
Below $659,000 the exclusion covers the entire gain and the tax is zero. Above it, every extra dollar of price is taxed at the full combined rate — 20 cents on the dollar here — because the exclusion is already exhausted.
This is an estimate, not a tax return
The calculator applies the structure of the residence-sale rules with the rates you supply. It does not model your full return: capital gains brackets depend on your total taxable income, so a large gain can push part of itself into a higher bracket; the net investment income tax depends on modified adjusted gross income against thresholds that are not indexed; the reduced exclusion for a qualifying early sale is not computed; and non-qualified-use allocation for property that was not always your main home is not applied.
Nor does it handle inherited property, which generally receives a stepped-up basis at date of death; property received in divorce; a like-kind exchange under Section 1031; or the interaction between an installment sale and the exclusion. Read IRS Publication 523 and take professional advice on any gain large enough to matter.
What counts, and what does not
- Adds to basis: additions and structural work, a new roof, replacement windows, HVAC and water heater replacement, a finished basement, permanent landscaping, new plumbing or wiring, and special assessments for streets or sewers.
- Does not add to basis: repainting, repairs, routine maintenance, appliances that stay personal property, and any improvement you later removed or replaced.
- Reduces the amount realized: brokerage commission, transfer or excise tax, owner's title policy, escrow and legal fees, and advertising you paid to sell.
- Reduces basis: depreciation allowed or allowable, casualty loss deductions taken, and insurance reimbursements for damage you did not repair.
- Never in the calculation: your mortgage balance and payoff. How much you borrowed against the house has no effect on gain — only on how much cash you receive.
- Not deductible: a loss on a personal residence. It produces no deduction and no carryforward.
- Special treatment: depreciation since 6 May 1997, which is excluded from Section 121 relief and taxed at up to 25%.
Related calculations and planning options
Gain and proceeds answer different questions, and it is worth running both. The seller net sheet calculator gives you the cash that reaches your account after the mortgage payoff — a figure that can be far smaller or far larger than the gain computed here. The commission calculator sizes the largest of the selling costs that reduce the amount realized.
For a property that has been a rental, the depreciation side needs care. The rental property depreciation calculator reconstructs how much was allowable over the holding period, and the depreciation recapture calculator handles the recapture computation in more detail than this page does. If the property is an investment rather than a residence, a 1031 exchange can defer the entire gain into a replacement property — but a like-kind exchange is not available for a personal residence, and the rules on timing and identification are strict.
Two planning levers are worth knowing about. Improving basis is retrospective and costs nothing but record-keeping. And converting a rental back into a principal residence for two years does not shelter the whole gain — the non-qualified-use rules allocate gain to the rental period, and depreciation recapture survives regardless. If you are considering that move, model it with an adviser before you rely on it.
