What capital gains tax means and how it applies to real estate sales
Capital gains tax is the tax you owe on the profit you make when you sell a property for more than you paid for it. The profit itself—not the sale price—is what gets taxed. If you bought a house for $300,000 and sold it for $400,000, your capital gain is $100,000, and that $100,000 is the amount the IRS taxes, not the full $400,000.
Real estate capital gains come in two forms: short-term (you owned the property for one year or less) and long-term (you owned it for more than one year). Long-term gains are taxed at lower rates—0%, 15%, or 20% depending on your income—while short-term gains are taxed as ordinary income at your regular tax bracket, which can be much higher. Most home sales may have access to as long-term because people typically own homes for years.
The calculation itself is straightforward: sale price minus your cost basis equals your gain. The tricky part is figuring out what counts as your cost basis, because it includes more than just what you paid for the house.
Key Takeaways
- Your capital gain is the sale price minus your cost basis (the original purchase price plus certain improvements and costs).
- Long-term capital gains on real estate are taxed at 0%, 15%, or 20% depending on your total income, while short-term gains are taxed as ordinary income.
- You can exclude up to $250,000 of gain ($500,000 if married filing jointly) if you lived in the home as your primary residence for at least two of the last five years.
- Cost basis includes the purchase price, closing costs, and capital improvements like a new roof or addition—but not repairs or maintenance.
- You report capital gains on Schedule D (Form 1040) and may owe estimated taxes before you sell if the gain will be large.
Understanding cost basis: what counts toward your starting point
Your cost basis is what you paid for the property plus certain expenses. It starts with the purchase price, but it also includes closing costs you paid at purchase: loan origination fees, title insurance, recording fees, and attorney fees. These are part of what you invested in the property, so they reduce your taxable gain.
Capital improvements also add to your basis. These are permanent upgrades that add value or extend the life of the property: a new roof, a deck, a finished basement, a new HVAC system, or an addition. Keep receipts and invoices for all of these. Repairs and maintenance do not count—fixing a leaky faucet, repainting walls, or replacing broken windows are not capital improvements, even though you paid for them.
If you inherited the property, your basis is typically the fair market value on the date of death, not what the previous owner paid. If you received the property as a gift, your basis is usually what the giver paid, unless the property had declined in value at the time of the gift. These rules matter because they can dramatically change your taxable gain.
The primary residence exclusion: how to avoid tax on most home sales
If you lived in the home as your primary residence for at least two of the last five years before the sale, you can exclude up to $250,000 of your gain from taxation ($500,000 if you are married filing jointly). This is the Section 121 exclusion, and it is one of the largest tax breaks available to homeowners.
The two-year requirement does not have to be consecutive. If you lived in the house for one year, moved out, and then moved back in for another year within the five-year window, you may have access to. You can use this exclusion once every two years, so if you sell a home, you cannot use it again on another property for two years.
This exclusion is why most people who sell a primary residence owe little or no capital gains tax, even if the home appreciated significantly. If your gain is less than $250,000 (or $500,000 if married), you may owe nothing. If your gain exceeds those amounts, you only pay tax on the excess.
Calculating long-term versus short-term gains and their tax rates
The holding period determines which tax rate applies. If you owned the property for more than one year, it is a long-term gain. If you owned it for one year or less, it is a short-term gain.
Short-term gains are taxed as ordinary income at your marginal tax rate—the same rate you pay on wages or salary. This can be 10%, 12%, 22%, 24%, 32%, 35%, or 37% depending on your total income and filing status. Long-term gains are taxed at preferential rates: 0%, 15%, or 20%. The 0% rate applies to lower-income taxpayers, 15% to most middle-income taxpayers, and 20% to high-income taxpayers. These brackets change annually.
For example, if you are single and your long-term capital gains fall within the 15% bracket (roughly $47,000 to $518,000 in 2024, though this varies yearly), you pay 15% tax on those gains. If you held the property for less than a year and your short-term gain is $50,000, you pay your ordinary income tax rate on that $50,000, which could be 22% or higher.
Step-by-step calculation with a real example
Here is how to work through the numbers. Suppose you bought a house in 2015 for $250,000. You paid $5,000 in closing costs (title insurance, recording fees, attorney fees). In 2020, you spent $30,000 on a new roof and $15,000 finishing the basement. You sold the house in 2024 for $450,000 and paid $18,000 in selling costs (real estate commission, closing costs on the sale).
Step 1: Calculate your cost basis. Purchase price ($250,000) + closing costs at purchase ($5,000) + capital improvements ($30,000 + $15,000) = $300,000.
Step 2: Calculate your amount realized. Sale price ($450,000) − selling costs ($18,000) = $432,000.
Step 3: Calculate your gain. Amount realized ($432,000) − cost basis ($300,000) = $132,000 gain.
Step 4: explore the primary residence exclusion. If this was your primary residence for two of the last five years, you exclude $250,000 (or $500,000 if married). Since your gain is $132,000, which is less than $250,000, your taxable gain is $0. You owe no federal capital gains tax.
If you had sold for $600,000 instead, your gain would be $300,000. After the $250,000 exclusion, your taxable gain would be $50,000. At the 15% long-term rate, you would owe $7,500 in federal capital gains tax.
Reporting capital gains on your tax return
You report capital gains on Schedule D (Form 1040), which is part of your federal income tax return. Schedule D asks for the date you bought the property, the date you sold it, your basis, your sale price, and your gain or loss. The IRS uses this to verify that you held the property long enough to may have access to for long-term rates and to check that you applied the primary residence exclusion correctly.
If your gain is large, you may owe estimated taxes before you close the sale. Estimated taxes are quarterly payments you make to the IRS when you expect to owe more than a certain amount (usually $1,000) that will not be covered by withholding. Your tax professional or the IRS website can help you calculate whether you need to make estimated payments.
Some states also tax capital gains on real estate. The rate and rules vary by state. A few states (like Washington and California) have their own capital gains taxes on top of federal tax. Others tax capital gains as ordinary income. Check your state's tax authority website or speak with a tax professional about your state's rules.
When to work with a tax professional
If the property was not your primary residence, if you owned it for a very short time, if you made substantial improvements and need to document them, or if your gain is large, a tax professional can help you calculate correctly and find deductions or strategies you might miss. Real estate transactions can be complex, especially if you are selling an investment property, a rental, or a property you inherited.
A CPA or tax attorney can also advise you on timing—whether selling this year or next year would result in a lower tax bill, or whether you should make estimated tax payments before closing. They can review your closing documents to make sure all deductible costs are captured in your basis.
Frequently Asked Questions
Do I owe capital gains tax if I sell my primary home at a loss?
No. Capital losses on personal residences cannot be deducted. If you sell for less than your basis, you straightforward report the loss on Schedule D, but it does not reduce your other income or taxes. The loss is not usable.
What if I owned the house with someone else?
If you are married and file jointly, you can exclude up to $500,000 of gain. If you are unmarried co-owners, each of you can exclude up to $250,000 if you each lived in the home for two of the last five years. The rules depend on how the deed is titled and your relationship, so check with a tax professional.
Can I deduct the cost of selling, like the real estate agent commission?
Yes. Selling costs reduce your amount realized, which lowers your gain. These include real estate commissions, title insurance on the sale, recording fees, and attorney fees paid at closing. Keep all closing documents.
What if I rented out part of my home?
If you rented out part of the home, you may not may have access to for the full primary residence exclusion. The exclusion applies only to the portion you used as your primary residence. You would owe capital gains tax on the gain attributable to the rental portion. This is complex—consult a tax professional.
Do I have to report the sale if my gain is under the exclusion amount?
You should still file Schedule D to document the sale and show that you are claiming the primary residence exclusion. Even though you owe no tax, reporting it protects you if the IRS questions the transaction later.