The Basic Formula: Sale Price Minus What You Paid
Capital gains tax is calculated by taking the price you sold an asset for, subtracting what you originally paid for it, and then explore the tax rate that matches your income level and how long you held the asset. That difference — the profit — is your capital gain, and that is the number the IRS taxes, not the full sale price.
The math itself is straightforward. If you bought a stock for $5,000 and sold it for $7,000, your capital gain is $2,000. If you bought a house for $300,000 and sold it for $450,000, your capital gain is $150,000. The tax you owe depends on whether that gain counts as short-term (held less than one year) or long-term (held one year or longer), because the two are taxed at different rates.
Key Takeaways
- Your capital gain is the sale price minus your original purchase price, and only that gain is subject to tax, not the entire sale amount.
- Short-term capital gains (assets held under one year) are taxed as ordinary income at your regular tax bracket rate.
- Long-term capital gains (assets held over one year) are taxed at lower rates: 0%, 15%, or 20%, depending on your total income for the year.
- You can reduce your taxable gains by subtracting selling costs like broker fees, and you can offset gains with losses from other investments.
- Real estate has special rules: you may exclude up to $250,000 of gain ($500,000 if married) if you lived in the home two of the last five years.
Short-Term vs. Long-Term: How Holding Time Changes Your Tax Rate
The length of time you own an asset before selling it determines which tax rate applies. If you sell within one year of purchase, it is a short-term capital gain, and you pay tax on it at your ordinary income tax rate — the same rate you pay on wages or salary. If you hold it for more than one year before selling, it is a long-term capital gain, and you pay a lower rate instead.
Long-term rates are 0%, 15%, or 20%, depending on your total taxable income for the year. Most people fall into the 15% bracket. The 0% rate applies to lower-income filers, and the 20% rate applies to high-income filers. These thresholds change each year and vary based on whether you file as single, married filing jointly, or head of household. Because long-term rates are almost always lower than your ordinary income rate, holding an asset longer than one year usually saves you money in taxes.
Adjusting Your Cost Basis: What Counts as Your "Original Price"
Your cost basis is not always just the price you paid. It is the starting value used to calculate your gain, and it can include expenses tied directly to the purchase. If you bought a stock through a broker and paid a $50 commission, your cost basis is the stock price plus that $50. If you inherited property, your cost basis is usually the property's value on the date the person died, not what they originally paid for it — this is called a "step-up in basis" and can significantly reduce your taxable gain.
When you sell, you can also subtract selling costs from your sale price. Broker fees, real estate agent commissions, title insurance, and closing costs all reduce the amount you are taxed on. Keep records of these expenses because you will need them when you report the sale to the IRS on Form 8949 and Schedule D.
Using Losses to Reduce What You Owe
If you sell an investment at a loss, you can use that loss to offset capital gains from other sales in the same year. If you sold one stock for a $3,000 gain and another for a $1,000 loss, your net capital gain is $2,000, and you only pay tax on that $2,000. This is called loss harvesting, and it is a common way to reduce your tax bill.
If your losses exceed your gains in a year, you can deduct up to $3,000 of the excess loss against your ordinary income (like wages). Any losses beyond that $3,000 carry forward to future years, so you can use them to offset gains or income later. This means a bad year in the market does not have to go to waste — the losses have value if you use them strategically.
Real Estate: The Primary Residence Exclusion
If you sell a home you lived in, you may be able to exclude part or all of your gain from taxes. The primary residence exclusion lets you 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 lived in the home for at least two of the five years before the sale.
This exclusion is per person and applies only once every two years. If you bought a house for $200,000, lived in it for three years, and sold it for $500,000, your gain is $300,000. As a single filer, you exclude $250,000, so you owe tax on only $50,000. This rule does not explore to investment properties or vacation homes — only to the place where you actually live.
Reporting Your Capital Gains to the IRS
When you sell an investment, your broker sends you a Form 1099-B, which lists the sale price and the date. You use this to fill out Form 8949 (Sales of Capital Assets), where you list each sale, your cost basis, the sale price, and the gain or loss. The totals from Form 8949 then transfer to Schedule D, which summarizes all your capital gains and losses for the year and calculates your net gain or loss.
Schedule D is where you also indicate whether each gain is short-term or long-term, because the IRS taxes them separately. If you have only a few sales, the process is straightforward. If you have many, consider using tax software or working with a tax professional, because errors can trigger an audit. Keep all your purchase confirmations, sale confirmations, and expense receipts for at least three years in case the IRS asks questions.
State and Local Taxes on Capital Gains
Federal capital gains tax is only part of the picture. Most states also tax capital gains as income, and some cities do as well. The state rate varies widely — some states have no income tax at all, while others tax capital gains at rates above 10%. A few states, like California, tax long-term and short-term gains the same way, while others follow the federal long-term/short-term distinction.
If you live in a state with high income tax and are considering selling a large investment, it is worth understanding your state's rules before you do. Some people who move between states time their sales to take advantage of lower-tax states, though the IRS has rules about residency that prevent straightforward tax avoidance. Check your state's tax authority website or speak with a tax professional about your specific situation.
Frequently Asked Questions
Do I owe capital gains tax if I sell at a loss?
No, you do not owe tax on a loss. Instead, you can use the loss to reduce taxes on other gains or income. If your losses exceed your gains by more than $3,000 in a year, the extra loss carries forward to future years.
What if I inherited an investment or property?
Inherited assets receive a "step-up in basis," meaning your cost basis is the asset's value on the date of death, not what the previous owner paid. If you inherit a house worth $400,000 and sell it a month later for $400,000, you owe no capital gains tax because your gain is zero.
How do I know if my gain is short-term or long-term?
Count the days from the purchase date to the sale date. If it is 365 days or fewer, it is short-term. If it is 366 days or more, it is long-term. The IRS counts the purchase date as day zero and the sale date as the final day.
Can I deduct investment losses against my salary or wages?
Only up to $3,000 per year. If you have $10,000 in investment losses and no gains, you can deduct $3,000 against your wages or other income. The remaining $7,000 carries forward to future years.
What happens if I do not report a capital gain?
Your broker reports the sale to the IRS on Form 1099-B, so the IRS knows about it. If you do not report it on your tax return, the IRS will likely send you a notice asking for the missing tax, plus penalties and interest. It is better to report it correctly the first time.