Capital gains tax is the tax you pay on profit when you sell an investment for more than you paid for it
When you sell a stock, bond, mutual fund, real estate, or other investment at a profit, the IRS taxes that profit. The profit itself—not the full sale price—is what gets taxed. This profit is called a capital gain. The tax rate depends on how long you held the investment and your income level. Most people pay either 0%, 15%, or 20% on long-term gains (investments held over one year), or ordinary income tax rates on short-term gains (held one year or less).
The math is straightforward: sale price minus what you originally paid equals your gain. But the IRS has specific rules about what counts as your "original cost," how to handle multiple purchases of the same investment, and when you can reduce or avoid the tax altogether. Understanding these rules keeps you from overpaying or underpaying.
Key Takeaways
- Capital gain equals the sale price minus your original purchase price, and you only pay tax on the gain, not the full amount you received.
- Long-term gains (held over one year) are taxed at 0%, 15%, or 20% depending on your total income; short-term gains are taxed as ordinary income at your regular tax rate.
- Your broker sends you a Form 1099-B showing the sale price, and you must report the original cost yourself unless your broker tracked it.
- You can reduce capital gains by using the "highest cost" method to identify which shares you sold, or by offsetting gains with losses from other investments.
The basic formula: sale price minus cost basis
Cost basis is what you paid for the investment, including any fees or commissions. If you bought 100 shares of stock at $50 per share and paid a $10 commission, your cost basis is $5,010 (not $5,000). When you sell those shares for $60 each and pay a $10 commission to sell, your sale proceeds are $5,990. Your capital gain is $5,990 minus $5,010, which equals $980.
If you bought the investment over time in multiple purchases at different prices, you need to track which shares you sold. If you bought 50 shares at $40 and 50 shares at $60, and you sold 50 shares for $70 each, your gain depends on which batch you sold. This is where the IRS lets you choose a method to identify which shares left your account.
Keep records of every purchase: the date, number of shares, price per share, and any fees. Your broker will have this information, but you are responsible for calculating and reporting the cost basis on your tax return. If you cannot find the records, the IRS may assume your cost basis is zero, meaning you owe tax on the entire sale price.
Long-term versus short-term: how holding time changes your tax rate
A long-term capital gain is profit from an investment you held for more than one year. A short-term capital gain is profit from an investment you held for one year or less. The holding period starts the day after you buy and ends the day you sell. If you bought on January 15 and sold on January 16 of the next year, that is long-term.
Long-term gains get preferential tax rates: 0%, 15%, or 20%, depending on your total taxable income for the year. Short-term gains are taxed at your ordinary income tax rate, which can be as high as 37%. This difference is substantial. A $10,000 short-term gain could cost you $3,700 in federal tax if you are in the top bracket; the same gain held long-term might cost you $2,000.
The IRS does not automatically know your holding period. You must report it on your tax return. Your broker's Form 1099-B will show the sale date, but you must enter the purchase date and calculate whether the gain is long-term or short-term.
What your broker reports and what you must add
Your broker sends you a Form 1099-B after the year ends, showing every sale you made: the date sold, number of shares, sale price, and gross proceeds. This form goes to the IRS, so the IRS knows you sold something. However, the 1099-B often does not include your cost basis—the price you paid—unless your broker has been holding the investment since 2011 or later and has tracked it in their system.
If your cost basis is missing from the 1099-B, you must find it yourself and report it on your tax return. You can look at your old statements, trade confirmations, or account history. If you cannot find it, contact your broker and ask for a cost basis report. Many brokers offer this as a free service and can generate a report going back years.
When you file your return, you report the sale on Schedule D (Form 1040). You enter the sale price from the 1099-B and the cost basis you found. The difference is your gain or loss. If you have multiple sales, you list each one separately and add them up.
Choosing which shares to sell when you own multiple batches
If you bought the same stock or fund at different times and prices, and you sold only part of your holdings, the IRS lets you choose which batch of shares you sold. This choice can save you thousands in taxes. The most common method is highest cost basis: you identify the shares with the highest purchase price as the ones you sold, which minimizes your gain.
Example: You own 100 shares bought at $40 each and 100 shares bought at $60 each. You sell 100 shares for $80 each. If you use the highest cost method, you identify the $60 shares as sold, giving you a gain of $2,000 (100 × $20). If you used the lowest cost method, you would identify the $40 shares as sold, giving you a gain of $4,000 (100 × $40)—double the tax.
To use a specific method, you must tell your broker in writing at the time of sale which shares to sell. If you do not specify, the IRS assumes you used the first-in, first-out (FIFO) method: the oldest shares are sold first. This is often the worst outcome for your taxes. Contact your broker before you sell and ask how to specify a cost basis method.
Using losses to reduce gains and taxable income
If you sold an investment at a loss, you can use that loss to offset capital gains from other investments. If you have $5,000 in gains and $3,000 in losses, your net capital gain is $2,000, and you only pay tax on $2,000. This is called loss harvesting and is a common tax strategy.
If your losses exceed your gains in a year, you can deduct up to $3,000 of the excess loss against your ordinary income (wages, salary, interest). Any loss beyond $3,000 carries forward to future years and can be used to offset future gains or income. This means a large loss in one year can reduce your taxes for years to come.
The IRS has a rule called the wash sale rule: if you sell an investment at a loss and buy the same or a substantially identical investment within 30 days before or after the sale, you cannot claim the loss. The loss is added to the cost basis of the new purchase instead. This rule prevents people from selling at a loss for the tax break and immediately buying back the same thing.
State and local taxes on capital gains
Most states tax capital gains as ordinary income, meaning you pay your state income tax rate on top of federal tax. A few states—including Alaska, Florida, Nevada, South Dakota, Tennessee, Texas, Washington, and Wyoming—do not have an income tax at all. California, New York, and other high-tax states can add 10% or more to your federal bill.
Some states have special capital gains taxes separate from income tax. Washington State, for example, taxes long-term capital gains on stocks and certain other investments at a flat 7% rate. New York has proposed a similar tax. If you live in a state with a capital gains tax, you must report the same gain to both the state and the IRS.
If you moved during the year you sold an investment, you may owe tax to both your old state and your new state. Some states have reciprocal agreements, but most do not. Check your state's tax authority website or speak with a tax preparer if you moved or lived in more than one state during the year of the sale.
Frequently Asked Questions
Do I have to pay capital gains tax if I reinvest the money?
Yes. The tax is based on the profit you made, not on what you do with the money afterward. Whether you spend it, save it, or buy another investment, you owe tax on the gain. Reinvesting does not defer or eliminate the tax.
What if I inherited an investment—do I owe capital gains tax when I sell it?
Inherited investments receive a stepped-up basis. Your cost basis becomes the market value on the date of death, not what the person who died originally paid. If the investment was worth $100,000 when inherited and you sell it for $105,000, your gain is only $5,000, not the full $105,000. This is a major tax benefit of inheritance.
How do I report capital gains if I use a tax software or hire a preparer?
If you use tax software, you enter the information from your 1099-B forms into the capital gains section. The software calculates long-term versus short-term and applies the correct tax rates. If you hire a preparer, bring all your 1099-B forms and your cost basis records. The preparer will handle the calculations and file Schedule D for you.
Can I deduct investment losses if I did not sell the investment?
No. The loss must be realized—meaning you actually sold the investment—before you can claim it on your taxes. A decline in value that you have not sold is an unrealized loss and cannot be deducted. You must sell to lock in the loss.
What if my cost basis is zero because I cannot find old records?
The IRS will assume your entire sale price is a gain. Contact your broker and ask for a historical cost basis report; most can provide records going back many years. If your broker cannot help, you may be able to reconstruct the cost from old statements, bank records, or brokerage confirmations. If you truly cannot find the records, you may be able to file an amended return once you locate them, even years later.