How to Avoid Paying Taxes When Selling a House

Most people who sell their main home owe no federal tax on the profit, and the rest can usually shrink the bill with a handful of legal moves. To avoid paying taxes when selling a house, the core tool is the Section 121 exclusion, which shelters up to $250,000 of gain for single filers and $500,000 for married couples filing jointly. When a sale produces more than that, or when the property isn’t your primary residence, cost-basis adjustments, partial exclusions, like-kind exchanges, installment sales, and loss harvesting can reduce or defer what’s owed.

The Primary Residence Exclusion

Section 121 is the reason most home sales generate no tax at all. If you owned the home and lived in it as your primary residence for at least two of the five years before the sale, you can exclude up to $250,000 of gain. Married couples filing jointly can exclude up to $500,000, as long as both spouses meet the two-year use requirement and at least one meets the ownership requirement.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence The two years don’t have to be consecutive. You could live in the home for 14 months, move out for a year, move back for 10 months, and still qualify.

A few details trip people up. The property must be your primary residence, not a vacation home you visit a few weekends a year. The IRS looks at where you actually live day to day, and if questioned, practical evidence matters: voter registration, the address on your tax returns, where you get your mail, and utility records showing regular usage. You can also claim this exclusion only once every two years, so count backward from your closing date if you used it on a prior sale.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence

If your gain falls entirely within the exclusion, you generally don’t need to report the sale at all. The closing agent can skip issuing a Form 1099-S if you certify in writing that the home was your principal residence, the sale price doesn’t exceed $250,000 (or $500,000 for a married seller), and the full gain is excludable.2Internal Revenue Service. Instructions for Form 1099-S Proceeds From Real Estate Transactions Anything above the exclusion is taxed at long-term capital gains rates of 0%, 15%, or 20%, depending on your income.3Internal Revenue Service. Topic No. 409, Capital Gains and Losses

Surviving Spouses

If your spouse recently died, you may still qualify for the full $500,000 exclusion rather than the $250,000 single-filer amount. The sale must close no later than two years after the date of death, you must remain unmarried at the time of the sale, and the ownership and use requirements must have been met immediately before your spouse died.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence That window closes fast, and it’s one of the most financially significant timelines a widow or widower faces.

Military and Foreign Service Members

Active-duty members of the uniformed services or Foreign Service stationed away from home can elect to suspend the five-year lookback period for up to 10 additional years. That means you could be away on extended duty for a decade, return, and still satisfy the two-year residency requirement using time you lived in the home before your assignment.4eCFR. 26 CFR 1.121-5 – Suspension of 5-Year Period for Certain Members of the Uniformed Services and Foreign Service The suspension applies to both the ownership and use tests, and a spouse’s qualifying service counts too.

Partial Exclusion If You Sell Before Two Years

Selling before the two-year mark doesn’t automatically mean paying tax on the entire gain. The IRS allows a prorated exclusion when the sale is driven by a job relocation, a health issue, or an unforeseen event.5Internal Revenue Service. Publication 523, Selling Your Home

A job-related move qualifies if your new workplace is at least 50 miles farther from the home than your previous workplace was. Health-related sales qualify when the move is needed to obtain treatment for or care for yourself, a spouse, a co-owner, or a family member living in the home. The IRS defines “family member” broadly here, covering parents, children, siblings, in-laws, aunts, uncles, nieces, and nephews.5Internal Revenue Service. Publication 523, Selling Your Home Unforeseen events include divorce, legal separation, and multiple births from a single pregnancy, among others.

The math is simple. Divide the time you actually lived in the home by 24 months, then multiply that fraction by your maximum exclusion. A single filer who lived in the home for 12 months before relocating for a job would get 12/24 of $250,000, or a $125,000 exclusion.5Internal Revenue Service. Publication 523, Selling Your Home Not as generous as the full amount, but enough to wipe out the tax bill on many sales.

Raise Your Cost Basis Before You Calculate Gain

Your taxable gain isn’t the difference between what you paid and what you sold for. It’s the difference between your adjusted cost basis and the net sale price after selling expenses. Every dollar added to your basis is a dollar subtracted from taxable gain.

The starting basis is whatever you paid for the home, including the down payment and financed amount. From there, add capital improvements: projects that increase the home’s value, extend its useful life, or adapt it to a new use. The IRS draws a firm line between improvements and maintenance.5Internal Revenue Service. Publication 523, Selling Your Home Adding a bedroom, installing central air conditioning, replacing a roof, or putting in a new heating system all count. Painting walls, patching cracks, and fixing a leaky faucet do not.

Selling expenses reduce your gain too. Real estate agent commissions, legal fees, title insurance, and advertising costs all get subtracted from the sale price when calculating profit.5Internal Revenue Service. Publication 523, Selling Your Home On a typical sale where the agent takes 5% to 6% and legal and title costs add another percent or two, you might trim $20,000 to $40,000 or more from taxable gain before the exclusion even applies.

Some costs look like they should count but don’t. Mortgage-related charges like loan origination fees, appraisal fees required by a lender, mortgage insurance premiums, and refinancing costs cannot be added to basis. Neither can fire insurance premiums or any rent you paid to occupy the home before closing.5Internal Revenue Service. Publication 523, Selling Your Home Keep receipts for every improvement project. In an audit, the IRS won’t take your word that you spent $30,000 on a kitchen remodel eight years ago.

Selling an Inherited Home

Inheriting a property comes with a significant tax advantage that many heirs don’t fully use. The basis resets to fair market value on the date the previous owner died, regardless of what they originally paid.6Internal Revenue Service. Gifts and Inheritances If a parent bought a house in 1985 for $80,000 and it was worth $450,000 when they died, your basis is $450,000. Sell for $460,000, and taxable gain is only $10,000.

This stepped-up basis effectively erases decades of appreciation. Selling relatively soon after the death, while the value is still close to the date-of-death appraisal, often produces little or no tax. One caveat: if the estate filed a federal estate tax return (Form 706), the basis you report must be consistent with the value used on that return. An accuracy-related penalty can apply if you claim a higher basis than what was reported for estate tax purposes.6Internal Revenue Service. Gifts and Inheritances

Moving Into a Rental Before Selling

A popular strategy in online forums is buying an investment property, renting it out, moving in for two years, and then claiming the Section 121 exclusion. It works, but not as cleanly as people expect. Since 2009, any period of “nonqualified use” before you move in reduces the exclusion proportionally.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence

If you owned a property for 10 years, rented it for 6 years, then lived in it for 4 years before selling, 6 of those 10 years count as nonqualified use. Sixty percent of the gain is ineligible for the exclusion, and only the remaining 40% can be sheltered by the $250,000 or $500,000 limit. On a $400,000 gain, that leaves $240,000 taxable regardless of the exclusion.

There’s an asymmetry that helps in the opposite direction. Time after you move out doesn’t count as nonqualified use, as long as it falls within the five-year lookback window. So if you live in a home for three years, then rent it out for two years before selling, that rental period is ignored for the nonqualified use calculation.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence Order matters. Living in the home first, then renting, is far more tax-friendly than the reverse.

Depreciation You Already Claimed Comes Back

If you claimed depreciation deductions while using part of the home as a home office, or while renting it out before converting it to your primary residence, those deductions resurface at sale. The Section 121 exclusion does not shelter depreciation recapture. Even if your total gain falls within the $250,000 or $500,000 limit, the portion tied to depreciation you previously claimed is taxed at a flat 25% rate.7Office of the Law Revision Counsel. 26 USC 1 – Tax Imposed

Say you claimed $40,000 in depreciation deductions over the years while renting. At sale, that $40,000 is taxed at 25% no matter what. The remaining gain above that can then qualify for the primary residence exclusion or be taxed at the regular long-term capital gains rate. This catches sellers off guard, since they assume the exclusion covers everything. It doesn’t cover the depreciation piece, and there’s no workaround short of a 1031 exchange on the investment portion.

Like-Kind Exchanges for Rentals and Investments

Section 121 doesn’t apply to rental or business properties. For those, the primary tool is a Section 1031 like-kind exchange, which defers the capital gains tax by rolling the proceeds into another investment property.8Office of the Law Revision Counsel. 26 USC 1031 – Exchange of Real Property Held for Productive Use or Investment The tax isn’t eliminated; it’s postponed until you eventually sell without exchanging. Many investors chain 1031 exchanges for decades, deferring gains until death, when heirs receive a stepped-up basis.

The deadlines are rigid. From the day you close on the sale of the relinquished property, you have exactly 45 days to identify potential replacement properties in writing. The entire purchase must close within 180 days of the sale, or by the due date of your tax return for that year (including extensions), whichever comes first.8Office of the Law Revision Counsel. 26 USC 1031 – Exchange of Real Property Held for Productive Use or Investment Miss either deadline and the full gain becomes taxable immediately.

You also cannot touch the sale proceeds. A qualified intermediary must hold the funds between the sale and the purchase. If the money passes through your hands or your bank account at any point, the IRS treats it as a completed sale, and the deferral is lost. To fully defer, the replacement property’s purchase price must equal or exceed the sale price of the property you gave up, and you must take on at least as much debt. Any cash you pull out or any reduction in your mortgage is treated as “boot” and taxed as gain in the year of the exchange.

Spreading the Gain With an Installment Sale

If the buyer pays you over time rather than in a lump sum, you can report the gain gradually as payments arrive. This is the installment method under Section 453, and it applies automatically to any sale where at least one payment arrives after the end of the tax year in which the sale occurs.9Office of the Law Revision Counsel. 26 USC 453 – Installment Method

Here’s the mechanic. You calculate a gross profit percentage by dividing total gain by total contract price. That percentage is applied to each payment (after subtracting the interest portion), and only that piece is reported as capital gains income for the year.10Internal Revenue Service. Publication 537, Installment Sales If your gross profit percentage is 40% and you receive a $50,000 payment, $20,000 is taxable gain and $30,000 is a nontaxable return of basis. The interest portion of each payment is taxed separately as ordinary income.

This works best when a lump-sum gain would push you into a higher tax bracket or trigger the net investment income tax. Spreading the income across several years can keep you in lower brackets on each slice. The installment method cannot be used for sales at a loss or for dealer sales where you regularly sell properties in the ordinary course of business.10Internal Revenue Service. Publication 537, Installment Sales

Offset the Gain With Investment Losses

When home sale profit exceeds the exclusion, tax-loss harvesting can chip away at the taxable remainder. If you sell stocks, mutual funds, or other investments at a loss during the same tax year, those losses offset your capital gains dollar for dollar. Short-term losses offset short-term gains first, long-term losses offset long-term gains first, and any net loss in one category can then offset gains in the other.3Internal Revenue Service. Topic No. 409, Capital Gains and Losses

If losses exceed gains for the year, you can deduct up to $3,000 of the excess ($1,500 if married filing separately) against ordinary income. Any remaining unused losses carry forward to future tax years indefinitely.3Internal Revenue Service. Topic No. 409, Capital Gains and Losses Timing is everything. The losses have to be realized in the same calendar year as the home sale. Selling an underwater stock in January doesn’t help if the closing happened the previous December.

Watch the 3.8% Surtax at Higher Incomes

Higher earners face an additional 3.8% surtax on any capital gain from a home sale that isn’t sheltered by Section 121. The net investment income tax kicks in when modified adjusted gross income exceeds $250,000 for married couples filing jointly, $200,000 for single filers, or $125,000 for married individuals filing separately.11Internal Revenue Service. Topic No. 559, Net Investment Income Tax These thresholds are not adjusted for inflation, so more taxpayers cross them each year.

The tax applies to the lesser of net investment income or the amount by which MAGI exceeds the threshold. A year with a large excluded home sale gain can push you over on its own. Combined with the 20% long-term capital gains rate at the top bracket, the effective federal rate on a home sale gain can reach 23.8%. Installment sales and loss harvesting are especially valuable in this income range, since keeping taxable gain below the threshold in any one year can eliminate the surtax entirely.

What Rate Applies to the Leftover Gain

Any gain that isn’t excluded or deferred is treated as a long-term capital gain if you owned the property for more than one year. Long-term rates are 0%, 15%, or 20%, depending on overall taxable income, and the bracket thresholds adjust annually for inflation.3Internal Revenue Service. Topic No. 409, Capital Gains and Losses7Office of the Law Revision Counsel. 26 USC 1 – Tax Imposed

If you owned the property for one year or less, gain is short-term and taxed at your ordinary income rate, which can reach 37%. That rarely comes up for primary residences (the exclusion requires two years anyway), but it matters for flipped investment properties or homes sold shortly after purchase without meeting the partial exclusion requirements.

Reporting the Sale

Whether you have to report depends on the numbers. If your gain is fully covered by the Section 121 exclusion and you certified that to the closing agent, no Form 1099-S is issued and you generally don’t need to report the sale on your return.2Internal Revenue Service. Instructions for Form 1099-S Proceeds From Real Estate Transactions If a 1099-S was issued, or if your gain exceeds the exclusion, you report the sale on Schedule D and Form 8949. Installment sales use Form 6252 instead.

Even when reporting isn’t strictly required, it can be smart to report a sale that comes close to the exclusion limit. If the IRS sees information suggesting you sold real estate but finds no corresponding entry on your return, it may flag the omission. Reporting the sale and showing the exclusion calculation eliminates that risk and documents your basis in case questions come up later.