Last updated:
What Is Cost Basis for Stocks?
Cost basis is the original value of an asset for tax purposes, typically the purchase price plus any commissions or fees you paid to acquire it. The Internal Revenue Service uses your cost basis to determine how much of your sale proceeds represent a taxable gain and how much is simply a return of capital you already paid. Accurately calculating cost basis is not optional. It directly determines whether you owe capital gains tax and how much. Errors inflate or deflate your reported gain, which can lead to overpayment or penalties.
The cost basis of a stock is not always the same as the purchase price you remember. It can be adjusted upward or downward by a number of subsequent events: stock splits, spinoffs, dividend reinvestment, return-of-capital distributions, and wash-sale disallowances. An adjusted cost basis calculator accounts for these changes so you always report the correct figure on Schedule D of your federal tax return.
The IRS provides detailed rules in IRS Publication 550. Investment Income and Expenses, which covers every scenario from stocks and bonds to options and mutual funds. Reading it alongside a stock cost basis calculator gives you a solid foundation for tax-aware investing.
How This Calculator Works
This tool offers two modes. The Single Purchase tab handles the most common scenario: one block of shares purchased at a fixed price. You enter the number of shares, price per share, commission paid, and a split multiplier if the stock has split since you bought it. The calculator outputs three figures; total cost basis, adjusted cost per share, and adjusted share count. That you can plug directly into a brokerage trade ticket or tax form.
The Multiple Lots tab covers investors who accumulated shares over time. Enter up to five purchase lots, each with its own share count, price, and holding period in months. Choose either the FIFO cost basis calculator method or average cost, then enter the number of shares you plan to sell and today's price. The tool calculates total cost basis, the basis of the shares being sold, total gain or loss, and, critically, breaks that gain or loss into short-term and long-term components. That breakdown is necessary because the two categories are taxed at very different federal rates.
For a broader view of the taxes owed on an upcoming sale, use our capital gains tax calculator after you have your cost basis in hand.
FIFO vs. Average Cost Method Explained
The IRS allows several methods for identifying which shares you are selling when you have multiple lots. The two most widely used are FIFO and average cost.
FIFO (First In, First Out) assumes you sell your oldest shares first. The IRS treats FIFO as the default for individual stocks when you do not specify otherwise. Because older shares were often purchased at lower prices, FIFO frequently results in a larger gain, but it also tends to maximize the fraction of your gain that qualifies as long-term, since older shares are more likely to have been held over 12 months. This FIFO logic in the Multiple Lots tab applies automatically, working through lots from oldest to newest until the shares-to-sell quantity is met.
Average cost divides your total cost basis by the total shares held to produce a single blended per-share basis. It simplifies record-keeping, especially for mutual funds where investors make frequent small purchases through systematic investment plans. Average cost is not permitted for individual stocks under IRS rules. It is allowed only for regulated investment company (mutual fund) shares. However, many investors use it conceptually to estimate a blended stock cost basis before deciding whether to sell.
A third approach, specific identification, lets you choose exactly which shares to sell, potentially selecting the highest-basis lot to minimize the taxable gain. To use specific identification, you must notify your broker before the sale and keep detailed records. Investopedia's cost basis explainer walks through all three methods in depth.
Here is how the choice of method changes the tax bill. An investor bought 100 shares at $40 in 2019, another 100 at $80 in 2021, and another 100 at $120 in 2023, for 300 shares total. They now sell 100 shares at $150. Under FIFO, the oldest lot ($40 basis) is sold first, producing a $110-per-share gain, or $11,000 total, all of it long-term. Under average cost, the blended basis across all 300 shares is $80, producing a $70-per-share gain, or $7,000 total. Under specific identification, selling the most recent $120 lot produces just a $30-per-share gain, $3,000 total, though part of that lot may still be short-term depending on the exact purchase date. The same sale generates a taxable gain anywhere from $3,000 to $11,000 depending purely on which shares are deemed sold, which is why the method you choose (or your broker chooses by default) has real tax consequences.
A costly and common mistake is ignoring the wash-sale rule when harvesting losses. If you sell a stock at a loss and buy the same or a substantially identical security within 30 days before or after the sale, the IRS disallows the loss and instead adds it to the cost basis of the replacement shares. Investors who sell a losing position and immediately rebuy it, thinking they have banked a deductible loss while keeping their market position, are often surprised at tax time to find the loss was deferred, not eliminated. Waiting at least 31 days, or buying a similar but not identical fund, avoids the trap.
How Stock Splits Affect Cost Basis
When a company declares a stock split, the number of outstanding shares increases while the price per share decreases proportionally. A 2-for-1 split doubles your share count and halves the price. A 3-for-1 split triples your shares and cuts the price to one-third. In every case, your total investment value, and therefore your total cost basis, remains unchanged.
What does change is the cost per share, which is the figure that matters when calculating a capital gain on a sale. If you bought 100 shares at $200 each ($20,000 total) and the stock split 4-for-1, you now hold 400 shares with an adjusted cost per share of $50. The adjusted cost basis calculator handles this automatically: enter 100 shares, $200 price, and a split multiplier of 4. The result shows 400 adjusted shares at $50 each, total basis still $20,000.
Reverse splits work the same way in the opposite direction. A 1-for-10 reverse split reduces your 1,000 shares to 100 shares and multiplies the per-share basis by 10. Enter a split multiplier of 0.1 in the Single Purchase tab. Failing to adjust for splits is one of the most common errors on tax returns involving stock sales, so always verify split history with your broker before filing. Our stock profit calculator can take your split-adjusted cost basis and compute the final gain or loss for any sell price.
Cost Basis and Capital Gains Tax Planning
Proactive cost basis tracking is one of the most effective legal strategies for reducing capital gains taxes over time. Several planning techniques depend directly on knowing your capital gains cost basis for each lot you hold.
Tax-loss harvesting is the practice of selling positions that are below your cost basis to realize a loss you can use to offset capital gains elsewhere. The IRS allows you to deduct up to $3,000 in net capital losses against ordinary income each year, carrying forward any excess to future years. To harvest losses strategically, you need to know your cost basis for every position, not just the ones you plan to sell. Use the Multiple Lots tab of this tool alongside our tax-loss harvesting calculator to identify the highest-impact losses to realize before December 31.
Lot selection at sale time gives you control over your gain or loss by choosing which specific shares to sell. If you hold 300 shares purchased in three batches at $30, $50, and $70 per share and the stock is now at $65, selling the $70 lot produces a capital loss while selling the $30 lot produces a large gain. Keeping accurate per-lot cost basis records, and using FIFO lot selection to model the outcome, lets you make informed decisions at sale time rather than accepting whatever the IRS default produces.
Holding period management is equally important. Shares held more than 12 months qualify for long-term capital gains rates of 0%, 15%, or 20%, compared to ordinary income rates of up to 37% for short-term gains. The difference can be substantial: on a $10,000 gain, a taxpayer in the 32% ordinary income bracket would owe $3,200 at short-term rates versus $1,500 at the 15% long-term rate. The Multiple Lots tab in this capital gains cost basis calculator shows you exactly how much of your pending gain is short-term versus long-term, giving you the data you need to decide whether to wait a few more months before selling.
Explore the full suite of investing tools for additional calculators covering CAGR, dividend reinvestment, options pricing, and more, all designed to support data-driven, tax-aware investing decisions.