Skip to content

How to Estimate Capital Gains Tax Before You Sell a Stock

OpenBudget6 min read
Comparison showing a $50,000 stock gain taxed as short-term ordinary income versus long-term capital gains, showing how much waiting to sell can save

How to Estimate Capital Gains Tax Before You Sell a Stock# permalink to this section

Most people find out what they owe in capital gains tax after they sell, when the number shows up on their tax return. By then it's too late to change anything. This guide walks through how to estimate that number before you sell, so it factors into the decision instead of surprising you the following April.

Short-Term vs Long-Term: The Difference That Changes Your Tax Bill# permalink to this section

The single biggest factor in your tax bill is how long you held the asset.

If you held it for one year or less, any profit counts as a short-term capital gain and gets taxed at your ordinary income tax rate, the same rate that applies to your paycheck. For most people, that's a meaningfully higher rate than what comes next.

If you held it for more than one year, the profit counts as a long-term capital gain and gets taxed at one of three lower rates: 0%, 15%, or 20%, depending on your income. This is the reason financial advisors talk about "holding period" so much. Selling one day before the one-year mark instead of one day after can change your tax bill by thousands of dollars on a large gain.

The 2026 Long-Term Capital Gains Tax Brackets# permalink to this section

These are the official 2026 brackets from the IRS, based on your taxable income (not your gross income) and filing status.

Taxable income means your income after subtracting the standard deduction ($16,100 single, $32,200 married filing jointly for 2026) or your itemized deductions, whichever is larger. Your capital gain stacks on top of your ordinary income to determine which bracket it falls into, which is a detail that trips a lot of people up.

Short-term gains don't use this table at all. They're taxed at your regular income tax bracket, which tops out at 37% for high earners.

How to Calculate Your Cost Basis# permalink to this section

Your taxable gain isn't your sale price. It's your sale price minus your cost basis, which is generally what you originally paid for the asset, plus any reinvested dividends or fees that were added to your position over time.

This gets more complicated when you've bought shares of the same stock at different times and different prices, which is normal if you've been investing for a while or hold the same stock across a taxable brokerage, a Roth IRA, and maybe an old 401(k) rollover. Each purchase, called a "lot," has its own cost basis. When you sell, you can usually choose which lots to sell from (specific identification) or let your broker use the default method (often FIFO, first in first out). The lots you choose to sell can meaningfully change your tax bill.

A Worked Example# permalink to this section

Here's what this looks like with real numbers. Say you're a single filer with $100,000 in ordinary income for 2026, and you're considering selling a stock position with a $50,000 long-term gain.

First, subtract the standard deduction: $100,000 minus $16,100 leaves $83,900 in taxable ordinary income. That's already above the $49,450 threshold for the 0% rate, so none of the gain qualifies for 0%.

The $50,000 gain stacks on top of that $83,900, landing entirely inside the 15% bracket (which runs up to $545,500). So the full gain gets taxed at 15%: $7,500.

Add that to the federal tax owed on the $83,900 of ordinary income (about $13,170 under 2026 brackets), and the total federal tax bill is roughly $20,670, an effective rate of about 13.8% on total income.

Bar chart comparing capital gains tax on the same $50,000 gain: $11,564 if sold short-term versus $7,500 if held long-term, a $4,064 difference

Change one variable, like holding the stock for less than a year, and that $50,000 gain would instead be taxed as ordinary income, at rates as high as 24% or more depending on the bracket it lands in. That's the difference holding period makes.

Don't Forget the Net Investment Income Tax# permalink to this section

High earners have one more layer to account for. The Net Investment Income Tax (NIIT) adds an extra 3.8% on investment income, including capital gains, once your modified adjusted gross income crosses $200,000 (single) or $250,000 (married filing jointly). It applies to the lesser of your net investment income or the amount you're over the threshold, so it doesn't always apply to your full gain.

State Taxes Add Another Layer# permalink to this section

Everything above is federal. Depending on where you live, your state may tax capital gains too, sometimes at the same rate as ordinary income, sometimes with no capital gains tax at all. If you live in a state with income tax, add that rate on top of your federal estimate to get a complete picture.

Ask Claude to Calculate Your Exact Number# permalink to this section

The brackets above give you the general shape of what you'll owe. Getting your actual number requires your actual cost basis, which is where most calculators fall short, since they ask you to enter numbers by hand instead of pulling them from your real accounts.

If your brokerage accounts are connected to OpenBudget, you can just ask:

"How much capital gains tax will I owe if I sell my Apple position?"

Claude already knows your exact cost basis across every account, including which shares were bought when and at what price, so it can tell you the real number instead of an estimate built on guesses.

Claude showing estimated capital gains tax owed on an Apple position broken down by lot, with long-term, tax-free, and short-term rates across three accounts

Ways to Reduce What You Owe# permalink to this section

A few strategies are worth knowing before you sell, not after.

Hold past the one-year mark. If you're close to the one-year threshold, waiting even a few weeks can move a gain from your ordinary income rate down to the long-term rate.

Harvest losses to offset gains. If you're also holding a position that's down, selling it in the same year lets you offset your gain with that loss, dollar for dollar, up to certain limits. This is called tax-loss harvesting.

Watch your income in the sale year. Since capital gains stack on top of ordinary income, selling in a year when your income is lower (between jobs, a sabbatical, early retirement) can push more of the gain into the 0% or 15% bracket instead of the 20% one.

Spread large sales across years. Selling a large position all at once can push part of the gain into a higher bracket than spreading the sale across two tax years would.

The Bottom Line# permalink to this section

Capital gains tax depends on three things: how long you held the asset, your cost basis, and your total taxable income in the year you sell. The brackets above will get you a rough estimate. Your real accounts will get you an exact one.

Connect your brokerage accounts and ask Claude what you'd actually owe before you sell, not after.

Get started at openbudget.sh →

This article is for informational purposes only and isn't tax advice. Tax situations vary, and you should talk to a qualified tax professional before making decisions based on the numbers above.

OpenBudget

Ask AI about your money.

Keep reading