Cost Basis Calculator

See the capital gain, the long-term tax, and the net cash from selling part of a position, plus the basis you still hold.

What you originally paid per share.
Your taxable income before this gain, which sets the capital gains rate.
Capital gain $15,000.00
Estimated tax $2,250.00
Net proceeds after tax $24,750.00
Total proceeds $27,000.00
Effective tax rate on gain 15%
Shares still held 700

How it's calculated

When you sell only part of a position, the tax turns on your cost basis, which is what you paid for the shares. Sell some shares and your gain is the sale proceeds minus the basis on just those shares. Using your average cost per share keeps it simple. Multiply the shares sold by your basis to get the basis sold, subtract that from the proceeds, and the difference is the taxable gain.

Take the default. You own 1,000 shares bought at $40 each, and you sell 300 at $90. The proceeds are $27,000, and the basis on those 300 shares is $12,000, so the capital gain is $15,000. With $60,000 of other taxable income, that long-term gain falls in the 15 percent bracket, so the tax is $2,250 and you keep $24,750 after tax. You still hold 700 shares with $28,000 of cost basis, which sets the gain on any future sale.

Two things drive the tax. Whether the gain is long-term, meaning held more than a year, which earns the lower 0, 15, or 20 percent rates instead of your ordinary rate, and how much other income you have, since the gain stacks on top of it. A lower income can push part of the gain into the 0 percent bracket, while a high income can add the 3.8 percent NIIT. Track the basis on what you keep, because it decides your next tax bill.

Assumptions

Last updated: 2026-08-08 · Tax year 2026

These assumptions follow our general methodology.

Frequently asked questions

How do I calculate cost basis on a partial sale?

With the average-cost method, multiply the number of shares you sell by your average cost per share. That is the basis on the shares sold. Subtract it from the sale proceeds to get your capital gain. The shares you keep retain the same per-share basis for next time.

What tax rate applies to my gain?

If you held the shares more than a year, the gain is long-term and taxed at 0, 15, or 20 percent depending on your total income, often far below your ordinary rate. Held a year or less, it is short-term and taxed as ordinary income. This calculator uses the long-term rates.

Can I choose which shares to sell?

Yes, if your broker supports specific-lot identification. Selling the highest-cost lots first shrinks the gain and the tax, a tactic called tax-loss or tax-lot harvesting. This calculator uses your average cost, which is simpler and is the default at many brokers for mutual funds.

What is the basis of the shares I keep?

With average cost, each remaining share keeps the same per-share basis, so 700 shares bought at $40 still carry $28,000 of basis. That figure sets the gain when you eventually sell them, so it is worth tracking as you trim a position over time.

Related calculators

Capital Gains Tax Calculator (2026) Calculate the tax on a long-term capital gain in 2026, with the gain stacked on your income across the 0, 15, and 20 percent rates. Dividend Reinvestment Calculator See how reinvesting dividends compounds into more shares over time, and how much more it builds than taking the dividends as cash. Net Worth Calculator Add up what you own and subtract what you owe to see your net worth, the clearest single number for your financial health.