If you’ve ever sold a stock, a house, or any other asset for more than you paid, you already owe a version of this question: how capital gains tax works, and how much of your profit you actually get to keep. This guide walks through the formula, the 2026 brackets, and a full worked example so you can see exactly where the numbers come from.

How Capital Gains Tax Works: The Basic Formula
At the most basic level, how capital gains tax works comes down to one formula: sale price minus your cost basis equals your gain, and that gain is what gets taxed, not the full sale price.
Your cost basis is generally what you paid for the asset, plus certain costs like commissions or improvements. This matters because people often assume they owe tax on the entire amount they received, when in reality they only owe tax on the profit.
Short-Term vs Long-Term: How Capital Gains Tax Works Differently
This is the single biggest factor in how capital gains tax works: how long you held the asset. Sell within one year or less and the gain counts as short-term, taxed at your regular ordinary income rate, which runs from 10% up to 37% in 2026.
Hold the asset more than one year and the gain qualifies as long-term, taxed instead at the preferential 0%, 15%, or 20% federal rates, based on your total taxable income and filing status, per IRS Revenue Procedure 2025-32. That one extra day of holding can cut your tax bill significantly.
How Capital Gains Tax Works With a Real Example
Numbers make this easier to follow than rules alone. Say you’re a single filer with $70,000 in other taxable income for 2026, and you sell stock you held for two years.
You bought the stock for $10,000 and sold it for $25,000, for a $15,000 long-term gain.
How Capital Gains Tax Works Out in This Example
| Item | Amount |
|---|---|
| Sale price | $25,000 |
| Cost basis | $10,000 |
| Long-term capital gain | $15,000 |
| Other taxable income | $70,000 |
| Applicable rate | 15% |
| Capital gains tax owed | $2,250 |
Because your $70,000 in other income already sits above the 2026 single filer 0% threshold of $49,450, the entire $15,000 gain stacks on top of that income and lands in the 15% bracket, which runs up to $545,500 for single filers. Fifteen percent of $15,000 is $2,250, so that’s what you’d owe in federal capital gains tax on this sale.
How Capital Gains Tax Works on Investment Property
Real estate follows the same core rules, with a couple of extra wrinkles. Your cost basis includes the purchase price plus qualifying improvements, and depreciation you claimed on a rental property gets added back and taxed separately at a 25% recapture rate when you sell.
If the property is your primary home, Section 121 lets you exclude up to $250,000 of gain ($500,000 for married couples filing jointly) if you meet the ownership and use tests, which changes how capital gains tax works on that sale considerably.
How Capital Gains Tax Works With the 0% Bracket
One detail that surprises people is how capital gains tax works when your income is low enough. For 2026, single filers pay 0% federal tax on long-term gains that fall within the first $49,450 of taxable income, and married couples filing jointly get a $98,900 threshold.
Retirees or anyone with a lower income year can sometimes realize long-term gains and pay nothing in federal tax on them, simply by timing the sale for a year when total taxable income stays under that threshold.
Common Mistakes in How Capital Gains Tax Works
The most common mistake is assuming the capital gains rate applies to your entire income instead of just the gain itself, and just the portion of the gain that falls into each bracket. A single sale can straddle two rate bands, part taxed at 0% and the rest at 15%, for example.
Another common mistake is forgetting the 3.8% Net Investment Income Tax, which applies on top of the regular rate once your modified adjusted gross income passes $200,000 (single) or $250,000 (married filing jointly), per IRS guidance on NIIT.
What To Do Once You Understand How Capital Gains Tax Works
Once you know the mechanics, a few moves can meaningfully lower what you owe. Holding an asset past the one year mark to get long-term treatment is the simplest one, and tax-loss harvesting, selling a losing position to offset a gain, is another.
You can run your own how capital gains tax works numbers against your actual holdings with our Capital Gains Calculator, which walks through your cost basis, holding period, and income to show your estimated federal tax before you sell.
For larger gains, timing the sale across two tax years, or spreading it out, can also keep more of the gain in the 0% or 15% bracket instead of pushing into 20%.
Bottom Line
Understanding how capital gains tax works comes down to three things: your gain is sale price minus cost basis, your holding period decides which rate structure applies, and your total taxable income decides where in that structure you land.
This is for informational purposes only and isn’t financial, tax, or legal advice.
Raghu Shekar writes about personal finance, banking, Medicare, and retirement planning at SimpleUSAFinance. His goal is simple: break down the numbers people actually need — no jargon, no sales pitch — so readers can make their own decisions with confidence. When he’s not writing, he’s usually digging through the latest rate changes, tax brackets, or Medicare updates to keep the site’s calculators and guides current.