You pay capital gains tax when you sell a stock for more than you paid for it, and the tax is due in the year you sell
Capital gains tax is not charged while you own the stock. It only becomes due when you sell and lock in a profit. The IRS taxes the difference between what you paid (your cost basis) and what you received when you sold. You report this on your tax return for the year the sale happened, and you owe the tax by April 15 of the following year.
The amount you owe depends on two things: how much profit you made, and how long you held the stock before selling. If you held it for one year or less, the profit is taxed as ordinary income at your regular tax rate. If you held it for more than one year, it gets a lower rate called the long-term capital gains rate, which ranges from 0% to 20% depending on your income.
Key Takeaways
- Capital gains tax is owed only when you sell a stock, not while you own it or when it gains value.
- Short-term gains (stocks held one year or less) are taxed at your ordinary income tax rate, which is higher than long-term rates.
- Long-term gains (stocks held more than one year) are taxed at 0%, 15%, or 20% depending on your total income for the year.
- You report the sale on Schedule D of your tax return and owe the tax by April 15 of the year after you sold.
- If you sell at a loss, you can use that loss to reduce other capital gains or up to $3,000 of ordinary income in the same year.
How the holding period changes your tax rate
The length of time you own a stock before selling it determines which tax rate applies. This is measured from the date you bought it to the date you sold it. If you sell within 12 months, the gain is short-term. If you sell after 12 months have passed, the gain is long-term.
Short-term capital gains are added to your other income and taxed at your regular tax bracket. If you earn $60,000 a year and have a $10,000 short-term gain, you are taxed on $70,000 total. Long-term gains are taxed separately at lower rates: 0% if your income is below a certain threshold (which varies by filing status), 15% for most middle-income earners, and 20% for high earners. These thresholds change each year.
The difference matters. A $10,000 short-term gain for someone in the 24% tax bracket costs $2,400. The same gain taxed as long-term at 15% costs $1,500. Holding the stock an extra few weeks or months to cross the one-year mark can save hundreds or thousands in tax.
What counts as your cost basis
Your cost basis is what you paid for the stock, including any fees or commissions. If you bought 100 shares at $50 per share and paid a $10 commission, your total cost basis is $5,010, or $50.10 per share. When you sell, you subtract this from the sale price to find your gain or loss.
If you received the stock as a gift, your cost basis is usually what the person who gave it to you paid, not the value when you received it. If you inherited the stock, your cost basis is stepped up to the market value on the date of death, which often means you owe little or no tax if you sell soon after inheriting.
If you bought the same stock multiple times at different prices and sold only some of it, you need to track which shares you sold. The IRS assumes you sold the oldest shares first (called FIFO, or first-in-first-out) unless you tell your broker otherwise. Some brokers let you specify which lot you are selling, which can lower your tax if you choose the shares with the highest cost basis.
Reporting the sale on your tax return
You report stock sales on Schedule D, which is part of Form 1040. Your broker sends you a Form 1099-B in January or February showing every sale you made in the previous year, including the date bought, date sold, proceeds, and cost basis. You use this form to fill out Schedule D.
On Schedule D, you list each sale separately or in groups, depending on the form's layout. You calculate the gain or loss for each sale (proceeds minus cost basis) and add them up. Short-term gains and losses go in one section; long-term gains and losses go in another. If your total long-term gains exceed your long-term losses, that net gain is taxed at the long-term rate. If you have losses that exceed gains, you can deduct up to $3,000 of the excess against your ordinary income in that year, and carry forward any remaining loss to future years.
The deadline to report is April 15 of the year after the sale. If you file an extension, you have until October 15, but the tax is still due by April 15 unless you have already paid it through estimated tax payments or withholding.
Estimated tax payments if you sell during the year
If you sell a stock and owe a large capital gain, you may owe estimated tax payments before April 15. This is especially true if you do not have an employer withholding taxes from your paycheck. Estimated payments are due on April 15, June 15, September 15, and January 15.
You are not required to make estimated payments, but if you do not pay enough tax throughout the year, you may owe a penalty when you file. The penalty is small, but it adds up if you owe a lot of tax. To avoid it, you can either make estimated payments based on what you expect to owe, or you can wait and pay the full amount when you file your return, as long as you do not owe more than $1,000 in unpaid tax.
Using losses to reduce your tax bill
If you sell a stock for less than you paid, you have a capital loss. You can use this loss to cancel out capital gains from other sales in the same year. If you sold one stock for a $5,000 gain and another for a $3,000 loss, your net gain is $2,000, and you owe tax only on that $2,000.
If your losses exceed your gains in a year, you can deduct up to $3,000 of the excess against your ordinary income (wages, salary, interest, and so on). If your total loss is more than $3,000, you carry the rest forward to future years and use it to offset gains or income in those years. This carryforward has no time limit; you can use it years or decades later.
Some investors deliberately sell losing stocks at the end of the year to offset gains and reduce their tax bill. This is called tax-loss harvesting. The IRS has a rule called the wash-sale rule that prevents you from buying the same stock back within 30 days before or after the sale, or you lose the tax benefit of the loss. The rule applies to substantially identical securities, so buying a similar but not identical stock is usually allowed.
State and local taxes on capital gains
Most states tax capital gains as ordinary income at your state tax rate. A few states do not tax capital gains at all (including Florida, Texas, and Wyoming). A few others tax capital gains at a lower rate than ordinary income or only on gains above a certain amount. New York City and a handful of other cities also tax capital gains.
You report state and local capital gains tax on your state return, which usually mirrors your federal Schedule D. The rules for holding periods and cost basis are the same. If you moved to a different state during the year you sold, you may owe tax to both states, though most states offer a credit for taxes paid to another state to prevent double taxation.
Frequently Asked Questions
Do I owe capital gains tax if the stock is in a retirement account like a 401(k) or IRA?
No. Sales inside a 401(k), traditional IRA, or Roth IRA do not trigger capital gains tax. You can buy and sell stocks within these accounts without owing tax on the gains. With a traditional IRA or 401(k), you owe tax when you withdraw the money in retirement. With a Roth IRA, you owe no tax on withdrawals if you follow the rules.
What if I sold stock at a loss and want to buy it back?
You can buy it back, but if you buy it within 30 days before or after the sale, the wash-sale rule cancels the tax loss. The 30-day window runs from 30 days before the sale to 30 days after. If you wait 31 days, you can claim the loss and buy the stock back without penalty.
Do I owe capital gains tax if I have not sold the stock yet?
No. Tax is owed only when you sell. If a stock you own has doubled in value but you have not sold it, you owe no tax. You will owe tax only if and when you sell it for a profit.
What if my broker made a mistake on the 1099-B form?
Contact your broker and ask for a corrected form. Brokers sometimes report the wrong cost basis or sale date. Once you have the corrected 1099-B, file an amended return (Form 1040-X) if you already filed. The IRS matches your return to the 1099-B, so the numbers need to match.
Can I deduct the cost of a financial advisor who helped me decide when to sell?
Investment advisory fees are no longer deductible for most taxpayers. Before 2018, you could deduct them as a miscellaneous deduction, but that deduction was suspended. Some self-employed traders may be able to deduct advisory fees as a business expense, but this is rare and requires specific circumstances.