IRS Publication 523 is the agency’s guide to the federal tax rules for selling your main home, and its central promise is this: if you owned and lived in the home for at least two of the five years before the sale, you can exclude up to $250,000 of profit from your taxable income, or up to $500,000 if you’re married filing jointly.1Internal Revenue Service. Publication 523 (2025), Selling Your Home Everything else in the publication exists to tell you how to measure the gain, when the exclusion shrinks or disappears, and when you have to report the sale at all. One boundary worth stating up front: a loss on the sale of your personal residence is not deductible.2Internal Revenue Service. What if I Sell My Home for a Loss?
Who Qualifies for the Exclusion
The exclusion comes from Internal Revenue Code Section 121 and turns on two tests, both measured over the five-year window ending on your closing date.
Ownership test. Your name must have been on the deed for at least 24 months during that five-year window. The months don’t have to be consecutive. For a married couple filing jointly, only one spouse has to meet this test.1Internal Revenue Service. Publication 523 (2025), Selling Your Home
Use test. You must have lived in the home as your principal residence for at least 24 months during the same five-year window. The 24 months of use don’t need to overlap with the 24 months of ownership. Vacations and short absences still count, even if you rented the home out while you were away. To claim the full $500,000 exclusion on a joint return, both spouses must meet the use test independently; if only one does, the couple is capped at $250,000.1Internal Revenue Service. Publication 523 (2025), Selling Your Home
Your main home is generally where you spend most of your time. If you own more than one property, the IRS looks at a mix of factors: time spent, the address on your voter registration, tax returns, and driver’s license, and proximity to work, bank, and family.1Internal Revenue Service. Publication 523 (2025), Selling Your Home
The once-every-two-years rule. Even if you pass both tests, you can only claim the full Section 121 exclusion once in any two-year period. If you or your spouse already excluded gain on a different home sold within the two years before this one, the full exclusion is off the table. A reduced exclusion may still be available if the sale was triggered by a qualifying event.3eCFR. 26 CFR 1.121-2 – Limitations
How to Figure Your Gain
Your gain is your amount realized minus your adjusted basis. The exclusion only matters if that number is positive.
Adjusted Basis
Start with the purchase price, including the down payment and the amount you borrowed. Add qualifying settlement costs from the purchase (things like abstract fees, recording fees, surveys, and owner’s title insurance), but not financing costs such as loan origination fees or mortgage insurance premiums.
Then add the cost of capital improvements made while you owned the home. An improvement adds value or extends the home’s useful life: a new roof, a kitchen remodel, an added bathroom, replacement of all the windows. Ordinary repairs don’t count. Fixing a gutter, patching drywall, or painting a room keeps the home in its existing condition and doesn’t raise your basis.
Finally, subtract any depreciation you claimed or were allowed to claim, for a home office or rental use, for example. Depreciation reduces your basis, which increases your taxable gain.1Internal Revenue Service. Publication 523 (2025), Selling Your Home
Amount Realized
Amount realized is the sale price minus selling expenses. Publication 523 counts real estate commissions, advertising costs you paid directly, legal fees tied to the sale, loan charges you covered on the buyer’s behalf (such as discount points), and other costs directly connected to selling, which can include title insurance and transfer taxes paid by the seller.1Internal Revenue Service. Publication 523 (2025), Selling Your Home Purchase-side settlement costs belong in basis, not here.
A Worked Example
Say you bought a home for $300,000, spent $50,000 on qualifying improvements, and sold it for $600,000 with $35,000 in selling expenses. Your adjusted basis is $350,000, your amount realized is $565,000, and your gain is $215,000. A single filer who passes both tests owes no federal tax on that sale, since the gain is under the $250,000 limit.
What Happens to Gain Above the Exclusion
Gain that exceeds your exclusion limit is taxed as a long-term capital gain, assuming you owned the home for more than a year. The federal long-term rates are 0%, 15%, or 20% depending on taxable income. For 2026, a single filer pays 0% up to $49,450, 15% from $49,451 through $545,500, and 20% above that. For joint filers, the 15% band runs from $98,901 to $613,700.
A married couple with a $600,000 gain, for instance, excludes $500,000 and pays long-term capital gains tax on the remaining $100,000.
Higher-income sellers may also owe the 3.8% Net Investment Income Tax on the taxable portion. NIIT kicks in when modified adjusted gross income is above $200,000 for single filers or $250,000 for joint filers. Gain covered by the Section 121 exclusion is not investment income for NIIT purposes; only the recognized gain above the exclusion counts.4Internal Revenue Service. Questions and Answers on the Net Investment Income Tax Those thresholds don’t adjust for inflation.
Partial Exclusion When You Sell Before Two Years
Selling before you’ve hit the 24-month mark doesn’t automatically disqualify you. Section 121 allows a prorated exclusion if the sale was driven by a qualifying event.
Publication 523 lists safe-harbor events that automatically qualify, so long as they occurred while you owned and lived in the home:1Internal Revenue Service. Publication 523 (2025), Selling Your Home
- The home was destroyed or condemned.
- The home suffered a casualty loss from a disaster or act of terrorism.
- You, your spouse, a co-owner, or another resident of the home died, became divorced or legally separated, gave birth to two or more children from the same pregnancy, became eligible for unemployment compensation, or became unable to pay basic living expenses because of a change in employment.
- A job-related move, if the new workplace is at least 50 miles farther from the home than your old workplace was.
To calculate the reduced exclusion, find the shortest of three periods: how long you lived in the home during the five-year window, how long you owned it, or how long it has been since you last claimed the exclusion. Divide that figure (in days by 730, or months by 24) and multiply by $250,000.1Internal Revenue Service. Publication 523 (2025), Selling Your Home Joint filers run the calculation separately for each spouse and add the results.
A single filer who owned and lived in the home for 15 months before an eligible job transfer would get 15 ÷ 24 × $250,000, or $156,250.
Rental Use, Home Offices, and Depreciation Recapture
If the property wasn’t your principal residence for part of the time you owned it, two separate rules can bite into your exclusion.
Non-qualified use. Any period after December 31, 2008, during which the home wasn’t your (or your spouse’s) main home is “non-qualified use.” Renting the home out or using it as a vacation property are the common examples.5Office of the Law Revision Counsel. 26 U.S.C. 121 – Exclusion of Gain From Sale of Principal Residence Divide the post-2008 non-qualified use period by your total ownership period, and that fraction of the gain is taxable regardless of the exclusion. The remaining gain is eligible for the normal Section 121 treatment. If you owned a home for ten years, rented it out for four of those (after 2008), and lived in it for the other six, 40% of the gain is taxable and 60% can go against the exclusion.
Depreciation recapture. Depreciation claimed (or allowable) after May 6, 1997, cannot be excluded under Section 121. It is taxed as unrecaptured Section 1250 gain at a maximum rate of 25%.6Internal Revenue Service. Sales, Trades, Exchanges 3 If the business use was inside the dwelling (a home office in a spare bedroom), you don’t split the sale between personal and business portions; the whole gain qualifies for the exclusion except for the depreciation piece. If the business space was physically separate (a rented unit in a duplex, a detached workshop, farmland), you allocate the sale price and basis between residential and non-residential portions, and the business portion is reported on Form 4797. That business portion only qualifies for the exclusion if you also owned and lived in it for two of the last five years.1Internal Revenue Service. Publication 523 (2025), Selling Your Home
Divorce, Death of a Spouse, Inheritance, and 1031 Property
Divorce. When a home moves between spouses or former spouses in a divorce under Section 1041, the receiving spouse picks up the transferor’s full ownership period. And if a former spouse continues living in the home under a divorce or separation instrument, that time counts as your use of the home for Section 121, even after you’ve moved out.5Office of the Law Revision Counsel. 26 U.S.C. 121 – Exclusion of Gain From Sale of Principal Residence
Surviving spouses. A widow or widower can claim the full $500,000 exclusion on a sale within two years of the spouse’s death, provided they haven’t remarried, neither spouse used the exclusion in the previous two years, and the ownership and use tests are met (counting the deceased spouse’s time).1Internal Revenue Service. Publication 523 (2025), Selling Your Home
Inherited homes. Your basis in an inherited home is generally stepped up to its fair market value on the date of death under Section 1014, which often wipes out most of the built-in gain.7Office of the Law Revision Counsel. 26 U.S. Code 1014 – Basis of Property Acquired From a Decedent If you later move in and meet the 24-month use test, you can also apply the Section 121 exclusion to any appreciation after you inherited.
Property from a 1031 exchange. If you obtained the home through a like-kind exchange of investment property, you can’t use the Section 121 exclusion until you’ve owned it for at least five years from the exchange date, not the usual two.8Office of the Law Revision Counsel. 26 U.S. Code 121 – Exclusion of Gain From Sale of Principal Residence Non-qualified use rules still apply to the rental years.
Suspension for Military, Foreign Service, and Intelligence Personnel
Members of the uniformed services, the Foreign Service, and the intelligence community can elect to suspend the five-year lookback for up to ten years while on qualified official extended duty, stretching the combined testing window as long as 15 years. The duty station must be at least 50 miles from the home, or you must be living in government quarters under orders, and the assignment must exceed 90 days or be indefinite.5Office of the Law Revision Counsel. 26 U.S.C. 121 – Exclusion of Gain From Sale of Principal Residence Peace Corps volunteers serving outside the United States qualify for the same suspension.1Internal Revenue Service. Publication 523 (2025), Selling Your Home
Reporting the Sale
If your entire gain fits inside the exclusion, you met both tests, and you didn’t receive a Form 1099-S from the closing agent, you generally don’t have to report the sale at all.9Internal Revenue Service. Instructions for Form 1099-S Many closing agents will skip the 1099-S if you certify in writing that the full gain is excludable and there was no period of non-qualified use.
You do need to report the sale if any of the following apply:
- You received a Form 1099-S.
- Your gain exceeds the exclusion limit.
- Part of the gain is allocable to non-qualified use.
- You’re claiming a reduced exclusion.
- You have depreciation to recapture.
When you report, the sale goes on Form 8949 and flows to Schedule D of Form 1040. Enter the full sale price and basis on Form 8949, then show the excluded gain as a negative adjustment with code “H” in column (f). Only the taxable portion carries over to Schedule D.10Internal Revenue Service. Instructions for Form 8949 (2025) A separate business or rental portion of the property is reported on Form 4797.6Internal Revenue Service. Sales, Trades, Exchanges 3
Keep your records even when nothing is owed. Hold onto the original closing statement, receipts for every improvement, and any depreciation documentation. The IRS can audit returns for up to three years after filing, and up to six years when income is substantially understated. Without records, you have no way to defend your basis if asked.