Cost Basis Calculator (FIFO/LIFO)

Calculate stock cost basis using FIFO, LIFO, specific ID, or average cost. Compare tax impact of each method.

Purchase Lots
$
$
$
$
$
Cost Basis Method

Sale Proceeds

$6,000.00

Cost Basis (FIFO)

$4,008.00

Gain/Loss

$1,992.00

Method Comparison

FIFOGain: $1,992.00
LIFOGain: $1,388.00
Specific ID (Highest Cost)Gain: $1,388.00
Average CostGain: $1,690.00

Tax Impact (Estimated)

FIFOSTCG: $0.00 | LTCG: $1,992.00
LIFOSTCG: $0.00 | LTCG: $1,388.00
AVERAGESTCG: $1,690.00 | LTCG: $0.00
SPECIFICSTCG: $0.00 | LTCG: $1,388.00

Recommendation

Best Method for Tax SavingsLIFO
NoteSpecific 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

This Cost Basis Calculator helps you determine the original value of your stock investments, crucial for calculating capital gains or losses when you sell. Accurately determining your cost basis can significantly impact your tax liability, especially with the 2026 long-term capital gains tax rates potentially ranging from 0% to 20% depending on your income bracket. Understanding this is vital for optimizing your investment strategy and avoiding overpaying taxes.

The calculator employs various methodologies: FIFO (First-In, First-Out) assumes the oldest shares are sold first, LIFO (Last-In, First-Out) assumes the newest shares are sold first, Specific Identification allows you to choose which exact shares to sell, and Average Cost calculates a weighted average cost for all shares. Each method directly influences which purchase prices are applied to your sale, thereby determining your taxable gain or loss.

A common mistake is neglecting to track cost basis, leading to default FIFO application by brokers, which might not be tax-optimal. For highly appreciated assets, consider Specific Identification to sell high-cost shares first, minimizing gains. Remember, wash sale rules can disallow losses if you repurchase substantially identical securities within 30 days before or after selling at a loss.

Example: Selling Apple (AAPL) Shares Purchased Over Time

  1. 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. 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. 3 Intermediate Result (FIFO): Your capital gain is $15,750 (proceeds) - $12,750 (cost basis) = $3,000.
  4. 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?
FIFO (First In, First Out) sells your oldest shares first, often resulting in higher gains if the stock has risen over time. LIFO (Last In, First Out) sells the newest shares, which may show smaller gains if recent purchases were at higher prices.
Which cost basis method (FIFO or specific ID) saves the most on taxes?
Your cost basis determines your capital gain or loss when you sell. A higher cost basis means lower gains and less tax. The method you choose (FIFO, LIFO, specific identification, or average cost) can significantly impact your tax bill.
What is the cost basis of inherited stock?
Inherited stock gets a stepped-up cost basis to the fair market value on the date of the decedent death. This means unrealized gains during the decedent lifetime are effectively tax-free for the heir.