Skip to content
S SmartTaxCalcs
Tutorials

"How to Calculate Capital Gains on Stock Sales"

By SmartTaxCalcs Editorial Team Published February 12, 2026 Updated February 12, 2026 6 min read
Table of contents

The same $12,000 stock gain cost one investor $2,640 in tax and another $1,800 — a $840 difference created by a single day on the calendar. The first sold at the 364-day mark; the second waited to day 366. Capital gains tax on a stock sale turns on three quantities and one date, and the date does more than the other three combined. This walkthrough computes each piece in order, with 2026 numbers, using the Capital Gains Tax Calculator. The strategy behind the holding-period line is in capital gains tax: short-term vs long-term.

The three quantities and one date

Every stock-sale tax calculation needs:

  1. Cost basis — what you paid, including commissions, plus reinvested dividends that were already taxed.
  2. Proceeds — what you sold for, net of selling costs.
  3. Holding period — the date that decides which rate schedule applies.

Gain is proceeds minus basis. The holding period decides whether that gain is taxed as ordinary income or at the preferential long-term rates. Get the basis wrong and you overpay (or underpay and invite a notice); get the holding period wrong and the rate can nearly double.

Step 1 — Cost basis

Basis is not just the share price you paid. It includes purchase commissions and, critically, reinvested dividends: every time a dividend was automatically used to buy more shares, that dividend was already taxed as income, and it added to your basis. Investors who forget reinvested dividends systematically overstate their gain and overpay. For partial sales, the lot-identification method (FIFO, specific identification) determines which shares' basis is used — specific identification can materially lower the gain by selling the highest-basis lots first.

Step 2 — Proceeds

Proceeds are the sale price minus selling commissions or fees. The figure on your broker's 1099-B is usually net already, but confirm whether basis is reported alongside it — for older or transferred lots, the broker may not have basis, and reconstructing it correctly is your responsibility.

Step 3 — Holding period (the one that matters)

Count from the day after purchase through the day of sale.

  • Held one year or lessshort-term → taxed as ordinary income at your marginal bracket rate.
  • Held more than one yearlong-term → taxed at the preferential 0% / 15% / 20% rates.

"More than one year" means one year and a day. Selling on the 365th day is short-term; the 366th is long-term. That one day is the highest-leverage decision in the entire calculation.

Step 4 — Apply the right rate

Short-term: the gain stacks on top of your other income and is taxed at your ordinary marginal rate — run it through the Federal Income Tax Calculator, because a large short-term gain can push part of itself into a higher bracket.

Long-term: the rate depends on total taxable income against the 2026 long-term breakpoints:

Filing status 0% up to 15% up to 20% above
Single $49,450 $545,000 $545,000
Married filing jointly $98,900 $613,700 $613,700
Head of household $66,200 $579,650 $579,650

A worked sale

You bought stock for $8,000 and sold for $20,000. Gain = $12,000. You are single with $90,000 of other taxable income in 2026.

If short-term: the $12,000 is ordinary income stacked on $90,000. At that income level it falls in the 22% federal band, so the tax is roughly $2,640.

If long-term: $90,000 taxable income is above the single 0% breakpoint ($49,450) and well below the 20% breakpoint ($545,000), so the rate is 15%: $12,000 × 15% = $1,800.

Same shares, same $12,000 gain, same investor — $840 saved by crossing from day 365 to day 366. The Capital Gains Tax Calculator runs both outcomes side by side so the holding-period decision is visible before you click sell.

The traps that produce a wrong number

  • Forgetting reinvested dividends in basis — the most common error; it inflates the gain and the tax.
  • Miscounting the holding period — off by one day flips the entire rate schedule.
  • Ignoring that a big short-term gain can climb brackets — it does not all tax at your starting rate; the top of it can spill into the next band.
  • Overlooking the 3.8% Net Investment Income Tax — at higher incomes it rides on top of the capital gains rate and the calculator's note flags it; it is not in the headline rate.
  • Netting losses incorrectly — capital losses offset capital gains and then up to $3,000 of ordinary income per year, with the rest carried forward. A loss elsewhere in the portfolio can erase the gain entirely.

A multi-lot example: where basis really bites

Single sales are easy; real portfolios are built from many purchases. Suppose you bought the same stock three times and now sell 100 of 300 shares for $9,000:

Lot Shares Cost basis Holding period
A 100 $2,000 3 years
B 100 $5,000 2 years
C 100 $7,000 5 months

Sell "100 shares" with no instruction and the default (usually FIFO) sells Lot A: basis $2,000, gain $7,000, all long-term. Use specific identification and sell Lot B instead: basis $5,000, gain $4,000, still long-term — $3,000 less taxable gain from the same trade. Sell Lot C and the gain is short-term, taxed at your ordinary rate. Same 100 shares, same $9,000 proceeds, three different tax outcomes decided entirely by which lot you tell the broker to sell. This is why lot selection, made before the sale settles, is one of the highest-leverage and most-ignored levers in investing — and why "what's my gain?" is unanswerable without specifying the lot.

Netting gains and losses in the right order

Capital gains and losses do not stand alone — they net in a specific sequence that changes the final number:

  1. Short-term gains net against short-term losses; long-term against long-term.
  2. A net loss in one category then offsets a net gain in the other.
  3. Any remaining net capital loss offsets up to $3,000 of ordinary income per year.
  4. Whatever is still left carries forward to future years indefinitely.

The practical consequence: a loss harvested elsewhere in the portfolio can erase the tax on the stock sale entirely, and a large short-term loss is especially valuable because it can neutralize a high-rate short-term gain before anything reaches ordinary income. Running the sale in isolation, without the rest of the year's transactions, is how people overpay — the Capital Gains Tax Calculator prices a single sale, but the return nets all of them, so a standalone result is a ceiling, not necessarily the final cost.

Common questions

Do I owe tax if I didn't sell? No. An unsold position with a paper gain is not taxed — only a realized sale triggers capital gains tax. This is the lever behind a lot of legitimate timing strategy in how to reduce taxable income legally.

What if I sold at a loss? No gain, so no gains tax. The loss offsets other capital gains and then up to $3,000 of ordinary income a year, with any excess carried to future years. The Capital Gains Tax Calculator reflects a non-positive gain.

Does my state tax the gain too? Usually yes, and most states tax capital gains as ordinary income with no preferential rate — a real cost the federal figure omits. See the state income tax guide for all 50 states.

How does a wash sale affect this? Selling at a loss and rebuying substantially identical stock within 30 days disallows the loss and rolls it into the replacement shares' basis. It changes basis, not the mechanics above.

Is qualified-dividend income the same? Qualified dividends use the same 0/15/20% rate schedule as long-term gains but are not a sale — they are not computed with this walkthrough, though they share the rate table.

The reliable habit is to know the holding period before selling, not after — that is the only point at which the single most valuable decision in the whole calculation is still yours to make. Compute basis carefully, count from the day after purchase, and let the Capital Gains Tax Calculator price both the short-term and long-term outcomes against your real income so the day-365-versus-366 choice is made with the number in front of you. The 2026 breakpoints here are projected inflation-adjusted figures reconciled to the official IRS release at year-end, and a CPA can confirm basis and wash-sale specifics on a real return.

Share this result:

Try the related calculators

Related guides

We value your privacy

We use necessary cookies to make the site work. With your consent we also use analytics and advertising cookies. See our Privacy Policy.