IRS Publication 523 sets the federal tax rules for selling your main home: if you owned and lived in it for at least two of the five years before closing, you can exclude up to $250,000 of gain from your income, or up to $500,000 if you’re married filing jointly. Gain above that limit is taxed as a long-term capital gain. The rules also cap the exclusion at one use every two years, adjust the math when you had a home office or rented the property out, and give special treatment to divorces, surviving spouses, inherited homes, and military service.
Which Home the Rules Cover
The exclusion applies only to your main home, which is generally the place where you live most of the time. If you own more than one property, the IRS uses a facts-and-circumstances test. Time spent there matters most, but the address on your voter registration, tax returns, and driver’s license also counts, along with proximity to work, your bank, and family.1Internal Revenue Service. Publication 523 (2025), Selling Your Home The more of those markers pointing to the same property, the stronger the case that it’s your principal residence.
The Ownership and Use Tests
To claim the full exclusion, you must pass two tests measured over the five years ending on the closing date. Each requires at least 24 months, and neither has to be continuous. You can stitch together shorter stretches to reach the total.
The ownership test asks whether your name was on the deed for at least 24 months during that five-year window.1Internal Revenue Service. Publication 523 (2025), Selling Your Home For married couples filing jointly, only one spouse needs to meet it.
The use test asks whether you lived in the home as your principal residence for at least 24 months during the same window. The 24 months of use don’t have to overlap with the 24 months of ownership. Short absences like vacations still count as use, even if you rented the place out while away.1Internal Revenue Service. Publication 523 (2025), Selling Your Home For the $500,000 joint exclusion, both spouses must independently meet the use test.
The Once-Every-Two-Years Rule
Passing both tests isn’t enough on its own. You can only use the Section 121 exclusion once every two years. If you or your spouse excluded gain on a different home sale within the two years before your current sale, the full exclusion is off the table.2eCFR. 26 CFR 1.121-2 – Limitations A reduced exclusion may still be available if the sale was triggered by a qualifying event (see below).
Extra Time for Military and Similar Service
Members of the uniformed services, the Foreign Service, and the intelligence community can elect to suspend the five-year lookback period for up to ten years while on qualified official extended duty. That stretches the potential testing window to 15 years. To qualify, the duty station must be at least 50 miles from the home, or you must be living in government quarters under orders, and the call must exceed 90 days or be indefinite.3Office 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 also qualify.1Internal Revenue Service. Publication 523 (2025), Selling Your Home
Calculating Your Gain
The exclusion only helps if there is a gain. Your gain is the amount realized on the sale minus your adjusted basis in the home.
Adjusted basis starts with the original purchase price, including the down payment and the amount you borrowed. Add qualifying settlement fees and closing costs from when you bought the home, but not financing-related costs like loan origination fees or mortgage insurance premiums. Then add the cost of capital improvements: work that adds value or extends useful life, such as a new roof, a kitchen remodel, an added bathroom, or replacing all the windows. Ordinary repairs and maintenance don’t count. Finally, subtract any depreciation you claimed or were allowed to claim, such as for a home office or rental use. Depreciation lowers your basis and raises your taxable gain.1Internal Revenue Service. Publication 523 (2025), Selling Your Home
Amount realized is your sale price minus your selling expenses. Publication 523 treats the following as selling expenses:1Internal Revenue Service. Publication 523 (2025), Selling Your Home
- Real estate commissions paid to your agent and the buyer’s agent
- Advertising costs you paid directly
- Legal fees related to the sale
- Loan charges you agreed to cover for the buyer, such as discount points
- Other costs directly tied to selling, which can include title insurance fees and transfer taxes paid by the seller
Don’t mix these up with the closing costs from when you bought the home. Those go into basis, not into your selling expense calculation.
Exclusion Limits and What Gets Taxed
Single filers and married individuals filing separately can exclude up to $250,000 of gain. Married couples filing jointly can exclude up to $500,000, provided one spouse meets the ownership test, both spouses meet the use test, and neither used the exclusion on another home in the prior two years.2eCFR. 26 CFR 1.121-2 – Limitations If only one spouse meets the use test, a joint return is limited to the $250,000 amount.
The exclusion caps at your actual gain. A $180,000 gain against a $250,000 limit means no tax and no unused exclusion carried forward. Gain above the limit is taxable. A married couple with a $600,000 gain would exclude $500,000 and owe capital gains tax on the remaining $100,000.
That taxable slice is treated as a long-term capital gain if you owned the home for more than a year, so it falls into the 0%, 15%, or 20% federal rate depending on your taxable income. High-income sellers can also face the 3.8% Net Investment Income Tax on the taxable portion once modified adjusted gross income exceeds $200,000 (single) or $250,000 (married filing jointly). NIIT does not apply to gain covered by the Section 121 exclusion itself; only the recognized gain above the exclusion counts as net investment income.4Internal Revenue Service. Questions and Answers on the Net Investment Income Tax Those thresholds are not indexed to inflation.
Reduced Exclusion When You Sell Early
Selling before you clear the 24-month bar doesn’t necessarily wipe out the exclusion. The code allows a prorated exclusion when the sale is driven by a qualifying event. Publication 523 lists safe-harbor events that automatically qualify: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
- Death, divorce or legal separation, a multiple birth from the same pregnancy, eligibility for unemployment compensation, or an inability to pay basic living expenses because of a change in employment, affecting you, your spouse, a co-owner, or another resident of the home
A job-related move also qualifies if the new workplace is at least 50 miles farther from the home than the old one.
To find the reduced amount, take the shortest of three periods: time you lived in the home during the five-year window, time you owned it, or time since you last used the exclusion on another home. Divide days by 730 (or months by 24), then multiply by $250,000.1Internal Revenue Service. Publication 523 (2025), Selling Your Home Joint filers each run the calculation and combine results. A single filer who owned and lived in the home for 15 months before an eligible job transfer would divide 15 by 24, giving 0.625, and multiply by $250,000 for a reduced exclusion of $156,250.
Business Use, Rentals, and Depreciation Recapture
Many sellers used part of the property for something other than personal living space. How the tax works depends on where that use happened and when.
Non-Qualified Use
Any period after December 31, 2008, when the home wasn’t your (or your spouse’s) main home is non-qualified use. Common examples are renting it out or holding it as a vacation home before moving in.3Office of the Law Revision Counsel. 26 U.S.C. 121 – Exclusion of Gain From Sale of Principal Residence Divide the total post-2008 non-qualified use period by your total ownership period. That fraction of your gain is taxable regardless of the exclusion limits. The remaining gain can still be run through the normal Section 121 exclusion.
Home Office Inside Your Living Space
If the business use happened inside the home, you don’t split the sale into business and personal pieces. The whole gain is eligible for the exclusion. But you can’t exclude the portion of gain equal to any depreciation claimed or that should have been claimed after May 6, 1997.5Internal Revenue Service. Sales, Trades, Exchanges 3 That amount is taxed as unrecaptured Section 1250 gain at a maximum rate of 25%.
Separate Business Structure
If the business space is physically separate from the dwelling, such as a rented unit in a duplex, a detached workshop, or farmland, you must allocate proceeds and basis between the residential and non-residential portions. The business portion is reported on Form 4797 and does not qualify for the exclusion unless you also owned and lived in that portion for at least two of the last five years.1Internal Revenue Service. Publication 523 (2025), Selling Your Home Depreciation on the separate structure is recaptured at the same 25% maximum rate.
Divorce, Surviving Spouses, and Inherited Homes
Life events can rearrange the ownership and use math, and Section 121 has specific rules for each.
When a home is transferred between spouses or former spouses as part of a divorce under Section 1041, the receiving spouse takes over the transferor’s entire ownership period. Three years of ownership by your ex before the transfer becomes three years of ownership for you. The use test gets a parallel benefit: if your former spouse continues living in the home under a divorce decree or separation agreement, that time counts as your use of the property, even after you’ve moved out.3Office of the Law Revision Counsel. 26 U.S.C. 121 – Exclusion of Gain From Sale of Principal Residence
A surviving spouse who sells within two years of the other spouse’s death can claim the full $500,000 exclusion rather than the $250,000 single-filer amount. To qualify, you must not have remarried before the sale, neither you nor your late spouse can have used the exclusion on another home within the previous two years, and you must meet the ownership and use requirements, counting the deceased spouse’s time toward both tests.1Internal Revenue Service. Publication 523 (2025), Selling Your Home
When you inherit a home, your basis is generally stepped up to the fair market value on the date of death under Section 1014.6Office of the Law Revision Counsel. 26 U.S. Code 1014 – Basis of Property Acquired From a Decedent That step-up often erases most of the built-in gain. Move into the inherited home and use it as your principal residence for at least 24 months, and any post-inheritance appreciation can also fall inside the Section 121 exclusion.
Homes Acquired Through a 1031 Exchange
If you turned a rental or investment property into your main home through a Section 1031 like-kind exchange, the ownership requirement stretches. You can’t use the Section 121 exclusion until you’ve owned the property for at least five years from the date of the exchange, not the usual two-year minimum.7Office of the Law Revision Counsel. 26 U.S. Code 121 – Exclusion of Gain From Sale of Principal Residence Non-qualified use rules also still apply, so rental years before you moved in reduce the excludable share of gain.
Selling at a Loss
Selling for less than your adjusted basis produces a loss, but you can’t deduct it. Losses on personal-use property, including your main home, are not deductible and do not count toward the $3,000 annual capital loss deduction that applies to investment assets.8Internal Revenue Service. What if I Sell My Home for a Loss? A personal-residence sale that produces only a loss doesn’t need to be reported.
Reporting the Sale
If your entire gain is covered by the exclusion, you met the ownership and use tests, and you didn’t receive a Form 1099-S from the closing agent, you generally don’t need to report the sale.9Internal Revenue Service. Instructions for Form 1099-S Many closing agents skip issuing the 1099-S when you certify in writing that the full gain is excludable and there was no non-qualified use.
You must report the sale if any of the following are true:
- 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
Reportable sales go on Form 8949 and flow to Schedule D of Form 1040. Enter the full sale price and basis on Form 8949, then record the excluded gain as a negative adjustment using code “H” in column (f). Only the taxable portion carries forward to Schedule D.10Internal Revenue Service. Instructions for Form 8949 (2025) Any separate business or rental portion of the property is reported on Form 4797 instead.5Internal Revenue Service. Sales, Trades, Exchanges 3
Keep your records even when the sale generates no tax. Hold onto the original closing statement, receipts for every improvement, and documentation of any depreciation claimed. The IRS can audit returns for up to three years after filing, or six years if income is substantially understated, and without records you can’t defend your basis.