Guides › Money

Capital Gains Tax When You Sell a House: The Exclusion, the Two-Year Rule and Basis

How the $250,000 and $500,000 exclusion works, the two-of-five-years test, what counts as your basis, and the situations where sellers owe tax they did not expect.

Updated September 2026

Most people who sell the house they live in owe no federal capital gains tax at all, and a smaller number owe far more than they expected. The difference is almost always one of three things: whether the house was your main home, how long you lived in it, and what you can prove you paid for it. This is general information, not tax advice; the actual return belongs to a CPA who can see your numbers.

The exclusion, in one paragraph

When you sell your main home, federal law lets a single filer exclude up to $250,000 of gain from tax and a married couple filing jointly up to $500,000. Gain is the sale price, less selling costs, less your basis. If your gain is under the limit, the sale usually does not even create a tax bill, and in many cases does not have to be reported unless you receive a form from the closing agent.

The two-of-five-years rule

To use the exclusion you must have owned the house and lived in it as your main home for at least two of the five years ending on the sale date. The two years do not need to be continuous and the ownership years and the use years do not need to be the same years. For a married couple, both spouses have to meet the use test, and only one has to meet the ownership test, to claim the full amount.

The rule is what catches landlords and inheritors. A house you rented out for the last four years and lived in for one does not qualify. A house you inherited and never lived in does not qualify either, although the step-up in basis on inherited property usually makes the exclusion unnecessary; see selling an inherited house.

You can only use the exclusion once every two years. Sell two homes in eighteen months and the second one is fully taxable, however long you lived there.

What counts as basis

Basis is where sellers leave money on the table, because they only count the original purchase price. Your basis is:

  • What you paid for the house, including most of the closing costs you paid when you bought it: title fees, recording fees, transfer taxes, survey and legal fees.
  • Plus capital improvements. A new roof, an addition, a replaced furnace, a kitchen remodel, a new septic system, a fence, a driveway. Not repairs: patching the roof is a repair, replacing it is an improvement.
  • Minus depreciation you claimed or could have claimed, if you ever rented out the house or took a home office deduction. This part is taxed separately and is not covered by the exclusion.

The practical consequence: find every receipt for work you did to the house, going back to the day you bought it. Twenty years of improvements on a modest house can add tens of thousands to basis, and every dollar of basis is a dollar of gain you do not pay tax on. If the receipts are gone, bank statements, permits and contractor invoices are the next best evidence.

Selling costs reduce the gain too

Agent commission, transfer taxes you paid as seller, title fees, legal fees, and the cost of getting the house ready to show all come off the sale price before the gain is calculated. Sellers who forget this overstate their gain by the whole commission.

The partial exclusion nobody tells you about

If you fail the two-year test because of a job move, a health reason, or an unforeseen event such as a divorce, a death in the household or a job loss, you can often claim a partial exclusion. It is prorated by how much of the two years you completed. Somebody who lived in a house for one year and had to relocate for work can typically exclude half the full amount, which on most houses still wipes out the gain entirely. Ask about this before assuming the whole gain is taxable.

Where people actually get a bill

  • A second home or a rental. No exclusion at all. The gain is taxed as a long-term capital gain if held over a year, plus depreciation recapture on a rental.
  • A long-held house in an expensive market. A house bought decades ago can carry gain well above the limit. Improvements and selling costs close some of the gap; the rest is taxable, at long-term rates.
  • A recently divorced seller. Filing single halves the exclusion. Timing the sale relative to the decree matters; see selling the house in a divorce.
  • A house held less than a year. Gain is taxed as ordinary income, at your normal rate, with no exclusion unless a partial one applies.

State tax

Most states tax capital gains as ordinary income and most follow the federal exclusion, but not all, and a handful of states withhold tax at closing from sellers who live elsewhere. The closing agent will know whether withholding applies to you; ask before the settlement statement is final rather than after.

What this means for a cash sale

Nothing about how you sell changes the tax. A cash buyer, an agent and an iBuyer all produce the same gain calculation; the only differences are the selling costs you deduct and the date. What does change is that a cash sale lets you pick the closing date, and if the date decides which tax year the gain lands in, or whether you cross the two-year line, that is worth a conversation with a CPA before you sign.

Wondering what your house would fetch as-is?

A written cash offer in about 24 hours. Free, and you are under no obligation.

Or call (888) 555-0142. No obligation, ever.