Wealthy Habitat

Library · Home · Published 9/29/2026

Selling a home and the gain exclusion

When you sell your main home, a tax rule may let you exclude a large part of your profit if you meet the ownership and use tests.

In short

A friend of mine sold his little house last spring and worried for weeks about a tax bill that never came. If you are selling the home you live in, the tax law may let you keep a large part of your profit tax free. That break is called the home sale gain exclusion, and it lives in Section 121 of the Internal Revenue Code. The ownership test asks whether you owned the home for at least two of the five years before the sale. The use test asks whether you lived in it as your main home for at least two of those years. Your gain is your sale price, minus your selling costs, minus your basis, which is what you paid plus certain improvements. Keep your closing papers and improvement receipts, because they are the proof the IRS may ask to see.

The whole of it

What it is

I once watched a neighbor pack up thirty years of memories and then lose sleep over one question. Would the government take a big bite of what he made? For many people selling a family home, the answer is kinder than they fear. Congress wrote a rule that lets homeowners leave out a set amount of profit from their income when they sell a main home.

You have probably heard the word "gain" used loosely. Here it means your profit on paper. It is what you sold for, less what it cost you to sell, less what the home cost you to own. The exclusion wipes out some or all of that profit for tax purposes. If your gain is under the limit, you may owe no tax on it. If it is over, only the extra is taxed.

The rule is not a loophole. It is meant for people who use a house as a home, not as a business. That is why it comes with tests about how long you owned the place and how long you lived there. Meet the tests, and the law is on your side. Miss them, and you may still qualify for a smaller break. More on that below.

How it works

If you are holding the keys to a home you plan to sell, start with two clocks. The first is the ownership test. The law asks whether you owned the home for at least two years during the five years that end on the sale date. The second is the use test. The law asks whether you lived in it as your main home for at least two years during that same five year window. The two years do not have to be in a row. They do not have to be the same two years for both tests.

The amount you can exclude depends on how you file. A single filer gets one limit. A married couple filing jointly gets a larger one. Under the law, both spouses must meet the use test, and at least one must meet the ownership test. Those dollar limits are set by statute. The current figures are the current figure, which the official source publishes each year for a single filer and the current figure, which the official source publishes each year for a married couple filing jointly.

There is also a spacing rule. The exclusion generally does not apply if you used it on another home sale within the two years before this one. So it is not a break that stacks back to back.

What if life got in the way? A job move, a health problem, or certain unforeseen events can allow a reduced exclusion even when you fall short of two years. The reduced amount is based on the share of the two years you did meet. It is worth asking about if your plans changed fast.

Now for the math. Your gain equals the amount realized minus your adjusted basis. The amount realized is the sale price less your selling costs, such as agent fees and certain closing costs. Your adjusted basis is what you paid for the home, plus the cost of real improvements, minus any depreciation you were required to take. Depreciation is a tax deduction for wear on a rental or business space. A new roof or a finished basement counts as an improvement. Routine repairs, like patching a fence, generally do not.

The numbers, and where to find yours

Two kinds of numbers matter here. The first kind is set by law, and it can change. The exclusion limits are one example. Check the current figures on the IRS website and in Publication 523, titled Selling Your Home. Do not trust a number you saw in an old article or heard at a barbecue.

The second kind is your own. Your purchase price and your closing costs from when you bought are on the settlement statement you signed at closing. Look for it in your files or your email. You can also ask the title company or your lender. Your improvement costs come from receipts, invoices, and bank records. If you have lost some, old contractor statements and card records can help you rebuild the story.

When you sell, you will receive a closing statement. You may also get a Form 1099 S, which reports the sale to the IRS. If you get one, what you report must match it. Whether you must report the sale at all depends on your case. Publication 523 explains when reporting is required and when it is not.

One more source is worth naming. The IRS topic page on selling your home explains the basics in plain language, and it points to the forms. Read it before you file.

A worked example

Let me tell you about Ruth and Daniel, a couple in their fifties who file a joint return. They bought their house years ago for 210,000 dollars. Along the way they paid 15,000 dollars to finish the basement and 9,000 dollars for a new roof. Those are real improvements, so together they add 24,000 dollars to the basis.

Their adjusted basis is 210,000 plus 24,000, which is 234,000 dollars. They sell the house for 520,000 dollars. They pay 31,000 dollars in agent fees and closing costs. Their amount realized is 520,000 minus 31,000, which is 489,000 dollars.

Now the gain. It is the amount realized minus the adjusted basis, so 489,000 minus 234,000. That is 255,000 dollars of gain.

Ruth and Daniel both lived in the home as their main home for the past eleven years, and they own it together. They meet the ownership test and the use test. They have not used the exclusion in the last two years. So the joint limit applies to them, and that limit is the current figure, which the official source publishes each year.

Here is how the check works. If the joint limit is larger than their 255,000 dollar gain, the whole gain is excluded, and they owe no federal income tax on it. If the limit is smaller than their gain, only the amount above the limit is taxed. To test your own case, take your gain, subtract the limit, and see whether anything is left over.

That is the whole calculation. Sale price, less costs, less basis, less the limit. Simple.

Where it goes wrong

I have seen good people trip over small things, and none of them were fools. The first stumble is poor records. If you cannot show what you spent on improvements, your basis looks lower, and your gain looks bigger. A shoebox of receipts works fine.

The second is timing. Picture someone who moves out for a job, rents the house for several years, and then sells. By then the use test may fail, since they did not live there for two of the last five years. Renting also raises another issue. Depreciation you took on a rental portion is not shielded by the exclusion in the usual way.

The third is a home office or a space used for business. If part of the home was used only for business and you claimed depreciation, you may owe tax on that part. Publication 523 covers this. Read it before you list the house.

A fourth trap is assuming the rule covers everything. It does not cover a second home or a pure investment property. It also does not settle your state taxes, since states set their own rules. Your own state's tax agency can tell you how it treats a home sale.

Divorce, the death of a spouse, and military service each carry their own special rules. If any of those touch your sale, read the fine print in Publication 523. A qualified tax preparer can also walk through it with you.

Questions to answer before you leave this page

Have you owned the home for at least two of the last five years, and have you lived in it as your main home for at least two of those years? Did you use this exclusion on another home sale within the past two years? Do you know your basis, including the price you paid and the cost of each real improvement? Can you find your closing statement and your receipts if someone asks? Did any part of the house serve as a rental or a business space, and did you claim depreciation on it? Are you filing single or jointly, and have you looked up the current limit for your situation on the IRS site? Have you read IRS Publication 523, and does your state tax agency treat the sale the same way the federal rules do?

Related

your primary home as an asset
reading a filing
marginal versus effective rates
points rates and closing costs

Ask about this guide

A model reads this page and answers from it. It will say when the answer is not on the page. Education, not personalized advice.

Written by the site's growth engine and checked by its gates: voice, law and ethics, facts, arithmetic, and sources. Not yet read by a human editor; every page carries the correction process. Rules and dollar limits change every year; figures come from the rules table with their source and date.