Cost Basis Calculator
Calculate your stock cost basis across multiple purchase lots, stock splits, and DRIP reinvestments. Compare FIFO vs LIFO vs Specific ID methods, estimate capital gains tax with NIIT, and check if the wash sale rule applies to your trade.
Try another scenario
How to Use This Calculator
Calculate Cost Basis tab
Enter your purchase price per share, number of shares, and any commission or fee. Add up to 3 additional lots if you purchased the same stock at different times and prices. Adjust for stock splits (2:1 through 20:1) and toggle DRIP reinvestments if you participated in a dividend reinvestment plan. The calculator computes total cost basis, cost basis per share, and per-lot basis for FIFO/LIFO tax planning.
Tax on Sale tab
Enter your sale price, shares sold, and cost basis (from Tab 1 or your brokerage statement). Choose a cost basis method (FIFO, LIFO, Specific ID, or Average Cost), holding period (long-term vs short-term), filing status, and gross income. The calculator shows your capital gain or loss, federal tax at the correct LTCG or ordinary rate, NIIT (3.8% if applicable), state tax, total tax, and net after-tax proceeds.
Wash Sale Check tab
Enter your sale date, loss amount, repurchase date, and whether the repurchase is a substantially identical security. The calculator maps the 61-day wash sale window (30 days before through 30 days after the sale), determines whether the wash sale rule applies, and calculates your adjusted basis on the replacement shares if the loss is disallowed.
Share your result
Every input is encoded in the URL. Click Share to send your exact scenario to an accountant, financial advisor, or tax preparer.
The Formula
Cost basis is the original value of an investment for tax purposes, adjusted for splits, commissions, and reinvestments:
Total Cost Basis = Sum of All Lot Cost Bases + DRIP Reinvestment Costs
Adjusted Shares (after split) = Original Shares × Split Ratio
Adjusted Basis Per Share = Total Cost Basis / Adjusted Total Shares
Capital Gain = Net Sale Proceeds − Cost Basis
Net Sale Proceeds = (Sale Price × Shares Sold) − Sale Commission
LTCG Tax = Capital Gain × LTCG Rate (0% / 15% / 20%)
NIIT = Investment Income Above Threshold × 3.8%
Total Tax = Federal Tax + NIIT + State Tax
The cost basis method you choose affects which shares are considered sold and therefore your gain or loss. FIFO (first in, first out) sells the oldest shares first — in a rising market, this produces the largest gain. LIFO (last in, first out) sells the newest shares — in a rising market, this produces the smallest gain. Specific Identification gives you the most control by letting you choose exactly which lots to sell.
Stock splits change the number of shares you own but do not change your total cost basis. A 4-for-1 split turns 100 shares into 400 shares, but your total investment remains the same — only the per-share basis changes.
Example
Marcus — 3 lots of AAPL, comparing FIFO vs LIFO
Marcus bought Apple stock in three lots over two years. Now he wants to sell 150 shares at $210/share and minimize his tax bill. He files Single with $95,000 gross income and lives in California (13.3% state tax).
Purchase lots
FIFO method (sell oldest first)
LIFO method (sell newest first)
By using LIFO instead of FIFO, Marcus saves $1,239 in taxes on the same sale. However, Lot 3 was purchased less than a year ago — those 50 shares would be taxed as short-term gains at ordinary income rates (22%), which could change the math. Marcus should use Specific Identification to cherry-pick the highest-cost long-term lots for maximum tax efficiency.