The Basic Formula for Capital Gains
Capital gains tax is calculated by subtracting what you paid for an asset from what you sold it for. That difference is your capital gain. You then apply the tax rate that matches your income level and how long you held the asset.
The formula is straightforward: Sale Price minus Purchase Price equals Capital Gain. If you bought stock for $5,000 and sold it for $8,000, your capital gain is $3,000. That $3,000 is what gets taxed, not the full $8,000 sale price.
The tax you owe depends on two things: your total income for the year and whether you held the asset for more than one year. Long-term gains (held over one year) are taxed at lower rates than short-term gains (held one year or less). Short-term gains are taxed as ordinary income, using the same rates as wages or salary.
Key Takeaways
- Your capital gain is the sale price minus what you originally paid, and only that gain is taxed.
- Long-term capital gains (assets held over one year) are taxed at 0%, 15%, or 20% depending on your income; short-term gains use your regular income tax rate.
- You must track your original purchase price, sale price, and the date you bought and sold the asset to calculate what you owe.
- If you sold at a loss, you can use that loss to reduce gains from other sales or up to $3,000 of ordinary income in the same year.
- State income tax may also apply to capital gains on top of federal tax, and the rate varies by state.
Long-Term vs. Short-Term Capital Gains Rates
The tax rate you pay depends on how long you owned the asset. If you held it for more than one year before selling, it is a long-term capital gain. The IRS taxes these at preferential rates: 0%, 15%, or 20%, depending on your filing status and total income for the year.
If you held the asset for one year or less, it is a short-term capital gain. The IRS taxes these as ordinary income, meaning you pay the same rate as you would on wages. For 2024, that ranges from 10% to 37% depending on your tax bracket.
The difference can be substantial. Suppose you made a $10,000 short-term gain and your tax bracket is 24%. You would owe $2,400 in federal tax. The same $10,000 as a long-term gain might be taxed at 15%, costing you $1,500. Holding an asset just a few months longer can save you hundreds or thousands in tax.
What Counts as Your Cost Basis
Cost basis is what you paid for the asset, including fees and commissions. If you bought 100 shares of stock at $50 per share and paid a $25 broker commission, your cost basis is $5,025 (not $5,000). The commission counts because it is part of what you paid to acquire the asset.
For inherited assets, the cost basis is usually reset to the market value on the date of death, not what the original owner paid. This is called a "step-up in basis." If your parent bought stock for $10,000 and it was worth $50,000 when they died, your cost basis becomes $50,000. If you sell it immediately for $50,000, you owe no capital gains tax.
For real estate, cost basis includes the purchase price plus the cost of improvements (a new roof, addition, or major renovation). It does not include maintenance or repairs. If you bought a house for $300,000 and spent $50,000 on a new kitchen and bathroom, your basis is $350,000.
Calculating Gains When You Sell in Pieces
If you own multiple shares or units of the same asset and sell only some of them, you need to track which ones you sold. The IRS allows three methods: specific identification, first-in-first-out (FIFO), or average cost.
Specific identification means you choose which shares to sell. If you bought 100 shares at $10 each and 100 shares at $20 each, and you want to minimize your gain, you can specify that you are selling the shares you bought at $20. This method requires written documentation to your broker before the sale.
First-in-first-out (FIFO) assumes you sell the oldest shares first. If you bought shares in 2020 at $10 and in 2023 at $20, FIFO assumes you sold the 2020 shares first. This often creates the largest gain because older shares are usually cheaper. Average cost splits the difference: you add up what you paid for all shares and divide by the number of shares to get an average price per share.
Using Capital Losses to Reduce Your Tax
If you sold an asset for less than you paid, you have a capital loss. You can use losses to offset gains from other sales in the same year. If you had a $5,000 gain on one stock and a $3,000 loss on another, your net gain is $2,000, and you only pay tax on $2,000.
If your losses exceed your gains in a year, you can deduct up to $3,000 of the excess loss against ordinary income (wages, salary, interest). If your total loss is $8,000 and your gains are $2,000, you have a $6,000 net loss. You can deduct $3,000 against ordinary income this year. The remaining $3,000 carries forward to next year, where you can deduct another $3,000, and so on until the loss is used up.
There is one restriction: the wash-sale rule. If you sell a stock at a loss and buy the same or substantially identical stock within 30 days before or after the sale, the IRS disallows the loss. The loss is added to the cost basis of the new shares instead. This rule prevents people from selling for a tax deduction and immediately buying back the same investment.
State and Local Taxes on Capital Gains
Federal capital gains tax is only part of what you owe. Most states also tax capital gains as income. The state rate varies widely: some states have no capital gains tax, others tax it at their regular income tax rate (which can be 10% or higher), and a few have a separate capital gains tax.
California, for example, taxes long-term capital gains as ordinary income at rates up to 13.3%. New York taxes them at rates up to 10.9%. Washington and Texas have no state income tax at all. If you live in a state with high income tax and sell a large asset, state tax can add significantly to your federal bill.
Some cities also impose local income tax on capital gains. New York City residents, for instance, pay city income tax on top of state and federal tax. Check your state and local tax authority website to find the rate that applies to you.
Reporting Capital Gains on Your Tax Return
You report capital gains on Form 8949 (Sales of Capital Assets) and then transfer the totals to Schedule D (Capital Gains and Losses). Schedule D is where you separate long-term gains from short-term gains and calculate your net gain or loss for the year.
Your broker sends you a Form 1099-B in January showing all sales you made during the previous year. This form includes the sale date, sale price, and sometimes the cost basis (though brokers do not always have accurate basis information, especially for older purchases or inherited assets). You use this form to fill out Form 8949.
If you have a large number of transactions, you may be able to attach a statement instead of listing each one individually. Keep your own records of purchase dates, purchase prices, sale dates, and sale prices. If the IRS questions your return, you will need to show documentation.
Frequently Asked Questions
Do I have to pay capital gains tax if I reinvest the money?
Yes. The tax is based on the gain itself, not on what you do with the money afterward. If you sold stock for a $10,000 gain and immediately bought different stock with the proceeds, you still owe tax on the $10,000 gain. Reinvesting does not defer or eliminate the tax.
What if I sold an asset at a loss and never bought it back?
You can use the loss to offset capital gains from other sales in the same year. If you have no gains to offset, you can deduct up to $3,000 of the loss against wages or other ordinary income. Any loss beyond $3,000 carries forward to future years.
How do I know if my gain is long-term or short-term?
Count the days from the purchase date to the sale date. If it is more than one year, it is long-term. The IRS counts the purchase date as day zero, so if you bought on January 1, 2023, and sold on January 2, 2024, that is long-term. If you sold on January 1, 2024, it is short-term.
Can I deduct investment losses from my paycheck?
Only up to $3,000 per year. If your capital losses exceed your gains by more than $3,000, you can deduct $3,000 against your wages or other income this year. The remaining loss carries forward to next year, where you can again deduct up to $3,000.
What happens if I inherited stock and then sold it?
Your cost basis is the market value on the date the person died, not what they originally paid. If the stock was worth $50,000 when you inherited it and you sold it for $52,000, your gain is $2,000. If you sold it for $50,000, you have no gain and owe no tax.