ToolsBlog Download

Cost Basis Calculator

Calculate the adjusted cost basis of a stock position across up to 10 purchase lots, splits, and reinvested dividends, then see your short and long-term gain.

Cost Basis Calculator

Purchase Lots

One row per purchase: a date, a share count, and the price you paid. Up to 10 lots. Combine same-day buys into a single row, and for a position with more than 10 lots, run it in batches or read the totals off your broker's Form 1099-B.

Lot 1
Lot 2
Lot 3
3 of 10 lots

Cost Basis Method

FIFO sells your oldest shares first. It is the IRS default when you have not identified specific shares with your broker.

The Sale

$
$

Enter the price per share, not the total. The sale fee is a selling expense that reduces what you realized.

Adjustments

A split is applied once to every lot before the sale. Share counts go up, basis per share goes down, and your total basis does not move. Leave it at 1 for 1 if there was no split.

$

Total dollars of dividends reinvested into shares you have already counted in the lots above. The amount is spread across your lots pro rata by share count. To keep the acquisition dates exact instead, enter each reinvestment as its own lot row.

Price the gain with the Capital Gains Tax Calculator →
Cost Basis of Shares Sold
N/A
Enter your sale details
Total adjusted cost basis N/A
Total shares held N/A
Adjusted basis per share N/A
Net sale proceeds N/A
Capital gain or loss N/A
Short-term gain or loss N/A
Short-term shares N/A
Long-term gain or loss N/A
Long-term shares N/A
Shares still held N/A
Basis of remaining shares N/A

Estimates only. This calculator is for informational purposes and does not provide tax or legal advice. Cost basis reporting rules, the average-basis election, and specific-identification elections have to be handled with your broker at the time of the trade, so consult a qualified tax professional before relying on these figures for a filing position.

Which Shares Were Sold

Lot Acquired Shares used Basis / share Basis used Term
Add your lots and a sale date to see the depletion order.

Rows are listed in the order your chosen method consumes them. Greyed rows are lots the sale never reached.

Estimate the tax on your sale in Tax47

This tool stops at basis and gain, the part that is pure arithmetic. What the gain actually costs you depends on your filing status and the rest of your income. Tax47 builds the whole return, so the gain is taxed next to everything else you earned instead of on its own.

How to calculate cost basis, lot by lot

Basis is a property of a lot, not of a position. A lot is one purchase: one date, one share count, one price. The formula for a single lot is short:

Lot basis = shares x price per share + commission

Commissions and other acquisition costs are part of what you paid, so they belong in basis (IRS Publication 551). A $9.99 trade commission raises your basis by $9.99 and lowers your eventual gain by the same amount.

Take three purchases of the same stock, each with a $5 commission:

A three-lot position
LotAcquiredSharesPriceLot basisBasis per share
1May 10, 202250$20.00$1,005$20.10
2Jan 15, 202450$40.00$2,005$40.10
3Feb 2, 202650$60.00$3,005$60.10

Total: 150 shares, $6,015 of basis, $40.10 per share on average. Your broker will often show you only that blended per-share number. It is not enough. The moment you sell part of the position, the lot view is what decides which shares left the account, what basis went with them, and whether the resulting gain is short-term or long-term. Two of those three answers are invisible in a blended figure.

FIFO, LIFO, and average cost: how the method changes your gain

Keep the same three lots and sell 120 shares on August 1, 2026 at $70. The sale spans more than one lot, so the method decides which shares are consumed. Each lot contributes the smaller of what it still holds and what the sale still needs, then the walk moves on to the next lot in order.

Selling 120 of 150 shares, three ways
MethodDepletion orderBasis of shares soldGainSplit
FIFO50 from lot 1, 50 from lot 2, 20 from lot 3$4,212$4,188100 long-term, 20 short-term
LIFO50 from lot 3, 50 from lot 2, 20 from lot 1$5,412$2,98870 long-term, 50 short-term
Average costBasis averaged at $40.10, dates still FIFO$4,812$3,588100 long-term, 20 short-term

Same shares, same sale price, three different answers, and the largest is exactly $1,200 apart from the smallest. Which one you may use is not a preference:

  • FIFO is the default for stocks whenever you have not identified specific shares.
  • Average cost is limited to mutual fund shares and DRIP shares (IRS Publication 550, "Average Basis"; Treas. Reg. Section 1.1012-1(e)). It is not available for individual stocks. Even when you do use it, the shares are still deemed sold first-in-first-out for holding-period purposes, which is why the average-cost row above carries the same 100/20 split as FIFO.
  • Specific identification requires that you told the broker which shares to sell at the time of the trade, and that the broker confirmed it. Deciding afterward does not count.

LIFO appears here because brokers do offer a last-in-first-out lot-selection setting, and because seeing it next to FIFO makes the trade-off obvious: a smaller gain that is short-term is not automatically the better outcome.

Adjustments that change your basis: splits, reinvested dividends, and fees

A stock split is not a taxable event and it does not change your total basis. All it changes is how that basis is spread. A 2-for-1 split on 100 shares with a $5,000 basis gives you 200 shares at $25 each, still $5,000. A 1-for-10 reverse split gives you 10 shares at $500 each, still $5,000. The holding period rides along: post-split shares keep the acquisition date of the shares they came from, so a split never resets the clock. This calculator takes the ratio as two numbers, so 3-for-2 is 3 and 2, and 1-for-10 is 1 and 10.

Reinvested dividends are the adjustment people forget. You paid tax on the dividend in the year it was declared, and the cash then bought more shares. Those dollars are basis. Leaving them out is the most common way people overpay on a long-held position, because a year of small reinvestments adds up and then a decade of them really adds up. This tool takes one total figure and spreads it across your lots pro rata by share count, which gets the total exactly right. If the acquisition dates of the reinvested shares matter to your short-term and long-term split, enter each reinvestment as its own lot row instead.

Commissions and fees land on both sides. Buying costs get added to basis, and selling costs come off what you realized (IRS Publication 551). A $9.99 fee on each side of a trade moves the gain by $19.98, which is small on one trade and not small across a year of them.

Run the three-lot position above through all three adjustments: a 2-for-1 split turns 150 shares into 300 at half the per-share basis, $6,015 of total basis unchanged; $300 of reinvested dividends then lifts every share by $1.00, so total basis becomes $6,315; and the $15 of buy commissions is already inside those lot figures.

Short-term or long-term: where the line falls

Long-term means you held the shares more than one year. The counting rule is what trips people: you start counting on the day after you acquired the shares and count through the day you sell (IRS Topic No. 409). So shares bought on June 10, 2025 first become long-term on June 11, 2026. Selling on June 10, 2026, the exact anniversary, is short-term. One day of difference, and on a large position it is an expensive day.

The test runs per lot, then the results are summed, so one sale can land on both sides of the line at once. In the FIFO example above, 100 shares are long-term and 20 are short-term because the third lot was bought six months before the sale. The calculator classifies each depleted slice, adds up the long-term side, and derives the short-term side by subtraction so the two always reconcile against the total.

A stock split does not restart the clock, and neither does a reverse split. A leap-day purchase is handled the way the calendar handles it: shares acquired on February 29, 2028 become long-term on March 1, 2029.

What the two buckets actually cost you is a separate question, and it depends on your filing status and your total taxable income rather than on this trade alone. Take the split from here to the Capital Gains Tax Calculator, or, if the sale produced a loss, to the Tax-Loss Harvesting Calculator for netting and carryforward. A large realized gain can also pull in the net investment income tax, which the NIIT Calculator covers. For equity compensation, where every vest or purchase is its own lot with its own date, use the RSU Tax Calculator or the ESPP Tax Calculator. To see the gain sitting inside a whole return next to your credits and deductions, download Tax47.

Frequently Asked Questions

Common questions about cost basis calculator

What is cost basis?

Cost basis is what you paid for an investment, including commissions and fees, adjusted over time for events like stock splits, reinvested dividends, and returns of capital. Your capital gain or loss is the sale proceeds minus that adjusted basis, so an accurate basis is what keeps you from paying tax on money you already paid in. (IRS Publication 551, Basis of Assets.)

FIFO, LIFO, or average cost: which method should I use?

FIFO sells your oldest shares first and is the IRS default when you do not identify specific shares. It tends to produce more long-term gain, because the oldest shares are the ones most likely past the one-year line. LIFO sells your newest shares first, which in a rising market usually means a smaller gain but a short-term one. Average cost pools everything into a single per-share figure. Your broker's default is FIFO for stocks, and the method you use has to be supported by what you actually elected with the broker, not just what looks best in a calculator.

Can I use the average cost method for individual stocks?

No. Average cost is only permitted for mutual fund shares and for shares held in a dividend reinvestment plan (DRIP). Individual stocks must use FIFO or specific identification (IRS Publication 550, "Average Basis"; Treas. Reg. Section 1.1012-1(e)). If you pick Average cost here for a single-stock position, treat the result as a what-if, not as a filing position. Under average cost your shares are still treated as sold first-in-first-out for holding-period purposes, which is why this calculator splits short-term and long-term by FIFO order even when the basis is averaged.

How does a stock split change my cost basis?

A split changes the number of shares and the basis per share, but not your total basis, and it is not a taxable event. A 2-for-1 split on 100 shares with a $5,000 basis leaves you with 200 shares at $25 each, still $5,000. A 1-for-10 reverse split leaves you with 10 shares at $500 each, still $5,000. Your holding period does not restart: the post-split shares inherit the acquisition date of the shares they came from. (IRS FAQ, Stocks (options, splits, traders).)

Do reinvested dividends increase my cost basis?

Yes, and forgetting them is the single most common way people overpay. You already paid tax on the dividend in the year it was declared, the cash then bought more shares, and those dollars are part of your basis. Leave reinvestments out and you get taxed twice on the same money.

How does this calculator handle reinvested dividends?

It takes one total dollar figure and spreads it across your lots pro rata by share count, raising the basis per share. That gets your total adjusted basis exactly right. What it approximates is the acquisition date of the reinvested shares: because the reinvested dollars are folded into your existing lots, some genuinely short-term DRIP shares can land in the long-term bucket. If that split matters to you, skip the aggregate field and enter each reinvestment as its own lot row with its own date, up to the 10-lot limit.

When does a gain become long-term?

When the sale date is more than one year after the acquisition date. You start counting on the day after you acquired the shares and count through the day you sell, so buy on June 10, 2025 and the first long-term sale date is June 11, 2026. Selling on the anniversary itself is still short-term. The test is applied to each lot separately, so one sale can produce both short-term and long-term results. (IRS Topic No. 409.)

Why doesn't this calculator show the tax I'll owe?

Because the number would be wrong more often than right. Capital gains tax depends on your filing status, your total taxable income, and how the gain stacks on top of it, none of which a basis calculator knows. This tool does the part that is pure arithmetic: what your basis is, and what the gain or loss is. For the tax on top, use the Capital Gains Tax Calculator or build the full return in the Tax47 app.