The basic calculation: sale price minus what you paid, minus selling costs
Capital gains tax on real estate starts with a single number: the profit you made. That profit is your sale price minus your adjusted cost basis (what you paid plus certain improvements) minus your selling expenses.
The IRS taxes only the gain, not the full sale price. If you bought a house for $300,000, sold it for $400,000, and paid $15,000 in realtor commissions and closing costs, your taxable gain is $85,000 — not $400,000.
The tax rate on that gain depends on how long you owned the property and your income level. Most people who sell a home they lived in may owe nothing at all, because of the primary residence exclusion. But if you own rental property, investment land, or a second home, you will owe tax on the gain unless you meet specific conditions.
Key Takeaways
- Your taxable gain equals the sale price minus your adjusted cost basis (purchase price plus improvements) minus selling costs like realtor fees and closing costs.
- If you lived in the home as your primary residence for at least two of the last five years, you can exclude up to $250,000 of gain if single or $500,000 if married filing jointly.
- Long-term capital gains (property owned more than one year) are taxed at 0%, 15%, or 20% depending on your total income; short-term gains are taxed as ordinary income.
- Improvements you made to the property increase your cost basis and lower your taxable gain, but routine maintenance and repairs do not.
- You report the gain on Schedule D (Form 1040) and may owe tax to both the federal government and your state.
Finding your adjusted cost basis: purchase price plus capital improvements
Your cost basis starts with what you paid for the property. Include the purchase price, closing costs paid at purchase (title insurance, appraisal fees, attorney fees, recording fees), and any points paid to get your mortgage. Do not include homeowners insurance, property taxes, or mortgage interest — those are deductible separately if you itemize.
Capital improvements add to your basis. These are permanent upgrades that add value or extend the life of the property: a new roof, a deck, a kitchen remodel, new windows, a furnace, or a septic system. Keep receipts and invoices for all improvements. The cost of the improvement itself counts, plus any labor you paid for.
Routine maintenance and repairs do not add to basis. Painting, fixing a leak, replacing a broken window, or patching drywall are repairs, not improvements. The line between the two can be fuzzy — if you replace one shingle, that is repair; if you replace the entire roof, that is improvement. When in doubt, keep the receipt and let your tax preparer decide.
If you inherited the property, your basis is its fair market value on the date of death, not what the previous owner paid. If you received it as a gift, your basis is generally the donor's basis (what they paid), unless the property declined in value at the time of the gift.
Subtracting selling expenses from your gain
Selling expenses reduce your taxable gain dollar for dollar. These are costs you paid to sell the property and would not have paid otherwise. Realtor commissions (typically 5–6% of sale price) are the largest one for most sellers. Other selling expenses include:
- Attorney fees for the sale
- Title insurance and title search
- Recording fees and transfer taxes
- Inspection fees paid by you as the seller
- Repairs made specifically to prepare the home for sale
- Advertising costs if you sold it yourself
Do not include property taxes, homeowners insurance, or mortgage interest — these are not selling expenses. Do not include improvements you made years before the sale, even if you made them to help sell the house. Those go into your basis instead.
Understanding the primary residence exclusion
If you owned and lived in the home as your primary residence for at least two of the five years before the sale, you can exclude part of your gain from tax. Single filers can exclude up to $250,000 of gain. Married couples filing jointly can exclude up to $500,000.
You can use this exclusion only once every two years. If you sold another home and used the exclusion within the past two years, you cannot use it again yet — with limited exceptions for job changes, health issues, or unforeseen circumstances.
The two-year ownership and use test is flexible. You do not have to live there continuously. If you owned it for two years total during the five-year window before the sale, you meet the test. If you rented it out for part of that time, you may still may have access to, though any gain from the rental period is not covered by the exclusion.
If you do not meet the two-year test — for example, you bought and sold within a year — you cannot use the exclusion. Your entire gain is taxable.
Long-term versus short-term capital gains rates
How long you owned the property determines which tax rate applies. If you owned it more than one year, it is a long-term capital gain. If you owned it one year or less, it is a short-term capital gain.
Short-term gains are taxed as ordinary income at your regular tax bracket rate, which can be as high as 37% at the federal level. Long-term gains are taxed at lower rates: 0%, 15%, or 20%, depending on your total taxable income for the year. The 0% rate applies to lower-income filers, 15% to middle-income filers, and 20% to high-income filers. The income thresholds change each year.
For real estate you own as an investment or rental property, the long-term rate almost always applies because you typically hold it longer than a year. For a home you lived in, the primary residence exclusion usually eliminates the tax entirely, so the rate does not matter.
Depreciation recapture on rental and investment property
If you rented out the property or used it for business, you may have deducted depreciation on your tax returns over the years. When you sell, the IRS requires you to "recapture" that depreciation — add it back as taxable gain — and tax it at 25% at the federal level.
Depreciation recapture applies only to the building itself, not the land. If you deducted $50,000 in depreciation and sold the property for a $100,000 gain, $50,000 of that gain is taxed at 25% (recapture), and the remaining $50,000 is taxed at the long-term capital gains rate (0%, 15%, or 20%).
This is one reason rental property owners sometimes use a 1031 exchange — a way to defer the entire tax by reinvesting the proceeds into another investment property. A 1031 exchange does not eliminate the tax; it postpones it until you eventually sell without reinvesting.
State and local taxes on capital gains
Federal capital gains tax is only part of the picture. Most states tax capital gains as income, and the rate varies widely. Some states have no income tax at all (Florida, Texas, Wyoming, and others). Some tax capital gains at the same rate as ordinary income. A few states have a separate, lower rate for long-term capital gains.
Your state tax bill depends on where you lived when you sold the property and, in some cases, where the property is located. If you sold a rental property in one state but live in another, you may owe tax to both. Check your state's tax authority website or speak with a tax preparer in your state to learn the rate that applies to you.
How to report capital gains on your tax return
You report the sale on Schedule D (Form 1040), which is part of your federal income tax return. Schedule D asks for the sale date, the property address, your cost basis, the sale price, and your gain or loss.
If you sold your primary residence and used the exclusion, you still file Schedule D — you just report the gain after the exclusion. For example, if your gain was $200,000 and you are single, you report $0 on Schedule D because the $250,000 exclusion covers it.
If you sold rental or investment property, you also file Form 4797 (Sales of Business Property) to report depreciation recapture and other business property sales. Your tax software or preparer will handle this if you provide the details.
State returns vary. Most states have a capital gains line on the income tax return. Some require a separate schedule. Your state tax authority publishes instructions for reporting capital gains in your state.
Frequently Asked Questions
Do I owe capital gains tax if I sell my primary home?
Not usually. If you lived in the home for at least two of the last five years, you can exclude up to $250,000 (single) or $500,000 (married filing jointly) of gain. You owe tax only on any gain above that amount. If your gain is less than the exclusion, you owe nothing.
What counts as a capital improvement versus a repair?
A capital improvement adds value or extends the life of the property — a new roof, deck, kitchen remodel, or furnace. A repair fixes something broken or maintains it — painting, patching drywall, or replacing one shingle. Improvements increase your cost basis; repairs do not. When in doubt, keep the receipt and ask your tax preparer.
How do I calculate my cost basis if I inherited the property?
Your basis is the fair market value of the property on the date the previous owner died, not what they paid for it. This is called a "step-up in basis." If the property increased in value after you inherited it, that gain is not taxed when you sell — only gains that occurred after the death are taxable.
Can I avoid capital gains tax by doing a 1031 exchange?
A 1031 exchange defers the tax, not eliminates it. You reinvest the sale proceeds into another investment property of equal or greater value within strict timelines. The tax is postponed until you eventually sell without reinvesting. You must follow IRS rules exactly, including using a may have access to intermediary and meeting 45-day and 180-day important date.
What is depreciation recapture and why does it matter?
If you rented out the property or used it for business, you deducted depreciation on your tax returns. When you sell, that depreciation is "recaptured" and taxed at 25% at the federal level, separate from the long-term capital gains rate. This applies only to the building, not the land.