🇺🇸 United States

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.

$
$
Brokerage commission on this purchase
Purchase date
Additional lots (optional)
Adjusts share count but not total cost basis
Dividend Reinvestment Plan shares

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:

Cost Basis Per Lot = (Price Per Share × Number of Shares) + Commission/Fee

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

Lot 1: Jan 2024 — 100 shares @ $150$15,000
Lot 2: Jul 2024 — 75 shares @ $185$13,875
Lot 3: Mar 2025 — 50 shares @ $220$11,000
Total cost basis (225 shares)$39,875
Average cost basis per share$177.22

FIFO method (sell oldest first)

Sells: 100 shares from Lot 1 + 50 from Lot 2
Cost basis (FIFO)$24,250
Sale proceeds (150 × $210)$31,500
Capital gain (FIFO)$7,250
LTCG tax (15%)$1,088
State tax (13.3%)$964
Total tax (FIFO)$2,052

LIFO method (sell newest first)

Sells: 50 shares from Lot 3 + 75 from Lot 2 + 25 from Lot 1
Cost basis (LIFO)$28,625
Capital gain (LIFO)$2,875
LTCG tax (15%)$431
State tax (13.3%)$382
Total tax (LIFO)$813

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.

FAQ

Cost basis is the original value of an investment for tax purposes, including the purchase price plus any commissions, fees, or adjustments. It matters because your capital gain or loss is calculated as sale proceeds minus cost basis. A higher cost basis means a lower taxable gain and less tax owed. Tracking cost basis accurately can save you thousands in taxes, especially if you have multiple lots purchased at different prices.
FIFO (First In, First Out) sells your oldest shares first. This is the IRS default if you don’t specify. LIFO (Last In, First Out) sells your newest shares first — useful when recent purchases are at higher prices. Specific Identification lets you choose exactly which lots to sell, giving you the most tax control. Average Cost divides total cost by total shares — only allowed for mutual funds. To use Specific ID, you must identify the shares to your broker before the settlement date and receive written confirmation.
The wash sale rule (IRC §1091) disallows a capital loss deduction if you buy a “substantially identical” security within 30 days before or after the sale — a 61-day window total. The disallowed loss is added to the cost basis of the replacement shares, so the loss is deferred, not permanently lost. To avoid a wash sale: wait at least 31 days before repurchasing, buy a different (not substantially identical) security, or purchase in a different account type. Note: the wash sale rule applies across all your accounts, including IRAs and your spouse’s accounts.
Stock splits change the number of shares you own but do not change your total cost basis. For example, if you bought 100 shares at $200/share ($20,000 total) and the company does a 4-for-1 split, you now own 400 shares with a basis of $50/share — still $20,000 total. Your brokerage should automatically adjust the per-share cost basis after a split. Always verify the adjustment is correct on your 1099-B.
The Net Investment Income Tax (NIIT) is an additional 3.8% tax on investment income (including capital gains, dividends, and interest) when your modified adjusted gross income exceeds $200,000 (single), $250,000 (married filing jointly), or $125,000 (married filing separately). The NIIT applies to the lesser of your net investment income or the amount your MAGI exceeds the threshold. It’s reported on Form 8960 and is in addition to regular capital gains tax.

Related Calculators

Add This Calculator to Your Website

Embed the sum.money Cost Basis Calculator on your site. Free, responsive, always up-to-date.

<iframe src="https://sum.money/embed/us/cost-basis-calculator" width="100%" height="600"></iframe>