Cost basis calculator
Bought the same stock at different prices, then sold some? See your cost basis and realized gain under FIFO and LIFO, side by side.
FIFO vs LIFO — what's the difference?
When you've bought a stock in several batches at different prices and then sell only part of your holding, the IRS needs to know which shares you sold — because that decides your cost basis, and therefore your taxable gain.
- FIFO (first in, first out) assumes you sold your oldest shares first. It's the default most brokers apply if you don't specify.
- LIFO (last in, first out) assumes you sold your most recent shares first.
In a stock that's risen over time, FIFO usually sells your cheapest (oldest) shares, producing a larger reported gain and a bigger tax bill now. LIFO sells pricier recent shares, often shrinking the gain. Neither is "right" — they're just different lot-selection methods, and which one helps depends on your prices and your tax situation.
This calculator also shows the oldest-vs-newest split so you can see the gap for yourself.
Educational tool, not tax advice — it also ignores the long/short-term split within your lots. Runs entirely in your browser.