Your cost basis is what you actually paid for an investment, fees included — and it decides how much of your sale counts as a gain. This cost basis calculator works it out from your purchase price, share count, and commissions. Say you bought 450 shares at $87.40 each and paid $45 in commissions. The shares alone cost $39,330, so your total cost basis is $39,375 — or $87.50 per share. That $87.50, not the $87.40 you see on your trade confirmation, is the number your gain or loss is measured against when you sell. Use it before you sell, at tax time, or whenever you want to know if a position is really ahead.
What Is Cost Basis?
Cost basis is what you paid to buy an investment: the share price plus any commissions and fees. Pay $39,330 for shares and $45 in commissions and your basis is $39,375 — $87.50 per share. When you sell, your gain or loss is the sale proceeds minus that basis, not minus the share price alone.
Basis matters most at tax time, because tax is charged on the gain, not on the full sale amount. Sell above your basis and you have a gain; sell below it and you have a loss to use against other gains. The IRS explains the rules in Topic No. 703, Basis of Assets.
You need your basis when you sell, transfer, or inherit shares — not while simply holding.
How to Use This Cost Basis Calculator
- Enter the Number of shares bought — it must be greater than zero.
- Enter the Purchase price / share you actually paid.
- Enter any Purchase commissions & fees; leave it blank if there were none.
- To see the gain or loss too, enter the optional Sale price / share and Sale commissions & fees.
- Click Calculate Cost Basis for your total and per-share basis, principal invested, and purchase fees — plus estimated gain or loss, net proceeds, and the gain percentage if you entered a sale price.
- Click Reset to start over.
The calculator handles one purchase at a time — one lot, one price, one set of fees. Bought the same stock more than once? Run each lot separately and add the totals.
How the Calculation Works
Total cost basis = (shares × purchase price) + purchase commissions and fees. Cost basis per share = total cost basis ÷ shares. With a sale, net proceeds = (shares × sale price) − sale commissions and fees, and gain or loss = net proceeds − total cost basis. The percentage is the gain or loss divided by the total basis.
Take the headline case: 450 shares at $87.40 is 450 × $87.40 = $39,330 of principal. Add the $45 commission and the total cost basis is $39,375, or $87.50 per share.
Sell all 450 shares at $95.00 and pay another $45 in sale commission: gross proceeds are 450 × $95.00 = $42,750, net proceeds $42,705. Subtract the $39,375 basis and the gain is $3,330, or 8.46% — not $3,375, because the sale commission comes off first.
This tool holds no built-in rates, limits, or year-based figures, so nothing in it can go stale. It assumes a single purchase: no combined lots, split adjustments, or wash-sale rules.
Example
Maya bought the same stock three times: 200 shares at $40.00 plus a $15 commission, then 100 shares at $46.00 plus a $15 commission, then $250 of reinvested dividends bought 5 more shares at $50.00 each.
Her total basis is $8,000 + $15, plus $4,600 + $15, plus $250 of reinvested dividends — $12,880 in all. She owns 305 shares, so her per-share basis is $12,880 ÷ 305 = $42.23. The reinvested dividends count as basis even though no new cash left her account: they were already taxed as income when paid, so this stops the same money being taxed twice.
Sell all 305 shares at $55.00 with a $25 sale commission: gross proceeds $16,775, net proceeds $16,750 — a gain of $3,870, or 30.05%, on her $12,880 basis.
Common Uses
- Before you sell: check whether a position is really ahead after both commissions.
- At tax time: work out the gain or loss on each sale to match your broker’s figures.
- After reinvesting dividends: add each reinvestment to your basis so you do not overstate your gain.
- After a split: a 2-for-1 split halves your per-share basis while the total stays the same — 450 shares at $87.50 become 900 at $43.75.
- When comparing brokers: see what a year of commissions costs you.
One honest limit: this calculator tracks a single lot, and real portfolios get messy — multiple lots, reinvested dividends, splits, and inherited shares all change the basis, and broker records are not always right. Keep your trade confirmations.
Frequently Asked Questions
What is a cost basis calculator used for? It works out what you paid for an investment, commissions included, and the cost per share. That is the number you need to find your gain or loss when you sell.
How do reinvested dividends change my cost basis? Each reinvestment adds to your basis: a $250 dividend buying 5 shares at $50 each raises your basis by $250 and your share count by 5. The dividend was already taxed as income, so this stops you paying tax on the same $250 again.
What is a wash sale, and does it change my basis? A wash sale is selling at a loss and buying the same or a nearly identical security within 30 days either side of the sale. The loss is disallowed for that year, but added to the basis of the replacement shares — see IRS Publication 550.
What happens to cost basis when shares are inherited? Inherited shares generally get a stepped-up basis: the basis becomes the fair market value on the date of the previous owner’s death, not what they paid. That can wipe out years of realized gain, so confirm the value the estate used.
How does a stock split change my cost basis? A split changes the per-share basis, not the total: in a 2-for-1 split your share count doubles and your per-share basis halves. A reverse split works the other way — fewer shares, higher per-share basis, same total.
How much tax will I pay on the gain? It depends on your income and how long you held the shares. For 2026, the federal long-term rate is 0% up to $49,450 single and $98,900 married filing jointly, and 15% up to $545,500 single and $613,700 married filing jointly (IRS Rev. Proc. 2025-32). Short-term gains are taxed as ordinary income.
Related Calculators
- Capital Gains Tax Calculator — Tax on a sale once you know your gain.
- Stock Calculator — Price, shares, and total cost.
- Stock Return Calculator — Return on a position, dividends included.
- Investment Calculator — How an investment grows over time.
- Dividend Calculator — Dividend income on shares you own.
- Dividend Reinvestment Calculator (DRIP) — How reinvested dividends build your basis.
This calculator gives an estimate for education only, not financial, tax, or legal advice. Check the current rules and your broker’s records before you sell or file.
Last updated: December 2026