FIFO, LIFO, and HIFO: How Your Cost Basis Method Changes Your Tax Bill
Updated November 14, 2026
When you sell part of a position you bought at different times and prices, the lots you sell decide your gain and your tax. This guide explains the main cost basis methods and the tradeoffs between them.
Key takeaways
- The cost basis method decides which purchase lots count as sold, which changes your gain, loss, and tax.
- FIFO sells oldest first, LIFO sells newest first, and HIFO sells highest cost first.
- A method that lowers your tax now can leave lower-basis lots that create bigger gains later.
- You generally must identify the lots when you sell and keep records, or your broker’s default applies.
- Crypto basis is tracked separately for each wallet or account.
Why the method matters
If you buy the same investment several times at different prices, each purchase is its own lot, with its own cost basis and its own purchase date. When you sell only part of your position, the lots you say you sold decide your gain or loss, and whether it’s short-term or long-term. The rule for picking lots is your cost basis method.
An example. You bought 10 shares of a stock three times: in January 2024 at $50, in March 2025 at $120, and in March 2026 at $90. In November 2026 you sell 10 shares at $110, for $1,100. Here is what each method does, assuming a 24% short-term rate and a 15% long-term rate:
| Method | Lot sold | Cost basis | Gain or loss | Term | Estimated tax |
|---|---|---|---|---|---|
| FIFO | January 2024 lot | $500 | $600 gain | Long-term | $90 |
| LIFO | March 2026 lot | $900 | $200 gain | Short-term | $48 |
| HIFO | March 2025 lot | $1,200 | $100 loss | Long-term | $0 |
Same sale, same price, three different results, from a $600 gain to a $100 loss. You can run your own numbers in our cost basis comparison.
The main methods
- FIFO (first in, first out): you sell your oldest lots first. It’s the default for stocks and for crypto when you don’t choose otherwise. Older lots are often long-term and often have the lowest basis, so FIFO can produce larger gains.
- LIFO (last in, first out): you sell your newest lots first. These tend to be short-term, which can mean a higher tax rate even if the gain is small.
- HIFO (highest in, first out): you sell your highest-cost lots first. This usually produces the smallest gain or the biggest loss on that sale.
- Average cost: available for mutual funds, it gives every share the same average basis, which keeps things simple.
- Specific identification: you pick exactly which lots to sell. LIFO and HIFO are really just ways of doing this.
What the rules require
- Stocks and ETFs: if you don’t identify specific shares, FIFO applies. Many brokers let you choose a different method, or specific lots, but you generally must do it before the trade settles. Your broker sets a default method, so check it.
- Mutual funds: you can use average cost, and you generally need to tell the fund or broker if you want a different method.
- Crypto: you can identify specific units, but you need records that show which ones, kept at the time of the sale. Since 2025 you also track cost basis separately for each wallet or account. Without proper identification, FIFO within that wallet applies.
The common thread is documentation. If you can’t show which lots you sold, the default method applies.
The tradeoffs
- Lower tax now can mean higher tax later. If HIFO sells your high-basis lots, you keep the low-basis lots, which carry bigger gains for the future. You’re often deferring tax, not avoiding it.
- Short-term vs. long-term matters as much as size. A small short-term gain taxed at 24% can cost more than a bigger long-term gain taxed at 15%. See short-term vs. long-term capital gains.
- Your bracket can change. If you expect higher income later, realizing more gain now, when your rate is lower, can make sense.
- It only matters in taxable accounts. Trades inside an IRA or 401(k) aren’t taxed as they happen.
- Wash sales can interfere. If you sell at a loss and rebuy, the loss may be disallowed. See the wash sale rule explained.
Questions to ask before you choose
- Which lots are short-term and which are long-term?
- Do I have losses I could use, or gains I’d like to avoid?
- What’s my tax rate this year compared with the future?
- Does my broker or exchange let me pick lots, and by when?
- Can I document the choice?
A common approach people discuss is to sell long-term lots with the highest basis first, which tends to keep the gain small without triggering short-term treatment. It isn’t right for everyone, so run the numbers and, if the amounts are large, talk to a tax professional.
How this works for crypto
The same methods apply to crypto, with the per-wallet rule on top. A sale from one exchange can’t use lots bought in another wallet. Our crypto trade log matches sales to lots using FIFO within each wallet and shows each piece as short-term or long-term, and you can compare methods on a specific sale with the cost basis tool. For the full picture, read how crypto is taxed.
Common mistakes
- Assuming your broker will pick the most tax-efficient lots. The default is usually FIFO.
- Choosing a method after the trade has already settled.
- Not keeping records that identify the lots.
- Ignoring holding periods and focusing only on the size of the gain.
- Mixing lots from different wallets or accounts.
Frequently asked questions
Can I change methods each time I sell?
For stocks and crypto, you can generally choose a method, or specific lots, for each sale, as long as you identify the lots at the time of sale and keep records. Mutual fund average cost has its own rules for switching, so ask your provider.
Does the method matter inside an IRA?
No. Trades inside an IRA or 401(k) aren’t taxed as they happen, so the lots you sell don’t change your tax bill there.
Which method is best?
There’s no single best method. It depends on your lots, your tax bracket, and your plans. The method that gives the lowest tax today isn’t always the lowest over several years.
Can I use HIFO for crypto?
Yes, if you can identify the specific units you sold and document it. Without that, FIFO within the wallet or account applies.
Tools that can help
- Cost basis method comparisonCompare FIFO, LIFO, and highest-cost-first on the same sale.
- Crypto trade logRecord buys and sells and see realized gains by wallet.
- Long-term capital gains calculatorEstimate federal tax on a gain from an investment held over a year.
- Crypto tax calculatorEstimate US tax on selling crypto at a gain.
Keep reading
- The wash sale rule explainedThe 30-day rule for stock losses, how it works, and whether it applies to crypto.
- Short-term vs. long-term capital gainsHow the one-year line changes your tax rate, with 2026 brackets and examples.
- How crypto is taxed in the USWhat counts as a taxable event, how to figure gains, and what to report.
This article is for education only and isn’t financial, investment, tax, or legal advice. Tax rules and limits change, so check IRS guidance or a qualified tax professional about your situation. See our disclaimer.