When you sell stock at a profit, the IRS taxes how stock sales are taxed under one of two rate schedules depending on how long you held the shares. Sell within a year of buying and the gain is short-term, taxed at your ordinary income rate of up to 37%. Hold longer than a year and the gain qualifies for long-term rates of 0%, 15%, or 20%. High earners may owe an extra 3.8% surtax. Losses can offset gains and, within limits, ordinary income. What you actually owe comes down to your holding period, your total taxable income, and how you figure your cost basis.
The One-Year Holding Period
The IRS splits stock gains into two categories based on a single calendar threshold: one year.1Internal Revenue Service. Topic No. 409, Capital Gains and Losses Shares held for one year or less produce a short-term gain when sold. Shares held for more than one year produce a long-term gain. One extra day can shift a sale from the top ordinary bracket to the 0% long-term bracket, so the calendar matters.
Your holding period starts the day after you buy and ends on the day you sell. Shares acquired through less obvious routes, such as stock splits, reinvested dividends, or employer equity grants, can each have their own acquisition dates, so verify what your brokerage records show before assuming a lot has crossed the one-year line.
Figuring the Taxable Gain
Your taxable gain is what you received from the sale minus what you paid to acquire the shares. The IRS calls what you paid the “cost basis,” and it includes the purchase price plus any commissions or transfer fees.2Internal Revenue Service. Publication 551 (12/2025), Basis of Assets The proceeds side works the same way: total sale price minus any fees the broker charged to execute the trade. If the proceeds come in below your basis, you have a capital loss instead.
Adjustments can complicate things. A disallowed wash-sale loss gets added to the basis of your replacement shares. Stock splits, mergers, and return-of-capital distributions all change your adjusted basis over time. Most brokerages track these automatically, but the numbers are worth checking against your own records before filing.
Which Shares Did You Sell?
When you’ve bought the same stock at different prices and sell only some of it, you need a method for identifying which shares went out the door. The default at most brokerages is first-in, first-out (FIFO), which assumes the oldest shares sold first. Because oldest shares have usually appreciated the most, FIFO tends to produce the largest taxable gain.
Specific identification gives you more control. You tell the broker exactly which lot to sell, such as the 50 shares purchased on March 3, 2024, at $62. That lets you pick higher-cost lots to shrink the gain, or lots that have crossed the one-year line to lock in long-term rates. You have to designate the shares at the time of sale, not after.
A third option, average cost, divides your total investment by the total number of shares.3Internal Revenue Service. Mutual Funds (Costs, Distributions, etc.) 1 It’s most commonly used for mutual funds and is the simplest to apply, but it takes away your ability to pick and choose.
2026 Federal Rates
Short-Term Gains
Short-term gains get no special treatment. They’re taxed at the same rates as your wages and other ordinary income, ranging from 10% to 37% depending on taxable income and filing status.1Internal Revenue Service. Topic No. 409, Capital Gains and Losses Frequent traders feel this most, because rapid buying and selling almost always generates short-term gains.
Long-Term Gains
Long-term gains fall into 0%, 15%, or 20% brackets depending on where your taxable income lands.1Internal Revenue Service. Topic No. 409, Capital Gains and Losses For 2026:
- Single filers pay 0% on taxable income up to $49,450, 15% from $49,451 to $545,500, and 20% above $545,500.
- Married filing jointly: 0% up to $98,900, 15% from $98,901 to $613,700, 20% above $613,700.
- Head of household: 0% up to $66,200, 15% from $66,201 to $579,600, 20% above $579,600.
The 0% bracket is worth watching. If your total taxable income stays inside it, your long-term gains come out federally tax-free. Retirees living mostly on Social Security, or anyone with a lower-income year, sometimes sell appreciated stock deliberately to harvest gains at that rate.
The 3.8% Surtax
High earners face an additional 3.8% net investment income tax on capital gains and other investment income. It kicks in when modified adjusted gross income exceeds $200,000 for single filers or $250,000 for married couples filing jointly.4Office of the Law Revision Counsel. 26 USC 1411 – Imposition of Tax Those thresholds aren’t indexed to inflation, so more taxpayers cross them each year. Combined with the 20% top long-term rate, the maximum federal rate on long-term stock gains reaches 23.8%.
When You Sell at a Loss
A capital loss offsets capital gains dollar for dollar. If losses exceed gains for the year, you can deduct up to $3,000 of the excess against ordinary income ($1,500 if married filing separately).5Office of the Law Revision Counsel. 26 USC 1211 – Limitation on Capital Losses That $3,000 cap is a fixed statutory number that hasn’t been adjusted for inflation since it was set decades ago.
Anything beyond the $3,000 carries forward indefinitely and keeps its short-term or long-term character in future years.6Office of the Law Revision Counsel. 26 USC 1212 – Capital Loss Carrybacks and Carryovers A $25,000 loss with no gains to offset it becomes a $3,000 deduction this year and $22,000 to carry forward. You keep chipping away at it, $3,000 a year plus any future gains, until it’s used up. Tracking the carryover across years is your responsibility, not the IRS’s.
The Wash Sale Rule
You can’t sell a stock at a loss, buy it right back, and still claim the deduction. The wash sale rule disallows the loss if you purchase substantially identical shares within 30 days before or after the sale.7Office of the Law Revision Counsel. 26 USC 1091 – Loss From Wash Sales of Stock or Securities The 30-day window runs in both directions.
The loss isn’t gone forever. It gets added to the basis of the replacement shares and comes back to you when you eventually sell those. But if you were counting on the loss this tax year, a wash sale will spoil the plan. Brokerages flag most wash sales on your 1099-B, but their tracking can miss cross-account purchases, including buying the same stock in a different brokerage or in an IRA within the 30-day window.
Inherited and Gifted Shares
Stock you inherit generally gets a basis equal to the fair market value on the date the previous owner died, not what they originally paid.8Office of the Law Revision Counsel. 26 USC 1014 – Basis of Property Acquired From a Decedent This step-up can wipe out decades of unrealized appreciation. Shares a parent bought at $10 that were worth $100 on the date of death become $100-basis shares in your hands. Any gain on inherited stock is treated as long-term no matter how quickly you sell.
Gifted stock works differently. Your basis is generally the same as the donor’s, a rule called carryover basis.9Office of the Law Revision Counsel. 26 USC 1015 – Basis of Property Acquired by Gifts and Transfers in Trust Stock a friend bought at $20 and gave you carries a $20 basis, and you’ll owe tax on any appreciation above that when you sell. One exception: if fair market value at the time of the gift is lower than the donor’s basis, your basis for calculating a loss is that lower fair market value, so built-in losses can’t be shifted by gift.
Sales Inside Retirement Accounts Don’t Count
Everything above applies to taxable brokerage accounts. Selling stock inside a traditional IRA or 401(k) triggers no tax at all. There’s no capital gain, no 1099-B, and no Form 8949 entry. You owe tax only when you take money out of the account, and the withdrawal is taxed as ordinary income regardless of whether the growth inside came from stock gains, dividends, or interest. The preferential long-term rates do not apply to traditional retirement account withdrawals.
Roth IRAs and Roth 401(k)s go further. Sales inside the account are tax-free, and qualified withdrawals of both contributions and earnings come out tax-free too. The trade-off was funding the account with after-tax dollars in the first place.
State Taxes
Federal isn’t the whole picture. Most states tax capital gains as ordinary income, and combined state rates can add roughly 3% to over 13% on top of your federal bill. A handful of states have no income tax and no state-level capital gains tax as a result. Some states offer a preferential long-term rate; others don’t. Check your state’s tax agency for what applies to your situation.
Reporting and Paying
Your brokerage sends Form 1099-B after year-end listing every sale with the acquisition date, sale date, proceeds, and cost basis.10Internal Revenue Service. Form 1099-B – Proceeds From Broker and Barter Exchange Transactions (2026) The IRS gets the same copy, so what you report needs to match. If the reported basis is wrong (a common issue with transferred shares or older lots), you adjust it on your return rather than asking the broker to reissue the form.
Each sale gets reported on Form 8949, separating short-term from long-term transactions.11Internal Revenue Service. Instructions for Form 8949 (2025) The totals flow to Schedule D of your Form 1040, which calculates the net gain or loss.12Internal Revenue Service. 2025 Instructions for Form 8949 – Sales and Other Dispositions of Capital Assets Tax software handles most of this automatically once you import the 1099-B.
A big sale mid-year can leave you with a large tax bill the following April, and the IRS may add an underpayment penalty if you haven’t paid enough during the year. You generally avoid the penalty if you’ll owe less than $1,000 at filing, or if you’ve paid at least 90% of the current year’s tax or 100% of the prior year’s tax through withholding and estimated payments.13Internal Revenue Service. Estimated Taxes After a large sale, make an estimated payment by the next quarterly deadline (Form 1040-ES or the IRS online payment system) rather than waiting until April. This is the step most people skip after a windfall, and the penalty is entirely avoidable.