Cost basis calculator: how to calculate adjusted cost basis for stock, inherited and gifted shares.
Enter your actual purchase lots. This works out the adjusted cost basis of the shares you are selling under first in first out, specific identification, last in first out and average cost, splits each result into long-term and short-term shares, and prices the tax difference between them.
Other calculators multiply shares by price and stop. The number that moves money is which lot you sell, and almost nobody prices that decision before they place the order.
Cost basis calculator
Your purchase lots
You only hold shares, so the sale is capped at that.
| Method | Cost basis | Gain | Tax |
|---|---|---|---|
Naming your highest-cost lots instead of letting the broker sell your oldest saves on this one sale. The shares are identical. Only the paperwork differs, and it has to be done before the trade settles.
Planning estimate. Basis rules from IRS Publications 550 and 551; rates are whatever you enter, so use the capital gains tax calculator to work out your real bracket. Educational information, not tax advice.
In short
Cost basis is what you paid for a security, adjusted for everything that happened since, and your taxable gain is the sale proceeds minus that number. For a normal purchase it is shares times price plus commissions. It then moves: splits spread the same basis over more shares, reinvested dividends create new lots, return of capital reduces it, and a disallowed wash sale loss gets added to the replacement shares. Inherited stock resets to fair market value on the date of death, which erases the decedent's unrealized gain entirely. Gifted stock carries over the donor's basis, except that shares gifted while underwater carry a second, lower basis used only for losses. When you own several lots and sell part of a position, the lot you choose is the decision that actually changes the tax, and the IRS honors your choice only if you identify the shares at the time of the sale. Otherwise Publication 550 requires first in first out, which in an appreciated position is usually the most expensive outcome.
Last updated August 2026
Cost basis method
Which shares you sold is a decision, and it has a price
Own one lot and there is nothing to decide. Own four, and the same sale can produce four different gains. Publication 550 is direct about it: "If you can adequately identify the shares of stock or the bonds you sold, their basis is the cost or other basis of the particular shares of stock or bonds." Fail to identify them and the fallback is the oldest lot you own.
| Method | Shares deemed sold | Allowed on | What it costs you |
|---|---|---|---|
| Specific identification | Any lot you name, if you identify it at the time of sale | Individual stocks, ETFs, mutual funds | Lets you pick the highest-basis lot and cut the gain. Requires you to make the election with the broker before or at settlement. |
| FIFO, first in first out | The oldest lot you own | The default for stocks and ETFs when you name nothing | Usually the worst outcome in an appreciated position, because the oldest lot has the lowest basis and therefore the largest gain. |
| Average cost | The blended basis of every identical share | Mutual funds and shares bought through a DRIP only | Not available for ordinary stock or ETF purchases. Once elected for covered securities it applies to the whole account until you revoke it in writing. |
| Highest in first out | The most expensive lot you own | A form of specific identification, not a separate legal method | Minimizes the current gain, but can convert long-term shares into short-term sales if your expensive lots are also your newest. |
Source: IRS Publication 550, "Investment Income and Expenses" (2025), chapter 4. The average cost restriction is the rule most often stated wrongly online: it applies to "mutual fund shares if you acquired the identical shares at various times and prices, or you acquired the shares after 2011 in connection with a dividend reinvestment plan", not to ordinary stock purchases.
The timing trap
Identify before settlement, not in April
Specific identification is not something you decide when you file. You have to tell the broker which lots to sell at the time of the trade, and get written confirmation. Once the 1099-B is issued showing FIFO, arguing otherwise is a fight you will probably lose.
The holding period trap
Highest basis is not always cheapest
In a stock that has risen steadily, your most expensive lots are also your newest, so selling them can convert a 15% long-term gain into a 24% or 37% short-term one. The calculator above shows the long and short split for each method precisely so you can see when that happens.
The lock-in trap
Average cost is hard to leave
Elect average cost on covered fund shares and it applies to the whole account. Revoking it takes written notice to the custodian and generally has to happen within a year of the election or before the first sale, whichever comes first. It is the one basis choice that is genuinely sticky.
Cost basis for inherited stock
Inherited shares reset to the value on the date of death
Publication 551 puts it plainly: "Generally, the basis of property inherited from a decedent is one of the following. 1. The FMV of the property at the date of the individual's death. 2. The FMV on the alternate valuation date if the personal representative for the estate chooses to use alternate valuation."
What the decedent paid stops mattering. A grandparent who bought a position for $4,000 in 1978 and died with it worth $310,000 leaves an heir a $310,000 basis, and the entire $306,000 of unrealized gain simply never gets taxed. Sell it the following week and there is close to nothing to report. Inherited shares also count as long-term no matter how briefly you hold them.
This is why advisers spend so much energy on which appreciated positions a client should never sell. A concentrated holding you can afford to keep until death passes to your heirs with the gain wiped out, which is a materially different answer from diversifying out of a concentrated stock position while you are alive and paying for the privilege.
The community property bonus
In Arizona, California, Idaho, Louisiana, Nevada, New Mexico, Texas, Washington and Wisconsin, Publication 551 says "the total value of the community property, even the part belonging to the surviving spouse, generally becomes the basis of the entire property." Both halves step up when the first spouse dies, not just the decedent's half. In common-law states only the decedent's half resets.
The one-year clawback
You cannot gift an appreciated position to a dying relative and inherit it back clean. Publication 551 denies the step-up on "appreciated property you receive from a decedent if you or your spouse originally gave the property to the decedent within 1 year before the decedent's death." In that case you take the decedent's adjusted basis instead.
Cost basis for gifted stock
Gifted shares can carry two different bases at once
If the shares were worth at least what the donor paid on the day of the gift, it is simple: you take the donor's adjusted basis and their holding period. If they were underwater, you get a rule almost nobody applies correctly.
The dual basis rule, in the IRS's own example
Publication 551 works through property received as a gift with a fair market value of $8,000 and a donor's adjusted basis of $10,000. Sell for $12,000 and you have "a $2,000 gain because you must use the donor's adjusted basis ($10,000)". Sell for $7,000 and you have "a $1,000 loss because you must use the FMV ($8,000) at the time of the gift as your basis to figure a loss". Sell anywhere between $8,000 and $10,000 and, in the publication's words, "you have neither gain nor loss."
That middle band is real. A sale inside it produces nothing to report at all: no gain to tax, and no loss to harvest against other gains. It is also the reason gifting a losing position is usually a poor idea. The unrealized loss does not travel with the shares, so it is destroyed rather than transferred. If the point of the exercise is a deduction, the donor should sell first, keep the loss, and gift the cash.
When gift tax was paid, basis goes up
For gifts made after 1976, you increase the donor's basis by the portion of gift tax attributable to the appreciation: gift tax paid, multiplied by the net increase in value, divided by the amount of the gift. Publication 551's worked example uses a $50,000 property with a $20,000 donor basis, a $31,000 gift after the annual exclusion and $6,220 of gift tax, arriving at a basis of $26,033. Most gifts between family members fall under the annual exclusion, so no tax is paid and this adjustment never applies, but on a large transfer it is worth thousands.
Adjusted cost basis
Seven events that change the number you paid
| Event | Effect on basis | Detail |
|---|---|---|
| Commissions and fees to buy | Increase basis | The IRS example in Publication 550 buys 100 fund shares at $10 with a $50 commission and gets a basis of $10.50 per share. |
| Stock split or nontaxable stock dividend | Basis per share falls, total basis unchanged | Divide the adjusted basis of the old stock across the old and new shares. A 3-for-1 split on a $45 share leaves three shares at $15, not three shares at $45. |
| Dividend reinvestment | Each reinvested dividend creates a new lot | Every purchase has its own date and price. Forgetting them is the most common reason people overstate a gain, because they already paid tax on those dividends. |
| Return of capital distribution | Decreases basis | Common with REITs, MLPs and some closed-end funds. Basis can be driven to zero, after which further distributions are taxable gain. |
| Disallowed wash sale loss | Increases the basis of the replacement shares | Publication 550: "add the disallowed loss to the cost of the new stock or securities." The holding period of the sold shares carries over too. |
| Inheritance | Reset to fair market value at the date of death | The step-up wipes out the decedent's entire unrealized gain. It is the single largest basis event in the tax code. |
| Gift | Carryover of the donor's basis, with a loss trap | You inherit the donor's basis and holding period. If the shares were underwater at the time of the gift, a second, lower basis applies to losses. |
The wash sale adjustment, which is where basis and harvesting meet
A wash sale does not destroy your loss, it relocates it into the basis of whatever you bought back. Publication 550's example is exact: buy 100 shares for $1,000, sell them for $750, buy 100 of the same stock for $800 within 30 days, and the $250 loss is disallowed. You "add the disallowed loss of $250 to the cost of the new stock, $800, to obtain your basis in the new stock, which is $1,050." The holding period of the shares you sold carries across too.
The practical consequence is that a wash sale is a deferral, not a penalty, as long as the replacement shares stay in a taxable account. The genuine penalty case is the IRA one, where the disallowed loss cannot attach to anything and is lost for good. That, and the mechanics of the 61-day window, are covered in the tax loss harvesting rules. It is also why platforms that harvest automatically have to track basis at the lot level across every account they can see, which is the whole argument for tax loss harvesting software over doing it by hand in a spreadsheet.
What if I do not know my cost basis
Your broker knows some of it, and you own the rest
Covered
Bought after 2010
Publication 550: "Generally, a covered security is a security you acquired after 2010, with certain exceptions." For these, the broker reports basis to you and to the IRS on Form 1099-B, and the number flows onto Form 8949 with nothing further to do.
Noncovered
Older, transferred, or inherited
The 1099-B may show basis as blank or unknown. Reconstruct it from old confirmations and statements, from the company's transfer agent, or from the closing price on the purchase date. Report your figure and keep the evidence. Claiming nothing means a basis of zero, which taxes the entire sale price.
Wrong on the form
Equity compensation
Restricted stock units and employee stock purchase plan shares are the routine failure. Brokers often report only what came out of your pocket, ignoring the compensation already taxed on your W-2. Correcting it on Form 8949 with code B is normal, and skipping the correction means paying tax twice on the same dollars. The RSU tax calculator prices both versions of the same sale, the correct vest-date basis against the zero the broker reports. For plan shares the compensation element depends on which disposition rule applies, so the ESPP tax calculator works out the adjustment before you fill in the code B column.
One habit saves most of this trouble: record every purchase the day it happens, including reinvested dividends, and keep the record somewhere your brokerage cannot lose it when you transfer accounts. Basis is the one number nobody can reconstruct for you twenty years later.
Basis is a record of past decisions. This is for the next one.
Every lot in your account exists because of a decision you made about what to hold and in what weight. Build the index you actually want, weight it the way you want, backtest the construction against real history and track it against the S&P 500 before a single share changes hands.
Indexes is analysis software. It never places a trade, never connects to a brokerage and never holds money, so nothing you do here creates a lot or a taxable event.
Educational only · Never places a trade
Cost basis questions
The questions people actually type
How do I calculate cost basis?
Start with what you actually paid for the shares, including any commission or transaction fee, then adjust it for everything that happened afterwards. Splits spread the same total basis over more shares. Reinvested dividends add new lots at new prices. A disallowed wash sale loss gets added to the replacement shares. Return of capital distributions subtract from it. The result is your adjusted cost basis, and gain is proceeds minus that number.
How to calculate cost basis for stock?
Per lot, not per position. Multiply the shares in each purchase by the price you paid, add the commission on that purchase, and you have that lot's basis. When you sell part of the position you choose which lots go, and the IRS honors that choice only if you identified the shares at the time of the sale. If you did not, Publication 550 requires you to "use the stock you acquired first", which is FIFO.
What is adjusted cost basis?
Adjusted cost basis is your original purchase cost after every event the tax code says changes it. Splits, reinvested dividends, return of capital, disallowed wash sale losses, gift tax paid by a donor and the step-up at death all move it. The unadjusted purchase price is almost never the right number to put on Form 8949, and the gap between the two is where most retail reporting errors come from.
What is the cost basis for inherited stock?
Fair market value on the date the person died. Publication 551 states the basis of inherited property is "the FMV of the property at the date of the individual's death", or the value on the alternate valuation date if the estate elects it. What the decedent originally paid is irrelevant, so decades of unrealized gain disappear. Inherited shares also get long-term treatment regardless of how briefly you hold them.
What is the cost basis for gifted stock?
Usually the donor's basis, carried over to you along with their holding period. The exception matters: if the shares were worth less than the donor's basis on the day of the gift, you have two bases. You use the donor's basis to figure a gain and the lower date-of-gift value to figure a loss, and if the sale price lands between the two, Publication 551 says "you have neither gain nor loss."
What is the cost basis method?
It is the rule that decides which shares you are deemed to have sold when you own several lots of the same security. The three the IRS recognizes are specific identification, FIFO and average cost, and average cost is restricted to mutual funds and shares acquired through a dividend reinvestment plan. Your broker applies a default, usually FIFO, unless you tell it otherwise, and that default is a real cost.
Does a wash sale change my cost basis?
Yes, and this is the part people miss. The loss is not gone, it is moved. Publication 550 directs you to "add the disallowed loss to the cost of the new stock or securities", which raises the basis of the replacement shares by exactly the amount you were denied. The holding period of the sold shares carries over as well. You get the deduction later, when you finally sell the replacement without repurchasing, and the wash sale calculator works out how much of the loss is disallowed once partial buybacks are matched.
How is cost basis calculated for dividend reinvestment?
Each reinvestment is a separate purchase with its own date, price and basis. If a $400 dividend buys 3.7 shares at $108, that lot's basis is $400 and its clock starts that day. You already paid income tax on the dividend, so failing to record the lot means paying tax twice on the same money. Publication 550 adds that if a DRIP gives you stock at a discount, your basis is the full fair market value on the dividend payment date, not the discounted price.
What happens to cost basis in a stock split?
Nothing, in total. Publication 550 says to divide the adjusted basis of the old stock across the old and new shares, so a 4-for-1 split on 100 shares with a $12,000 basis leaves 400 shares with a $30 basis each and the same $12,000 overall. Your gain when you sell is unchanged. Reverse splits work the same way in the other direction.
What is the cost basis of RSUs and ESPP shares?
For restricted stock units, your basis is the fair market value on the vesting date, because that value was already added to your W-2 as wages. For an employee stock purchase plan, basis is the discounted price you paid plus any discount reported as ordinary income on your W-2. Brokers routinely report only the amount you paid out of pocket, which overstates the gain, so the compensation element usually has to be added back by hand on Form 8949.
What if I do not know my cost basis?
Start with the broker. Publication 550 notes that "generally, a covered security is a security you acquired after 2010", and for those your 1099-B must show basis. For older holdings the broker may show basis as unknown, and the burden is yours. Reconstruct it from old statements or confirmations, from the company transfer agent, or from historical prices on the purchase date. A basis of zero is the default the IRS will apply if you claim nothing, and that taxes the entire sale price.
Is cost basis the same as market value?
No. Cost basis is what you put in, market value is what the position is worth now, and the gap between them is your unrealized gain or loss. Basis only matters at the moment of a sale, gift or death, which is exactly why the timing of those events carries so much tax weight.
Keep reading
Where the basis number leads
Capital gains tax calculator
Once you have the basis, this prices the bill against the 2026 federal breakpoints, the 3.8% surtax and your state rate.
Tax loss harvesting rules
The 61-day wash sale window, what counts as substantially identical, and the IRA mistake that forfeits a loss permanently.
Tax loss harvesting software
Twelve US platforms compared on what they harvest, whether it runs on an algorithm or a manager's discretion, and what each charges.
Moving an account without losing basis
What survives an ACATS transfer, what gets liquidated, and why fractional shares are the part that generates a tax bill.
Direct indexing and lot-level harvesting
Owning the shares instead of the fund is what makes individual lots available to harvest in the first place.
Exchange funds
The IRC 721 route that carries your original basis into a diversified pool instead of realizing the gain.
Know what you paid, then decide what to hold
Build a weighted index of the stocks or crypto you want, backtest the construction against real history, and track it against the S&P 500. No brokerage, no trades, no money moved.