The basic calculation: sale price minus what you paid, minus selling costs
Capital gains tax is calculated on the profit you make when you sell property. The profit is the difference between what you received and what you actually spent to buy and sell it. The IRS taxes only the gain, not the full sale price.
The formula is straightforward: take your sale price, subtract your original purchase price (called your basis), subtract the costs of selling, and what remains is your taxable gain. If you spent $200,000 to buy a house, paid $15,000 in real estate commissions and closing costs to sell it, and sold it for $300,000, your taxable gain is $85,000 ($300,000 − $200,000 − $15,000).
The tax you owe on that gain depends on how long you owned the property and your income level. Property you own for more than one year gets taxed at long-term capital gains rates, which are lower than ordinary income tax rates. Property you own for one year or less gets taxed as short-term capital gains, at your regular income tax rate.
Key Takeaways
- Your taxable gain equals the sale price minus your purchase price, minus all costs of buying and selling the property.
- Long-term capital gains (property owned over one year) are taxed at 0%, 15%, or 20% depending on your income; short-term gains are taxed as ordinary income.
- You can reduce your gain by including all legitimate purchase and selling expenses, including repairs made before sale and real estate commissions.
- Primary residence sales may exclude up to $250,000 (single) or $500,000 (married filing jointly) of gain from taxation if you meet ownership and use tests.
- You report capital gains on Schedule D (Form 1040) and pay tax when you file your return for the year of the sale.
What counts as your basis (the amount you paid)
Your basis is not just the purchase price. It includes the price you paid plus certain costs directly connected to buying the property. These costs become part of what you subtract from your sale price.
Basis includes the purchase price, real estate commissions you paid to buy the property, title insurance, legal fees for the purchase, property surveys, and recording fees. If you paid points on a mortgage to buy the property, those count too. If the seller paid part of your closing costs as a credit, you subtract that from your basis.
Basis also includes the cost of permanent improvements you made to the property — additions, new roof, new foundation, built-in appliances, or a new HVAC system. These are capital improvements, meaning they add value or extend the life of the property. Repairs and maintenance do not count: painting, fixing a leak, or replacing a broken window are not added to basis because they restore the property to its original condition rather than improve it.
If you inherited the property, your basis is usually 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 generally what the giver paid, unless the property declined in value between purchase and gift.
Selling costs you can subtract
When you calculate your gain, you subtract not only what you paid to buy but also what you paid to sell. These are called selling expenses or selling costs, and they reduce your taxable gain dollar for dollar.
Selling costs include real estate agent commissions (typically 5% to 6% of the sale price), title insurance for the buyer, legal fees paid to close the sale, recording fees, transfer taxes, and homeowner association transfer fees. If you paid for a home inspection, appraisal, or survey that the buyer required, those are selling costs. If you made repairs specifically to prepare the house for sale — new paint, carpet, or landscaping done to make it marketable — those can be deducted as selling costs.
Do not include costs you would have paid anyway, such as property taxes or mortgage interest. Those are not selling costs; they are ownership costs. If you paid to stage the home for sale or held an open house, those are selling costs. If you paid to fix a roof leak that was already there, that is a repair, not a selling cost — but if you replaced the entire roof to make the house saleable, it may count.
Long-term versus short-term capital gains rates
The tax rate on your gain depends on how long you owned the property. If you owned it for more than one year before selling, it is a long-term capital gain. If you owned it for one year or less, it is a short-term capital gain.
Long-term capital gains are taxed at preferential rates: 0%, 15%, or 20%, depending on your total taxable income for the year. Short-term capital gains are taxed at your ordinary income tax rate, which can be as high as 37% for high earners. This is a significant difference. A $50,000 gain taxed as short-term might cost you $18,500 in federal tax; the same gain taxed as long-term might cost you $7,500.
The IRS counts ownership time from the date you acquired the property to the date you sold it. If you bought on June 15, 2022, and sold on June 16, 2023, you owned it for more than one year and may have access to for long-term rates. If you sold on June 14, 2023, you owned it for less than one year and pay short-term rates.
The primary residence exclusion
If you sold your main home, you may be able to exclude part or all of your gain from taxation. This is called the Section 121 exclusion, and it is one of the largest tax breaks available to homeowners.
You can exclude up to $250,000 of gain if you are single, or up to $500,000 if you are married filing jointly. To may have access to, you must have owned the home for at least two of the five years before the sale, and you must have lived in it as your main home for at least two of those five years. The two years do not have to be consecutive, and they do not have to be the most recent two years.
If you sold a home for $400,000 and your gain is $150,000, you owe no federal capital gains tax because $150,000 is less than the $250,000 exclusion. If your gain is $300,000, you exclude $250,000 and pay tax only on the remaining $50,000.
You can use this exclusion only once every two years. If you sold a home in 2022 and used the exclusion, you cannot use it again until 2024. Some situations disqualify you: if you used the exclusion on a different home within the past two years, or if you are a nonresident alien, or if you are married filing separately, you cannot use it.
State and local taxes on capital gains
Federal capital gains tax is only part of what you owe. Most states tax capital gains as ordinary income, and some cities do as well. State tax rates vary widely, from zero in states like Texas and Florida to over 13% in states like California and New York.
A few states tax capital gains at a different rate than ordinary income. Washington State, for example, taxes long-term capital gains on certain assets at a flat 7%. Illinois taxes capital gains at a lower rate than ordinary income. Most states, however, treat capital gains the same as wages and salary.
If you sold property in a state where you do not live, you may owe tax to both your home state and the state where the property is located. Some states offer credits to prevent double taxation, but the rules are complex and vary by state. A tax professional in your state can tell you what you owe.
How to report 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 has two sections: one for long-term gains and one for short-term gains. You list each property sale separately, showing the date acquired, date sold, sale price, basis, and gain or loss.
If you have only one property sale and it is a long-term gain, you may be able to use the simpler Form 8949 (Sales of Capital Assets) instead, depending on your situation. Your tax software or tax preparer will guide you to the right form.
You do not pay tax when you file Schedule D. Instead, the gain is added to your other income, and your total tax is calculated based on your total taxable income for the year. You pay the tax when you file your return or make estimated tax payments during the year if the gain is large.
Keep records of the purchase price, purchase date, sale price, sale date, and all costs of buying and selling for at least three years after you file your return. The IRS can audit your return up to three years later (or longer if there are issues), and you will need to prove your basis and selling costs.
Frequently Asked Questions
Do I have to pay capital gains tax if I reinvest the money in another property?
Yes. There is no tax break for reinvesting the proceeds. The only exception is the primary residence exclusion, which applies if you sold your main home and meet the ownership and use tests — it does not matter what you do with the money. If you sold an investment property and bought another one, you still owe capital gains tax on the first sale.
What if I sold the property at a loss?
If your sale price minus your basis and selling costs is negative, you have a capital loss. You can use capital losses to offset capital gains in the same year. If your losses exceed your gains, you can deduct up to $3,000 of the excess loss against ordinary income. Any remaining loss carries forward to future years.
How do I know if an expense is a capital improvement or a repair?
Capital improvements add value, prolong the life of the property, or adapt it to a new use. Repairs restore it to its original condition. A new roof is a capital improvement; fixing a leak is a repair. A room addition is a capital improvement; repainting is a repair. When in doubt, ask a tax professional, because the distinction affects your basis and your tax bill.
Can I deduct the cost of a real estate agent if I bought the property?
Yes. The commission you paid to buy the property is part of your basis and reduces your taxable gain when you sell. The commission you pay to sell is a selling cost and also reduces your gain. Both are deducted from the sale price to calculate what you owe tax on.
What if I owned the property before January 1, 2018?
The calculation is the same. Your basis is what you paid plus improvements, regardless of when you bought. Long-term capital gains rates apply if you owned it for more than one year. The only difference is that very old records may be harder to find, so gather documentation now if you are planning to sell.