You sold some stock, flipped a rental property, or cashed out of crypto, and now you’re staring at your brokerage statement wondering how much of that profit Uncle Sam is going to take. The answer depends on a surprisingly long list of variables: how long you held the asset, your total taxable income, your filing status, and whether any special surcharges apply. A capital gains tax calculator can give you a fast estimate, but understanding the mechanics behind the math is what keeps you from overpaying — or getting blindsided by a bill in April.

Below is exactly how capital gains taxes work in 2026, how to calculate what you owe, and the legal strategies that can shrink your bill.

Short-Term vs. Long-Term: The Holding Period That Changes Everything

The IRS draws a hard line at one year. Sell an asset you’ve held for 12 months or less, and your profit is taxed as a short-term capital gain — meaning it’s added to your ordinary income and taxed at your marginal rate. Sell after holding for more than 12 months, and you qualify for the lower long-term capital gains rates. According to IRS Publication 550, the holding period starts the day after you acquire the asset and ends on the day you sell or dispose of it.

That one-day difference can be worth thousands of dollars. Suppose you bought 200 shares of a stock on March 1, 2025 and sold them on March 1, 2026. That’s exactly 12 months — which means short-term rates apply. If you’d waited until March 2 to sell, you’d cross into long-term territory and potentially cut your tax rate in half.

Short-term capital gains tax rates for 2026 mirror the ordinary income brackets. For a single filer, that means 10% on the first $11,925 of taxable income, scaling up to 37% on income above $626,350. If you’re already in the 32% bracket from your salary, your short-term gains get stacked on top and taxed at 32% or higher.

Long-term capital gains tax rates for 2026 are considerably friendlier. Most taxpayers fall into one of three brackets: 0%, 15%, or 20%. Single filers with taxable income up to roughly $48,350 pay 0%. Between $48,350 and $533,400, the rate is 15%. Above $533,400, it jumps to 20%. The IRS capital gains tax rates page has the current thresholds for all filing statuses.

The difference is stark. A $50,000 gain on a stock held for 11 months by someone in the 35% bracket costs $17,500 in federal tax. Hold it one more month, and at the 15% long-term rate, the bill drops to $7,500. That’s $10,000 saved by waiting 30 days.

How to Calculate Your Gain: Cost Basis, Adjustments, and the Details That Matter

Using a capital gains tax calculator starts with knowing your cost basis — the original price you paid for the asset, adjusted for certain expenses and events. This is where people make the most mistakes, and where the IRS is most likely to send you a notice.

Your cost basis is generally the purchase price plus any transaction fees. If you bought 100 shares at $50 per share and paid a $4.95 commission, your cost basis is $5,004.95. When you sell those shares for $80 each, your gain isn’t $3,000 — it’s $7,995.05 minus $5,004.95, or $2,990.10. The selling commission reduces your proceeds, too.

Adjusted cost basis accounts for events that occur between purchase and sale. Stock splits, reinvested dividends, return-of-capital distributions, and corporate mergers all change your basis. Reinvested dividends are the sneakiest: if you’ve been automatically reinvesting dividends for years, each reinvestment is a separate purchase with its own cost basis and holding period. Your brokerage’s 1099-B form should report cost basis for covered securities, but it’s worth double-checking, especially for assets purchased before 2011 when brokerages weren’t required to track basis.

For real estate, cost basis includes the purchase price, closing costs, and the cost of any capital improvements (a new roof, a kitchen renovation) but not routine maintenance. Depreciation recapture is a separate animal — if you claimed depreciation on a rental property, the IRS wants some of it back at a 25% rate when you sell. IRS Publication 523 covers the rules for selling your primary residence, including the $250,000/$500,000 exclusion that many homeowners can use to eliminate or reduce their taxable gain.

The wash sale rule is a trap for anyone who sells at a loss and then buys back the same or a “substantially identical” security within 30 days before or after the sale. The IRS disallows the loss entirely. You don’t lose it forever — the disallowed loss gets added to the cost basis of the replacement shares — but it prevents you from claiming the deduction in the current tax year. This 61-day window (30 days before, the sale day, 30 days after) catches more casual investors than you’d think, especially those with automated dividend reinvestment plans. The SEC’s investor bulletin on wash sales has a clear breakdown.

Net investment income tax (NIIT). If your modified adjusted gross income exceeds $200,000 (single) or $250,000 (married filing jointly), you’ll owe an additional 3.8% surtax on your investment income under the Affordable Care Act. This applies to both short-term and long-term capital gains, interest, dividends, rental income, and royalties. It’s not technically a capital gains tax, but it shows up on the same return and inflates your effective rate. A taxpayer in the 20% long-term bracket who also owes NIIT is actually paying 23.8% on their gains. Use IRS Form 8960 to calculate whether you’re subject to it.

Putting It All Together: Your Capital Gains Tax Calculation

Here’s a step-by-step framework you can use alongside any capital gains tax calculator to verify the output.

Step 1: Determine your gain or loss. For each asset you sold during the tax year, subtract the adjusted cost basis from the net sale proceeds (sale price minus commissions and fees). Categorize each result as short-term or long-term based on the holding period.

Step 2: Net your gains and losses within each category. Add up all your short-term gains and subtract all your short-term losses. Do the same for long-term. If you have a net loss in one category and a net gain in the other, offset them. A $5,000 short-term gain and a $3,000 long-term loss nets to a $2,000 short-term gain.

Step 3: Apply the appropriate tax rate. Short-term net gains are taxed at your ordinary income rate. Long-term net gains are taxed at 0%, 15%, or 20% depending on your taxable income.

Step 4: Check for the NIIT. If your MAGI exceeds the threshold, add 3.8% to your investment income.

Step 5: If you have a net capital loss, you can deduct up to $3,000 against your ordinary income ($1,500 if married filing separately). Any unused loss carries forward to future years indefinitely. This is reported on IRS Schedule D, which feeds into your Form 1040.

Take a quick example. Say you’re a single filer with $120,000 in salary income. During 2026, you sold Stock A for a $15,000 long-term gain and Stock B for a $4,000 short-term loss. Your net capital gain is $11,000 long-term ($15,000 minus $4,000, with the short-term loss offsetting the long-term gain). At your income level, the long-term rate is 15%. Federal capital gains tax: $1,650. No NIIT applies because your MAGI is under $200,000. Total damage: $1,650 on $11,000 in profit. That’s a 15% effective rate.

Strategies to Legally Reduce Your Capital Gains Tax Bill

The tax code isn’t just a set of rules. It’s a set of incentives. Here’s how to use them.

Tax-loss harvesting is the practice of selling losing investments to generate capital losses that offset your gains. If you have $20,000 in realized gains and $12,000 in unrealized losses sitting in your portfolio, selling those losers brings your taxable gain down to $8,000. The key is avoiding the wash sale rule — you can’t buy back the same security within 30 days. But you can buy a similar (not identical) fund to maintain your market exposure. Selling an S&P 500 index fund and buying a total stock market fund, for instance, keeps you invested in largely the same companies while staying on the right side of the rule.

Holding period management is the simplest strategy and the one most people overlook. If you’re sitting on a gain and you’re within a few weeks of the one-year mark, waiting to sell can cut your rate from 37% to 15% or 20%. Set a reminder. Don’t let impatience cost you five figures.

Qualified opportunity zones offer a tax benefit for rolling capital gains into designated economically distressed areas. You defer the gain, and if you hold the opportunity zone investment for at least 10 years, any appreciation on the new investment is tax-free. The program has been extended and modified several times since its creation in 2017, so check the IRS opportunity zone FAQ for current rules.

Charitable giving can eliminate capital gains entirely. If you donate appreciated stock directly to a qualified charity, you get a deduction for the full market value and pay zero capital gains tax on the appreciation. This only works if you itemize deductions, and there are AGI-based limits on how much you can deduct, but for someone holding highly appreciated stock, it’s one of the most tax-efficient ways to give.

Asset location matters for long-term tax efficiency. Holding assets that generate frequent taxable events (actively traded funds, REITs, bonds) in tax-advantaged accounts like IRAs and 401(k)s shields the gains from current taxation. Keep your buy-and-hold index funds in taxable accounts, where they generate fewer taxable events and qualify for long-term rates when you eventually sell.

Primary residence exclusion. If you’ve lived in your home for at least two of the last five years, you can exclude up to $250,000 of gain ($500,000 for married couples) from capital gains tax. This is one of the most generous provisions in the tax code, and it’s available every two years.

The bottom line with any capital gains tax calculator is this: the inputs matter as much as the output. Get your cost basis right, pay attention to holding periods, and plan your sales with tax consequences in mind. The difference between a well-timed sale and a careless one can be tens of thousands of dollars — money that stays in your pocket instead of going to the Treasury.

Frequently Asked Questions

What is the capital gains tax rate for 2026?

It depends on how long you held the asset. Short-term capital gains (assets held one year or less) are taxed at your ordinary income rate, which ranges from 10% to 37%. Long-term capital gains (held more than one year) are taxed at 0%, 15%, or 20%, depending on your taxable income. Single filers earning up to about $48,350 pay 0%, those between $48,350 and $533,400 pay 15%, and income above that threshold is taxed at 20%.

How do you calculate cost basis for stocks?

Your cost basis is generally the purchase price of the stock plus any transaction fees like commissions. If you’ve reinvested dividends, each reinvestment counts as a separate purchase with its own cost basis and holding period. Stock splits, mergers, and return-of-capital distributions can also adjust your basis. Your brokerage’s 1099-B form should report this for shares purchased after 2011, but it’s worth double-checking the numbers yourself.

What is the wash sale rule?

The wash sale rule prevents you from claiming a tax loss if you buy back the same or a “substantially identical” security within 30 days before or after selling at a loss. The IRS disallows the deduction entirely for that tax year, though the disallowed loss gets added to the cost basis of your replacement shares. The rule covers a 61-day window total and catches many investors who have automatic dividend reinvestment turned on.

Can you offset capital gains with capital losses?

Yes. You can use capital losses to offset capital gains dollar for dollar. Short-term losses first offset short-term gains, and long-term losses first offset long-term gains. If you still have net losses after that, they offset gains in the other category. If your total losses exceed your total gains, you can deduct up to $3,000 of the excess against ordinary income per year, and any remaining loss carries forward indefinitely.

What is the net investment income tax?

The net investment income tax (NIIT) is a 3.8% surtax on investment income, including capital gains, dividends, interest, and rental income. It applies if your modified adjusted gross income exceeds $200,000 for single filers or $250,000 for married filing jointly. This means a taxpayer in the 20% long-term capital gains bracket who also owes NIIT is effectively paying 23.8% on their gains.

How can you avoid or reduce capital gains tax legally?

Several strategies work. Hold assets for more than a year to qualify for the lower long-term rates. Use tax-loss harvesting to offset gains with losses from other investments. Donate appreciated stock directly to charity to avoid the tax entirely while getting a deduction. Use the primary residence exclusion ($250,000 single, $500,000 married) when selling your home. And prioritize holding tax-inefficient investments in tax-advantaged accounts like IRAs and 401(k)s.