The basic formula for capital gains tax
Capital gains tax is calculated by taking the price you sold an asset for, subtracting what you paid for it, and then explore your tax rate to that profit. The difference between sale price and purchase price is your capital gain. Your tax rate depends on how long you held the asset and your income level.
Here is the simplest version: if you bought stock for $5,000 and sold it for $8,000, your capital gain is $3,000. You do not pay tax on the full $8,000 — only on the $3,000 profit. The tax you owe on that $3,000 depends on whether you held it for more or less than one year, and on your total taxable income for the year.
The IRS treats these two situations differently. Short-term capital gains (assets held one year or less) are taxed at your ordinary income tax rate. Long-term capital gains (assets held more than one year) are taxed at lower rates: 0%, 15%, or 20%, depending on your income bracket.
Key Takeaways
- Capital gain equals sale price minus purchase price, and you only pay tax on the gain, not the full sale amount.
- Short-term gains (held one year or less) are taxed as ordinary income; long-term gains (held over one year) use lower tax rates of 0%, 15%, or 20%.
- Your cost basis includes the original purchase price plus any fees, commissions, or improvements you made to the asset.
- You report capital gains on Schedule D (Form 1040) when you file your federal tax return.
- State and local taxes may also explore to capital gains, and the rules vary by location.
Understanding cost basis
Before you can calculate your gain, you need to know your cost basis — the true cost of what you bought. Most people think this is just the purchase price, but it includes more. Cost basis is the purchase price plus any fees, commissions, or costs you paid to buy the asset.
If you bought 100 shares of stock at $50 per share and paid a $25 commission, your cost basis is $5,025, not $5,000. If you inherited property and later sold it, your cost basis is usually the fair market value on the date of death, not what the original owner paid. If you made improvements to real estate — a new roof, a deck, major repairs — those costs add to your basis.
Keeping records of your cost basis is critical. Your brokerage or financial institution will send you a statement showing the basis they have on file, but you should verify it matches your records. If you cannot prove your basis, the IRS may assume your entire sale price is a gain.
How holding period changes your tax rate
The date you bought the asset and the date you sold it determine whether your gain is short-term or long-term. The rule is straightforward: if you held it for more than one year, it is long-term. One year or less is short-term.
Short-term capital gains are added to your ordinary income and taxed at your regular income tax bracket — which can be 10%, 12%, 22%, 24%, 32%, 35%, or 37% depending on your income. Long-term capital gains use a separate, lower rate schedule: 0% for lower incomes, 15% for middle incomes, and 20% for higher incomes. The income thresholds for these brackets change each year and depend on your filing status (single, married filing jointly, etc.).
For example, if you are single and your long-term capital gain pushes your total income into the 15% bracket, you pay 15% on that gain — not your ordinary income tax rate. This is why holding an asset past the one-year mark often saves money in taxes.
Working through a real example
Let us walk through a concrete scenario. You bought a rental property for $200,000 in 2022. You paid $3,000 in closing costs, so your cost basis is $203,000. You sold it in 2024 for $250,000.
Your capital gain is $250,000 minus $203,000 = $47,000. You held the property for more than one year, so this is a long-term gain. If you are single and your other income for 2024 puts you in the 15% long-term capital gains bracket, you owe 15% of $47,000 = $7,050 in federal capital gains tax (before any state or local taxes).
Now imagine you sold stock instead, and held it for only eight months. Your gain is $5,000. Because you held it less than one year, this is a short-term gain. If your ordinary income tax rate is 24%, you pay 24% of $5,000 = $1,200 in federal tax. If you had held it just four more months and may have access to for long-term treatment, you might pay only 15% = $750, saving $450.
Losses and how they offset gains
If you sell an asset for less than you paid for it, you have a capital loss. Capital losses can offset capital gains dollar-for-dollar. If you had $10,000 in long-term gains and $3,000 in long-term losses in the same year, your net long-term gain is $7,000, and you pay tax only on that $7,000.
You can also use capital losses to offset other types of income. 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, interest, etc.). Any losses beyond that $3,000 carry forward to future years and can be used to offset future gains or income.
This is why some investors deliberately sell losing positions late in the year — a practice called tax-loss harvesting. They realize the loss to offset gains elsewhere, then often repurchase the same or a similar investment. The IRS has a rule called the wash-sale rule that prevents you from buying the same security within 30 days before or after the sale, so timing matters.
Where to report capital gains on your tax return
When you file your federal income tax return, you report capital gains on Schedule D (Form 1040), titled "Capital Gains and Losses." You list each transaction separately: the asset, the date acquired, the date sold, the sale price, the cost basis, and the gain or loss. The form then totals your short-term and long-term gains and losses separately.
Your brokerage, mutual fund company, or other financial institution will send you a Form 1099-B (Proceeds from Broker and Barter Exchange Transactions) or Form 1099-S (Proceeds from Real Estate Transactions) showing the sale price. You use this form to fill out Schedule D. Keep your own records of cost basis and holding period, because the 1099 forms do not always include basis information.
If you have a net capital gain for the year, it flows to your main tax return (Form 1040) and is taxed according to the rates described above. If you have a net capital loss, you can deduct up to $3,000 against other income, with any excess carrying forward.
State and local capital gains taxes
Federal capital gains tax is only part of the picture. Many states and some cities also tax capital gains. The rules vary widely by location. Some states tax capital gains as ordinary income. Others have a separate capital gains tax rate. A few states do not tax capital gains at all.
Washington State, for example, has a 7% capital gains tax on long-term gains from the sale of certain securities and real estate, with some exemptions. New York taxes capital gains as ordinary income at rates up to 10.9%. California does the same at rates up to 13.3%. Other states have no capital gains tax. You need to check the rules for your state and any city where you live or own property.
If you live in one state but sell property in another, you may owe tax to both. Some states offer credits for taxes paid to other states to avoid double taxation, but the rules are complex. A tax professional in your state can advise you on your specific situation.
Frequently Asked Questions
Do I owe capital gains tax if I sell at a loss?
No, you do not owe tax on a loss. Instead, you can use the loss to offset capital gains or up to $3,000 of other income in the same year. Any unused loss carries forward to future years.
What if I inherited an asset and then sold it?
Your cost basis is usually the fair market value on the date the person died, not what they originally paid. This is called a "step-up in basis." If the asset appreciated between the death date and your sale, you owe tax only on gains after the death date, not on the appreciation that happened during the previous owner's lifetime.
How do I know if my gain is short-term or long-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 15, 2023, and sold on January 16, 2024, it is long-term.
Can I reduce my capital gains tax by donating the asset to charity instead of selling it?
Yes. If you donate appreciated securities or property directly to a may have access to charity, you avoid the capital gains tax entirely and can deduct the fair market value of the donation. This works only if you donate the asset itself, not the proceeds from a sale.
What records do I need to keep?
Keep the purchase confirmation (showing date and price), the sale confirmation (showing date and price), and any receipts for fees, commissions, or improvements. Keep these records for at least three years after you file your return, though the IRS can go back longer in some cases.