How capital gains tax works on stocks in the US

TrackMyShares Team

Every time you sell a stock for more than you paid, the IRS wants its share. Capital gains tax is the tax on that profit, and it affects when you sell, how long you hold, and how much you actually keep.

Selling stocks triggers capital gains or losses

When you sell a stock, you either make a profit (capital gain) or take a loss (capital loss). The amount depends on the difference between your cost basis (what you paid) and what you received.

Buy at $50, sell at $65, that is a $15 per share gain. Sell at $40 instead, that is a $10 per share loss.

Capital gains are only "realized" when you sell. If your stock is up but you have not sold, that is an unrealized gain and not taxable. You control the timing, which means you can manage your tax bill by choosing when to sell.

Short-term vs long-term capital gains

The holding period is the single biggest factor in your tax rate.

Short-term gains apply when you held the stock for one year or less. These are taxed at your ordinary income rate, the same brackets as your salary. If you are in the 32% bracket, your short-term gains are taxed at 32%.

Long-term gains apply when you held the stock for more than one year. These get preferential rates that are substantially lower for most people.

The holding period counts from the day after purchase to the day of sale. If you bought on January 15, 2025, you need to hold until at least January 16, 2026 for long-term treatment. If you are sitting on a gain and close to the one-year mark, waiting a few extra days could save you real money.

2026 tax rates for capital gains

Short-term capital gains rates

Short-term gains are taxed as ordinary income. For the 2026 tax year:

Tax rateSingle filersMarried filing jointly
10%Up to $12,400Up to $24,800
12%$12,401 - $50,400$24,801 - $100,800
22%$50,401 - $105,700$100,801 - $211,400
24%$105,701 - $201,775$211,401 - $403,550
32%$201,776 - $256,225$403,551 - $512,450
35%$256,226 - $640,600$512,451 - $768,700
37%Over $640,600Over $768,700

Long-term capital gains rates

For the 2026 tax year, long-term gains are taxed at preferential rates:

Tax rateSingle filersMarried filing jointly
0%Up to $49,450Up to $98,900
15%$49,451 - $545,500$98,901 - $613,700
20%Over $545,500Over $613,700

The gap is dramatic. A single filer earning $150,000 pays 24% on short-term gains but only 15% on long-term gains. On a $10,000 gain, that is $2,400 vs $1,500, a $900 difference just from holding longer than a year.

Net investment income tax (NIIT)

Higher earners may also owe an additional 3.8% on investment income. The NIIT applies when your modified adjusted gross income (MAGI) exceeds:

  • Single filers: $200,000
  • Married filing jointly: $250,000
  • Married filing separately: $125,000

This 3.8% is layered on top of regular capital gains rates. A single filer with $220,000 MAGI and $30,000 in long-term gains would owe the NIIT on $20,000 (the excess over $200,000), adding $760 to their tax bill.

Calculating your capital gain or loss

The formula is simple:

Capital Gain (or Loss) = Sale Price - Cost Basis

Your cost basis is what you paid (including commissions). Your sale price is what you received (minus selling fees).

Example: You buy 200 shares at $50 ($10,000) plus a $10 commission ($10,010 total basis). You sell at $65 ($13,000) minus a $10 commission ($12,990 proceeds). Your gain is $12,990 - $10,010 = $2,980.

If held over a year, that is a long-term gain taxed at 0%, 15%, or 20%. Under a year, it is taxed at your ordinary income rate.

Cost basis methods

When you have bought the same stock multiple times at different prices, you need a method to determine which shares you are selling. The method directly affects the size of your gain or loss.

FIFO (First In, First Out) is the default at most brokers. It sells your oldest shares first, which often produces the largest gains when a stock has risen over time. Specific identification lets you choose exactly which lots to sell, giving you the most control over tax outcomes.

For worked examples comparing FIFO, LIFO, and specific identification, see our guide on cost basis methods for stocks.

Wash sale rule

The wash sale rule prevents you from claiming a tax loss if you repurchase the same (or "substantially identical") security within 30 days before or after the sale. The disallowed loss gets added to the cost basis of the replacement shares, so it is deferred, not lost permanently.

This matters a lot for tax-loss harvesting strategies. For details, examples, and common pitfalls, see our guide on the wash sale rule explained.

The $3,000 loss deduction and carryforward

Capital losses offset gains dollar for dollar, and the IRS applies a specific ordering:

  1. Short-term losses offset short-term gains first, then any excess offsets long-term gains.
  2. Long-term losses offset long-term gains first, then any excess offsets short-term gains.
  3. Up to $3,000 of net losses can offset ordinary income ($1,500 if married filing separately).
  4. Unused losses carry forward indefinitely and can offset future gains or the $3,000 deduction each year.

Reporting on your tax return

Your broker sends you Form 1099-B by mid-February, reporting each sale with proceeds, cost basis, and holding period classification. You use that to complete Form 8949 (listing each sale) and Schedule D (summarizing your total gains and losses).

For a step-by-step walkthrough, see our guide on how to report stock sales on your taxes.

How TrackMyShares helps

Tracking gains across multiple purchases, holding periods, and cost basis methods gets complicated fast. TrackMyShares handles it automatically.

Every sale is classified as short-term or long-term based on holding period. Each purchase is tracked as a separate tax lot with its own date, quantity, and price. The capital gains tax report generates a full summary for any calendar year, broken down by holding, with proceeds, cost basis, gain or loss, and holding period classification.

The built-in tax-loss harvesting tool scans your portfolio for unrealized losses that could offset realized gains, estimates potential savings, and flags wash sale concerns. Prices are updated throughout the day, so your figures stay current.

Sign up for TrackMyShares to track your capital gains, generate tax reports, and stay on top of your tax obligations as you file for the 2025 tax year (due April 15, 2026).

This is general information, not personal tax or financial advice.