How the calculation works
Capital gains tax is calculated on the profit you make when you sell an asset — not on the sale price itself. The math is straightforward: subtract what you paid for the asset from what you sold it for, and that difference is your gain. The tax is then applied to that gain at a rate that depends on how long you held the asset and your income level.
The reason the holding period matters is that the tax code treats long-term gains (assets held over one year) differently from short-term gains (assets held one year or less). 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 as high as 37%.
This distinction is why the same $10,000 profit can result in very different tax bills depending on whether you held the stock for 13 months or 11 months.
Key Takeaways
- Your capital gain is the sale price minus your original cost basis, and tax applies only to that gain, not the full sale price.
- Long-term gains (held over one year) are taxed at 0%, 15%, or 20% based on your total income; short-term gains are taxed as ordinary income at your regular bracket.
- Your cost basis includes the purchase price plus any improvements or reinvested dividends, not just what you initially paid.
- You calculate gains separately for each asset sold, then combine them on Schedule D of your tax return.
- Net losses in one year can offset gains in that year and carry forward to reduce gains in future years.
Finding your cost basis
Before you can calculate a gain, you need to know your cost basis — the amount you have invested in the asset. For most purchases, this is straightforward what you paid for it, including any fees or commissions. If you bought 100 shares of stock at $50 per share plus a $10 brokerage fee, your cost basis is $5,010, not $5,000.
Cost basis gets more complex when you have reinvested dividends, received stock as a gift, or inherited an asset. If a mutual fund automatically reinvested dividends back into the fund, each reinvestment increases your cost basis. If you inherited stock, your cost basis is typically the market value on the date of death, not what the original owner paid — this is called a "step-up" in basis and can significantly reduce your taxable gain.
Your brokerage statement should show your cost basis, especially for stocks and mutual funds purchased after 2011. For older holdings or assets purchased elsewhere, you may need to track down old statements or reconstruct the basis from purchase records.
The difference between long-term and short-term gains
The holding period is measured from the date you purchased the asset to the date you sold it. If you bought a stock on March 15 and sold it on March 16 of the following year, you held it for more than one year, and the gain is long-term. If you sold it on March 15 of the following year, it is short-term by one day.
Long-term capital gains rates are 0%, 15%, or 20%, depending on your taxable income and filing status. For 2024, the 0% rate applies to single filers with taxable income up to $47,025; the 15% rate applies to income between that threshold and $518,900; and the 20% rate applies to income above $518,900. These income thresholds change each year.
Short-term gains are taxed at your ordinary income tax rate, which ranges from 10% to 37% depending on your tax bracket. This means a short-term gain can be taxed at nearly double the rate of a long-term gain, even if the profit is identical.
Working through a concrete example
Suppose you bought 50 shares of Company X at $100 per share on January 10, 2023, paying a $25 brokerage fee. Your cost basis is $5,025. On February 15, 2024, you sold all 50 shares at $150 per share, receiving $7,500 minus a $25 fee, for net proceeds of $7,475.
Your gain is $7,475 minus $5,025 = $2,450. Because you held the shares for more than one year, this is a long-term gain. If your taxable income for 2024 puts you in the 15% long-term capital gains bracket, your tax on this gain is $2,450 × 0.15 = $367.50.
Now suppose instead you had sold those same shares on January 5, 2024 — just five days short of one year. The gain would still be $2,450, but it would be short-term. If your ordinary income tax bracket is 24%, your tax would be $2,450 × 0.24 = $588. By holding just five more days, you would have saved $220.50 in tax on the same profit.
Combining multiple sales and using losses
If you sell multiple assets in the same year, you calculate the gain or loss for each one separately, then combine them. All long-term gains are added together, all short-term gains are added together, and then the two groups are combined to find your net capital gain or loss for the year.
If your long-term gains exceed your long-term losses, the net is taxed at the long-term rate. If you have both long-term and short-term gains, the long-term gains are taxed at their preferential rate and the short-term gains at ordinary rates. The order in which you combine them matters for tax purposes, and the IRS has specific rules about which losses offset which gains.
If your total losses exceed your total gains in a year, you can deduct up to $3,000 of the net loss against your ordinary income. Any loss beyond $3,000 carries forward to future years, where it can offset future gains or be deducted in $3,000 increments against ordinary income again. This is why investors sometimes sell losing positions at year-end — to harvest losses that can reduce their tax bill.
Where the calculation appears on your tax return
You report all capital gains and losses on Schedule D (Form 1040), which is filed along with your main tax return. Schedule D has separate sections for long-term and short-term transactions. You list each sale — the date acquired, date sold, proceeds, cost basis, and gain or loss — and the form calculates your net long-term and net short-term totals.
The net long-term gain or loss flows to line 15 of Form 1040, and the net short-term gain or loss flows to line 7. If you have a net long-term gain, it is taxed at the preferential long-term rate. If you have a net short-term gain, it is added to your ordinary income and taxed at your bracket rate.
If you sold only one or two assets and have a small gain, you may be able to report it directly on Form 1040 without filing Schedule D, but most investors with multiple transactions need the full schedule. Your brokerage will send you a Form 1099-B summarizing your sales, which helps you fill out Schedule D accurately.
Frequently Asked Questions
Do I owe capital gains tax if I sell at a loss?
No tax is owed on a loss, but you can use the loss to reduce your tax bill. Losses offset gains first; if losses exceed gains, you can deduct up to $3,000 against ordinary income. Excess losses carry forward indefinitely to future years.
What if I inherited stock — do I owe capital gains tax on the increase in value before I inherited it?
No. Inherited assets receive a "step-up" in basis to their market value on the date of death. If the stock was worth $50 when you inherited it and you later sold it for $75, you owe tax only on the $25 gain, not on any increase that happened before you inherited it.
How do I know if my gain is long-term or short-term?
Count from the purchase date to the sale date. If more than one year has passed, it is long-term. The IRS counts the purchase date as day zero, so buying on January 1 and selling on January 2 of the next year is long-term. Selling on December 31 of the same year is short-term.
Can I choose which shares to sell if I own the same stock at different prices?
Yes, if you specify which shares you are selling at the time of sale. This is called "specific identification." You can tell your broker to sell your highest-cost shares first, which minimizes your gain. If you do not specify, the IRS assumes you sold shares in the order you bought them (FIFO method).
Are dividends taxed the same way as capital gains?
may have access to dividends are taxed at the same long-term capital gains rates (0%, 15%, or 20%), but non-may have access to dividends are taxed as ordinary income. Dividends are separate from capital gains and are reported on a different part of your return, though they use the same preferential rates if they may have access to.