Cost Basis Calculator (FIFO/LIFO)
Calculate stock cost basis using FIFO, LIFO, specific ID, or average cost. Compare tax impact of each method.
By Konstantin Iakovlev · Updated April 2026 · Source: SEC
Sale Proceeds
$6,000.00
Cost Basis (FIFO)
$4,008.00
Gain/Loss
$1,992.00
Method Comparison
| FIFO | Gain: $1,992.00 |
| LIFO | Gain: $1,388.00 |
| Specific ID (Highest Cost) | Gain: $1,388.00 |
| Average Cost | Gain: $1,690.00 |
Tax Impact (Estimated)
| FIFO | STCG: $0.00 | LTCG: $1,992.00 |
| LIFO | STCG: $0.00 | LTCG: $1,388.00 |
| AVERAGE | STCG: $1,690.00 | LTCG: $0.00 |
| SPECIFIC | STCG: $0.00 | LTCG: $1,388.00 |
Recommendation
| Best Method for Tax Savings | LIFO |
| Note | Specific ID requires broker notification before sale |
Use the Cost Basis Calculator (FIFO/LIFO) above to calculate your results. Enter your values and see instant results — all calculations run in your browser.
Disclaimer: This calculator is for informational purposes only and does not constitute tax, financial, or legal advice. Results are estimates based on the information you provide and current rates. Always consult a qualified tax professional or financial advisor for advice specific to your situation.
How It Works
When you sell a stock, your taxable gain or loss is the difference between the sale price and your cost basis, which makes pinning down that basis one of the most consequential numbers on your return. It can move your tax bill meaningfully, particularly given that 2026 long-term capital gains rates may run anywhere from 0% to 20% depending on your income bracket. Get the basis right and you avoid handing the IRS more than you owe.
Four methods are available here, and each one points at a different set of purchase lots. FIFO (First-In, First-Out) treats your oldest shares as the first sold; LIFO (Last-In, First-Out) does the opposite and sells the newest first; Specific Identification lets you name the exact shares going out the door; and Average Cost blends every lot into a single weighted figure. Whichever you pick decides which purchase prices attach to the sale, and therefore the size of your reported gain or loss.
If you never track basis yourself, your broker typically defaults to FIFO, which is not always the most tax-efficient choice. With a position that has appreciated sharply, Specific Identification lets you unload your highest-cost shares first and hold your gain down. One more rule to respect: wash sale provisions can disallow a loss if you buy back a substantially identical security within 30 days before or after the sale that produced it.
Example: Selling Apple (AAPL) Shares Purchased Over Time
- 1 Input: On 1/15/2024, you bought 100 shares of AAPL at $170/share. On 7/20/2024, you bought another 50 shares at $190/share. On 3/10/2025, you sell 75 shares of AAPL for $210/share.
- 2 Calculation (FIFO Method): The calculator assumes you sell the first 75 shares acquired. 75 shares * $170/share = $12,750 (cost basis). Sale proceeds: 75 shares * $210/share = $15,750.
- 3 Intermediate Result (FIFO): Your capital gain is $15,750 (proceeds) - $12,750 (cost basis) = $3,000.
- 4 Final Result (FIFO): Under FIFO, you realize a $3,000 short-term capital gain. If, for example, your taxable income in 2026 puts you in the 22% ordinary income tax bracket, this gain would be taxed at your ordinary income rate, potentially resulting in $660 in taxes on this transaction.
Source: SEC · Last updated: April 2026
Frequently Asked Questions
What is the difference between FIFO and LIFO for cost basis?
Which cost basis method (FIFO or specific ID) saves the most on taxes?
What is the cost basis of inherited stock?
You might also need
Compound Interest Calculator — See Your Money Grow Over Time
Calculate compound interest with regular contributions and see how your money grows with daily, monthly, or annual compounding. Free, instant results and charts.
Inflation Calculator
Calculate the impact of inflation on purchasing power over time. See how much past dollars are worth today.
Net Worth Calculator
Calculate your net worth by adding up assets (savings, investments, property) and subtracting liabilities (loans, credit cards).