How capital gains tax works when you sell your home, who qualifies for the $250,000/$500,000 Section 121 exclusion, how to calculate cost basis, and the records to keep.
So you sold your house, or you're about to, and now you're wondering whether Uncle Sam is going to take a bite out of your profit. It's one of the most common questions homeowners ask, and honestly, the answer is better than most people expect. The vast majority of folks who sell their primary home pay zero federal capital gains tax. But "most people" isn't "everyone," and the rules have a few sharp edges that can cost you tens of thousands of dollars if you miss them.
This guide walks through exactly how capital gains tax works on a home sale, who qualifies for the big exclusion, how to figure out your real taxable profit, and the moves that legally shrink your bill. Let's get into it.
Quick disclaimer: This is general educational information, not tax advice. Tax law is full of exceptions, and your situation may have wrinkles a website can't see. Before you make a decision based on anything here, talk to a CPA or enrolled agent who can look at your actual numbers.
Why a Home Sale Can Trigger a Tax Bill in the First Place
When you sell almost any asset for more than you paid, the profit is a "capital gain," and capital gains are generally taxable. Your home counts as an asset. So in theory, if you bought a house for $300,000 and sold it for $500,000, you have a $200,000 gain that the IRS could tax.
Here's the relief valve: Congress created a special break for primary residences. It's called the Section 121 exclusion, and it lets most homeowners exclude a large chunk of that gain from tax entirely. The key word is exclusion: qualifying profit simply doesn't count as taxable income at all. It never shows up as a number you owe tax on.
The amount you can exclude is the headline everyone remembers:
- $250,000 of gain if you're single (or married filing separately).
- $500,000 of gain if you're married filing jointly.
That's the gain, not the sale price. If your taxable gain after all the math comes in under your exclusion limit, you owe nothing in federal capital gains tax and, in many cases, you don't even have to report the sale. That's why so many sellers walk away clean.
The Two Tests You Have to Pass: Ownership and Use
The exclusion isn't automatic. To claim it, you have to clear what the IRS calls the ownership test and the use test. Both look at the five years ending on the date you sold.
- Ownership test: You owned the home for at least 2 years out of the last 5.
- Use test: You lived in the home as your main residence for at least 2 years out of the last 5.
The two years don't have to be one continuous stretch, and they don't have to be the same two years. You could live somewhere, move out, move back, and still add up 24 months of use within that five-year window. The math is about total time, not a single unbroken block.
For married couples filing jointly, the rule is a little generous: only one spouse has to meet the ownership test, but both spouses have to meet the use test to claim the full $500,000. If only one spouse lived there long enough, the couple typically drops to a $250,000 ceiling.
There's one more guardrail people forget: the once every two years rule. You generally can't use the Section 121 exclusion on more than one sale within any two-year period. So if you flip primary residences quickly, you may have already "spent" your exclusion on the prior sale.
Cost Basis: The Single Most Important Number You Control
This is where a lot of money is won or lost, and it's the part most homeowners under-track. Your taxable gain isn't sale price minus purchase price. It's sale price minus your adjusted cost basis and minus your selling costs. The bigger your basis, the smaller your gain, the lower your tax. Raising your basis is completely legitimate, and it's mostly a matter of keeping receipts.
Your starting basis is generally what you paid for the home, including certain acquisition costs you took on at the closing table. From there you add the cost of capital improvements over the years. A capital improvement is something that adds value, prolongs the home's life, or adapts it to a new use, things like:
- A new roof, new HVAC system, or new windows
- A room addition, finished basement, or garage conversion
- A remodeled kitchen or bathroom
- A new deck, fence, driveway, or in-ground pool
- New plumbing, wiring, or a septic system
What does not raise basis is routine repair and maintenance, fixing a leak, repainting, swapping a broken appliance for a similar one. The line can blur, but the rule of thumb is: did it restore the home to its prior condition (repair) or meaningfully improve it (capital improvement)?
You also subtract selling expenses from your amount realized, real estate commissions, transfer taxes, title fees, and similar costs of the sale. Many of those overlap with the figures you saw when you bought; our closing costs guide breaks down which line items are which.
Here's the practical takeaway: that $40,000 kitchen remodel from 2019 and the $18,000 roof from 2022 don't just make your house nicer to live in, they directly lower the profit the IRS can tax. But only if you can prove them. Keep the invoices.
A Realistic Numbers Example
Let's run a married couple, filing jointly, who lived in their home the whole time.
| Item | Amount |
| Sale price | $880,000 |
| Selling costs (commission, fees) | -$55,000 |
| Amount realized | $825,000 |
| Original purchase price | $350,000 |
| Capital improvements over the years | +$95,000 |
| Adjusted cost basis | $445,000 |
| Taxable gain (before exclusion) | $380,000 |
| Section 121 exclusion (married) | -$500,000 |
| Gain subject to tax | $0 |
Their $380,000 gain sits comfortably under the $500,000 ceiling, so the whole thing is excluded. Notice how the $95,000 in improvements mattered: without those records their gain would have been $475,000, still under the limit here, but for a higher-priced home or a single filer with a $250,000 cap, that buffer is the difference between owing nothing and owing real money.
Now flip it: a single filer with a $600,000 gain after all adjustments. They exclude $250,000, leaving $350,000 that is taxable as a long-term capital gain. That's exactly the scenario where good records and timing earn their keep.
Short-Term vs. Long-Term: How the Taxable Portion Is Rated
If part of your gain does end up taxable, the rate depends on how long you owned the home.
- Short-term (owned one year or less): taxed as ordinary income, at your regular marginal rate.
- Long-term (owned more than one year): taxed at the preferential long-term capital gains rates, which are 0%, 15%, or 20% federally depending on your taxable income.
Because the Section 121 exclusion requires two years of use anyway, qualifying primary-home sales are almost always long-term, which means the gentler 0/15/20 rates. High-income sellers may also owe the 3.8% Net Investment Income Tax on the taxable portion, and your state may tax the gain too. State treatment varies a lot, so don't assume the federal answer is the whole story.
Partial Exclusion: When You Sell Early but Still Catch a Break
What if you have to sell before hitting the two-year mark? Life happens, and the IRS knows it. If your early sale is driven by certain unforeseen circumstances, you may qualify for a partial exclusion, a prorated slice of the full $250,000/$500,000 based on how long you actually owned and used the home.
The most common qualifying reasons include:
- A work-related move, generally a new job location far enough away to meet a distance threshold.
- Health reasons, a move recommended by a doctor for yourself or a family member.
- Unforeseeable events, things like divorce, the birth of multiples, job loss with unemployment benefits, or a natural disaster.
The math is roughly the fraction of the two-year requirement you completed. Live in the home 12 of the required 24 months and you might exclude half your limit. For a married couple that can still be up to $250,000 of tax-free gain, which is nothing to sneeze at. This is a spot where it really pays to document the reason for the move.
Investment and Rental Property Is a Different Animal
Everything above applies to your primary residence. If you're selling a rental, a vacation home, or a flip, the Section 121 exclusion generally does not apply, and the tax picture changes substantially. Two concepts come into play:
- Depreciation recapture. If you claimed depreciation deductions while renting the property, the IRS "recaptures" that benefit when you sell, taxing it at a special rate (up to 25% federally). Even if the property barely appreciated, recapture can create a bill.
- The 1031 exchange. Investors who reinvest proceeds into another qualifying investment property can defer the gain entirely. It's a powerful but rule-heavy strategy with strict deadlines. We cover the mechanics in our 1031 exchange guide.
If you've converted a former rental into your home, or vice versa, the rules get genuinely complicated, period-of-non-qualified-use allocations, partial recapture, the works. That's not a DIY situation. If you're financing the next investment property, our investment property mortgage guide covers what lenders look for, and ongoing carrying costs like property taxes factor into whether the deal pencils out at all.
Reporting the Sale: 1099-S, Schedule D, and Form 8949
Even when you owe nothing, paperwork can still show up. At closing, the settlement agent may file a Form 1099-S reporting the gross sale proceeds to the IRS. If you receive a 1099-S, you generally have to report the sale on your return even if the entire gain is excluded, otherwise the IRS sees the proceeds with no matching explanation and may send a letter.
When the sale is reportable, it flows through Form 8949 and Schedule D, which attach to your Form 1040. You can sometimes avoid a 1099-S by certifying at closing that your gain is fully excludable and under the limit, your settlement agent will know the form. Either way, keep a copy of your closing statement with your tax records.
Smart, Legal Ways to Lower the Bill
If some of your gain is taxable, or you're planning ahead for a future sale, these levers are worth knowing:
- Keep every improvement receipt, forever. This is the single highest-ROI habit. A shoebox (or a folder on your phone) of contractor invoices can raise your basis by six figures over a long ownership.
- Mind the two-year clock. If you're close to qualifying, the difference between selling at 23 months and 25 months can be the entire exclusion. Sometimes waiting a few weeks is worth tens of thousands.
- Time the sale to your income year. Long-term capital gains rates step up with income. Selling in a lower-income year, after retirement, between jobs, can drop you into the 0% or 15% bracket.
- Coordinate with other capital losses. Losses elsewhere in your portfolio can offset a taxable home gain.
- Don't forget the partial exclusion. If you're moving for work or health, document it; that paperwork can be worth a fortune.
While we're on the subject of records, the same habit helps you claim other breaks while you own the home, mortgage interest, certain points, and more, which we cover in our homeowner tax deductions guide. And if you're earlier in the journey and deciding when to buy, our best time to buy guide and the home affordability calculator can help you run the numbers before you commit. Already shopping for a loan? The mortgage calculator shows how rate and term shape your monthly payment.
Common Mistakes That Cost Real Money
- Assuming the exclusion covers the sale price. It covers the gain. Confusing the two leads to bad planning.
- Throwing away improvement receipts. No proof, no basis bump. The IRS can disallow undocumented additions.
- Forgetting depreciation recapture on a former rental. Even a home you later lived in can carry recapture for the rental years.
- Selling two homes inside two years and burning the once-every-two-years exclusion limit.
- Ignoring state tax. A zero federal bill doesn't always mean a zero state bill.
Frequently Asked Questions
Do I have to pay capital gains tax if I sell my primary home?
Usually not. If your gain is under $250,000 (single) or $500,000 (married filing jointly) and you pass the two-year ownership and use tests, the Section 121 exclusion wipes out the federal tax. Most homeowners fall under those limits and owe nothing.
Does the exclusion apply to the sale price or just the profit?
Just the profit (the gain). You calculate gain as your amount realized (sale price minus selling costs) minus your adjusted cost basis (purchase price plus improvements plus certain acquisition costs). Only that gain counts against the $250,000/$500,000 limit.
What counts as a capital improvement that raises my basis?
Permanent upgrades that add value or extend the home's life, new roof, HVAC, additions, remodeled kitchens or baths, new windows, an in-ground pool. Routine repairs and maintenance like repainting or fixing a leak do not raise basis. Keep receipts for everything in the first category.
Can I get any break if I sell before living there two years?
Possibly, through the partial exclusion. If your early sale is due to a qualifying reason such as a work relocation, a health issue, or another unforeseeable event like divorce or job loss, you can claim a prorated portion of the full exclusion based on the time you did own and use the home.
How are rental and investment properties taxed differently?
The Section 121 exclusion generally doesn't apply to investment property. You may owe regular capital gains tax plus depreciation recapture on any depreciation you claimed. Investors often defer the gain by reinvesting through a 1031 exchange instead. The rules are strict, so professional help is wise.
Do I have to report the sale if I owe no tax?
If you receive a Form 1099-S at closing, yes, you generally report the sale on Form 8949 and Schedule D with your 1040, even when the full gain is excluded. If no 1099-S is issued and your gain is fully excludable, reporting may not be required. When in doubt, report it and keep your closing statement.
Are the $250,000 and $500,000 limits going to change?
Those thresholds were set by statute and have not been indexed to inflation, so they've stayed the same for many years. Any change would require an act of Congress. Don't assume a future increase when planning; work with the current limits and confirm them with a tax professional before you sell.
The Bottom Line
For most homeowners, selling a primary residence is a tax non-event, the Section 121 exclusion does its job and you keep your whole profit. The people who get burned are usually the ones who didn't track improvements, sold a second home inside the two-year window, overlooked depreciation recapture on a former rental, or assumed the exclusion covered the sale price instead of the gain. Get your basis right, watch the calendar, document any early-sale hardship, and you'll keep more of what your home earned you.
And because every household's mix of income, state rules, and property history is different, run your specific numbers past a qualified CPA or enrolled agent before you sign. A short conversation can be worth thousands.