About
Income & Taxes

Cost Basis Explained: How to Calculate It for Capital Gains

Your capital gains tax is not based on what you sold for -- it is based on the difference between the sale price and your cost basis. Get the basis wrong and you either overpay the IRS or invite a notice. Here is exactly how basis is calculated, which method to tell your broker to use, and the special rules for inherited, gifted, and dividend-reinvested shares.

Updated July 3, 2026
12 min read
$300
Tax overpaid by forgetting $2,000 of reinvested dividends
$450
Saved in our example by choosing which lot to sell
3
IRS-recognized basis methods for stocks and funds
Section 1

Quick Answer

Cost basis is what you paid for an investment -- purchase price plus commissions -- adjusted up for things like reinvested dividends and down for things like depreciation. Your taxable capital gain is the sale proceeds minus that adjusted basis. If you invested $10,000, reinvested $2,000 of dividends over the years, and sold for $18,000, your basis is $12,000 and your taxable gain is $6,000 -- not $8,000. Forgetting those reinvested dividends would overstate the gain by $2,000 and cost you roughly $300 in unnecessary tax at the 15% long-term rate.

Estimate the Tax on Your Gain ->

Key Takeaways

  • Capital gain = sale proceeds − adjusted cost basis. The basis, not the sale price, is what keeps your tax bill honest.
  • Reinvested dividends add to basis. You already paid tax on them -- forgetting them means paying tax on the same money twice.
  • You can often choose which shares you sell. Specific identification frequently beats the FIFO default and can cut the tax on the same sale.
  • Inherited assets get a stepped-up basis (fair market value at death); gifted assets generally carry over the giver's basis.
  • Brokers only track basis for "covered" shares -- generally stocks bought since 2011 and fund/DRIP shares since 2012. Older lots are your responsibility.
Section 2

What Cost Basis Is (and Why It Sets Your Tax Bill)

When you sell a stock, fund, crypto, or property, the IRS does not tax the check you receive -- it taxes your profit. Cost basis is the yardstick that measures that profit. It represents your total investment in the asset for tax purposes, and the IRS defines it in Topic 703(opens in new tab) as the cost plus adjustments.

  • Higher basis → smaller taxable gain → less tax. Every dollar of basis you can document is a dollar of sale proceeds the IRS does not tax.
  • Lower (or missing) basis → larger taxable gain → more tax. If you cannot document any basis at all, the IRS can treat it as zero -- making the entire sale price taxable.

Basis matters twice. First, it determines the size of the gain. Second, together with your holding period, it feeds the rate: gains on assets held more than one year are long-term and taxed at the preferential 0%, 15%, or 20% federal rates, while assets held one year or less produce short-term gains taxed as ordinary income at 10%-37%. See our 2026 capital gains tax brackets guide for the thresholds by filing status.

Basis is the "purchase price" input in our Capital Gains Calculator. Enter your full adjusted basis -- not just the original trade amount -- and the estimate reflects your real taxable gain.

Section 3

The Basic Formula

Two short equations do all the work:

Cost basis = purchase price + purchase costs (commissions, fees) ± adjustments

Capital gain (or loss) = sale proceeds − adjusted cost basis

A simple stock example with no adjustments:

  • Buy 100 shares at $95 with a $5 commission → basis = $9,505
  • Sell all 100 shares for $12,000 with a $5 fee → net proceeds = $11,995
  • Capital gain = $11,995 − $9,505 = $2,490

Most brokers today charge zero commissions on stock trades, so for recent purchases the starting basis is usually just the trade amount. The complications -- and the money -- are in the adjustments.

Section 4

Adjustments That Change Your Basis

Your original cost is only the starting point. The IRS calls the final figure your adjusted basis (Publication 551(opens in new tab)), and these are the most common adjustments for individual investors:

Adjustment Effect on Basis Why
Reinvested dividends and capital gains distributions Increase Each reinvestment buys new shares with money you already paid tax on
Commissions and transaction fees Increase Part of your cost of acquiring the asset
Capital improvements (real estate) Increase A new roof or addition adds to your investment in the property
Nondividend distributions (return of capital) Decrease The fund or company is handing part of your investment back untaxed
Depreciation deductions (rental property) Decrease You already took the deduction; the IRS recaptures it at sale
Stock splits No change in total Total basis stays the same, spread across more shares (per-share basis drops)
Section 5

FIFO vs Specific ID vs Average Cost: Choosing a Method

If you bought shares of the same investment at different times and prices (separate "lots") and then sell only some of them, the IRS needs to know which shares you sold. Three methods are recognized (IRS Publication 550(opens in new tab)):

Method How It Works Applies To Best When
FIFO (first-in, first-out) Oldest shares are sold first -- the default if you say nothing Stocks, ETFs, funds Oldest lots have the highest basis, or you want long-term treatment
Specific identification You tell the broker exactly which lot(s) to sell, at or before the sale Stocks, ETFs, funds Almost always -- it gives you control over gain size and holding period
Average cost Total cost of all shares ÷ total shares = one per-share basis Mutual fund and dividend-reinvestment shares only Simplicity matters more than optimization

Two practical rules: specific identification must be made at or before settlement -- you cannot re-designate lots after the fact at tax time. And once you sell mutual fund shares under the average cost method, the averaging election generally sticks for the shares you already own; check with your fund company before switching.

Section 6

Worked Example: Same Sale, $450 Less Tax

Suppose you own 300 shares of one stock, bought in three lots, and in late 2026 you sell 100 shares at $120 ($12,000 of proceeds). You file single and your income puts your long-term gains in the 15% bracket.

Your Three Lots at the Time of Sale
Lot Purchased Shares Price Basis Holding Period
A January 2020 100 $50 $5,000 Long-term
B March 2023 100 $80 $8,000 Long-term
C February 2026 100 $90 $9,000 Short-term
The Same 100-Share Sale Under Each Choice
Choice Basis Used Taxable Gain Rate Federal Tax
FIFO default (sells Lot A) $5,000 $7,000 15% long-term $1,050
Specific ID: sell Lot B $8,000 $4,000 15% long-term $600
Specific ID: sell Lot C $9,000 $3,000 Ordinary income (short-term) $720 at a 24% marginal rate

Choosing Lot B instead of accepting the FIFO default cuts the tax on the identical sale from $1,050 to $600 -- a $450 saving from a single instruction to your broker. Note the trap in the third row: Lot C has the highest basis and the smallest gain, yet it can produce a bigger tax bill than Lot B, because a holding period of one year or less makes the gain short-term and taxes it at ordinary income rates (24% for this filer). The smartest lot to sell balances basis and holding period.

Run Your Own Lots Through the Calculator ->

Section 7

Special Situations: Inherited, Gifted, Crypto, and Your Home

Inherited Assets: The Step-Up

Inherited assets generally receive a stepped-up basis equal to the fair market value on the date of the original owner's death (IRC §1014). If your parent bought stock for $10,000 and it was worth $50,000 when they died, your basis is $50,000 -- the $40,000 of lifetime appreciation is never taxed as a capital gain. Inherited property is also automatically treated as long-term, no matter how long anyone held it.

Gifted Assets: Carryover (With a Twist)

A gift generally carries over the giver's basis. Stock your parent bought for $10,000 and gifted to you keeps a $10,000 basis in your hands, even if it is worth $30,000 on the gift date. The twist is the dual-basis rule for assets that have lost value by the gift date: you use the giver's basis to measure a later gain, but the lower gift-date value to measure a later loss -- and a sale price in between produces neither gain nor loss (IRS Publication 551(opens in new tab)).

Cryptocurrency

The IRS treats crypto as property, so the same basis math applies: purchase price plus fees, tracked lot by lot, with every sale, swap, or purchase-with-crypto a taxable event. Exchanges have historically been inconsistent about basis reporting, so keep your own records of each acquisition's date and cost.

Your Home

A home's basis starts at the purchase price plus many closing costs, then grows with documented capital improvements -- a remodel, an addition, a new HVAC system (repairs do not count). A higher basis shrinks the gain that has to fit under the Section 121 exclusion of $250,000 (single) / $500,000 (married filing jointly). Details and a worked example are in our home sale exclusion guide.

Section 8

Missing Cost Basis: Covered vs Noncovered Shares

Since the broker-reporting rules phased in, your broker is required to track basis and report it to the IRS on Form 1099-B(opens in new tab) for covered securities:

  • Stocks acquired on or after January 1, 2011
  • Mutual fund and dividend-reinvestment (DRIP) shares acquired on or after January 1, 2012
  • Options and less complex bonds acquired on or after January 1, 2014

For anything older -- noncovered shares -- the broker may show a courtesy figure or nothing at all, and the IRS gets no basis report. Reconstructing it is on you:

  1. Pull old records: trade confirmations, year-end account statements, and dividend-reinvestment histories.
  2. Use historical prices: if you know roughly when you bought, the stock's historical price range (adjusted for splits) supports a reasonable, documented estimate.
  3. Check for splits, spinoffs, and mergers: corporate actions reallocate basis; the company's investor-relations page usually publishes the allocation factors.
  4. Document everything: a defensible, written reconstruction beats a guess. If you can document no basis at all, the IRS can treat it as zero -- taxing the entire proceeds.

Selling losers to offset gains? Your basis also determines the size of a capital loss. See our tax-loss harvesting guide for how losses offset gains and the wash-sale rule that can disallow them.

FAQ

Frequently Asked Questions

Start with what you paid for the asset, including commissions and transaction fees. Then adjust it: add reinvested dividends and capital improvements (for property), and subtract depreciation, nondividend distributions (return of capital), and similar items. The result is your adjusted basis. Your capital gain is the sale proceeds minus that adjusted basis. For example, if you invested $10,000, reinvested $2,000 of dividends, and sold for $18,000, your basis is $12,000 and your taxable gain is $6,000 -- not $8,000.

First check your broker's records. For covered securities -- generally stocks bought in 2011 or later and mutual fund or dividend-reinvestment shares bought in 2012 or later -- brokers must track basis and report it to the IRS on Form 1099-B. For older, noncovered shares, reconstruct basis from trade confirmations, account statements, and historical prices. If you truly cannot document any basis, the IRS can treat the basis as zero, which makes the entire sale price taxable -- the most expensive possible outcome.

Inherited assets generally receive a stepped-up basis: the basis becomes the fair market value on the date of the original owner's death, not what the deceased originally paid (IRC §1014). If your parent bought stock for $10,000 and it was worth $50,000 when they died, your basis is $50,000 -- the $40,000 of gain that built up during their lifetime is never taxed as capital gain. Inherited assets are also automatically treated as long-term, regardless of how long you or the deceased held them.

Gifts generally carry over the giver's basis: if your parent gifts you stock they bought for $10,000, your basis is $10,000 no matter what it is worth on the gift date. A special dual-basis rule applies when the stock is worth less than the giver's basis at the time of the gift: you use the giver's basis to measure a later gain, but the lower gift-date value to measure a later loss, and a sale in between produces neither gain nor loss (IRS Publication 551).

Yes. Every reinvested dividend buys new shares, and each purchase adds to your total cost basis because you already paid income tax on the dividend in the year it was paid. Forgetting reinvested dividends is one of the most common cost basis mistakes -- it overstates your gain and makes you pay tax on the same money twice. An investor who reinvested $2,000 of dividends and forgets them would overstate the gain by $2,000, overpaying about $300 at the 15% long-term rate.

Take Action

Put Your Basis to Work

Once you know your adjusted basis, estimating the tax takes seconds: enter your basis as the purchase price, your sale price, your holding period, and your income, and our free calculator estimates the federal tax on the gain at 2026 rates.

Open the Capital Gains Calculator ->

Section 11

Sources

Important Disclaimer

Disclaimer: This content is for educational and informational purposes only and does not constitute financial, tax, or legal advice. Individual circumstances vary, and you should consult with a qualified tax professional before making decisions about basis methods, lot selection, or the sale of appreciated assets. Examples use simplified assumptions -- federal tax only, and a 15% long-term / 24% ordinary marginal rate where noted -- and exclude state taxes and the 3.8% Net Investment Income Tax that can apply to higher incomes. While we strive for accuracy, tax laws and IRS guidance change frequently. Data current as of July 2026.

Content reviewed by the Digital Calculator Team. Learn more about our accuracy standards.

Resources

Related Resources