Bufetico Join the waitlist

Capital gains tax calculator

Find out what a stock sale costs you in US tax, and what you keep. It uses your dates to tell if the gain is short or long term, adds the federal tax, the 3.8% tax on investment income and your state’s tax, and shows what you’d save by waiting.

Want these tools on your phone? They’re coming to the Bufetico app. Join the waitlist »

bufetico.com/tools/capital-gains-tax-calculator ·

An educational tool, not investment or tax advice. It’s free, with no sign-up and no ads. The result comes from the numbers you put in, the IRS tables for 2025 and 2026, and 2026 state tax tables.

Your sale

Try an example:
$

The price times the shares. If you inherited them, their value on the day the owner died.

$

The price times the shares you sold.

$

They add to your cost.

$

It comes out of what you got.

$

Dividends that bought more of these shares. You paid tax on them already.

Your lots

A lot is a batch of shares you got on the same day. Add each buy. A dividend that bought more shares is a lot too: pick Dividend.

DateSharesPrice per shareFeeKindSell
Paste lots from a spreadsheet

One lot per line: date, shares, price per share and fee, separated by commas or tabs. Dates as 2024-03-15 or 3/15/2024.

Or the day you plan to sell.

Leave it empty if you sold them all.

$
$

Most US brokers use first in, first out unless you pick the shares when you sell.

Your taxes

A qualifying surviving spouse uses married filing jointly.

$

Taxable income is the number on your return after deductions. Before deductions means your adjusted gross income.

If you don’t pay US tax, use your own country’s rates.

%

A year or less.

%

More than a year.

Other gains, losses and deductions
$

Negative for a loss.

$

Negative for a loss.

$

As a positive number.

$

As a positive number.

$

They pay the long-term rates, so they change where your gain lands.

$

It counts for the 3.8% tax.

$

Used for the 3.8% tax. Leave it empty and the calculator uses your taxable income plus the standard deduction.

$

Only if they’re more than the standard deduction.

%

A city or county rate, like New York City’s.

Bought the same stock near the sale?

If you sold at a loss and bought the same stock within 30 days before or after, the loss may not count yet. Shares your spouse bought count too.

Tax on this sale

$2,200.00

You keep $22,800.00 of the $25,000.00 you got. The tax is 22% of your $10,000.00 gain.

Short term: you held them a year or less, so the gain is taxed like your pay. Your top bracket is 22%.

Federal income tax: $2,200.00.

These shares turn long term on August 5, 2026, 142 days after the sale. If you sold them that day at the same price, the tax would be $1,500.00, or $700.00 less.

That saving is gone if the price falls more than 3.29% by then.

Your next $1,000.00 of long-term gain would add $150.00 of tax. The same short-term gain would add $220.00.

I hold the companies I own for years, and that keeps my tax lower too. A gain held more than a year pays 0%, 15% or 20%. A quick one pays the same rate as a paycheck. The costs of selling fast.

Where your income and gain land

Taxed like pay0%15%20%

Your taxable income with the sale: $90,000.00. Long-term gains and qualified dividends go on top.

The shares you sold, lot by lot

LotSharesCostGainTerm
Mar 4, 201980$3,204.00$7,991.00Long

The same sale, sold in other orders

OrderGainTaxYou keep
First in, first out$7,991.00$1,198.65$9,996.35
Last in, first out$182.75$40.20$11,154.80
Highest cost first-$938.33-$206.43$11,401.43
Least tax per share first-$850.33-$187.07$11,382.07

The highlighted row leaves the least tax. To use an order other than first in, first out, you have to pick the shares with your broker when you sell.

Show the math
Without the saleWith the sale
What you got, after the fee$25,000.00
What the shares cost, fees included$15,000.00
Gain$10,000.00
Short-term part$10,000.00
Long-term part$0.00
Taxable income$80,000.00$90,000.00
Taxed like pay$80,000.00$90,000.00
Long term at 0%$0.00$0.00
Long term at 15%$0.00$0.00
Long term at 20%$0.00$0.00
Federal income tax$12,312.00$14,512.00
3.8% tax$0.00$0.00
State tax$0.00$0.00
Local tax$0.00$0.00
Total$12,312.00$14,512.00
Tax on this sale$2,200.00

Tax on this sale = the total with it minus the total without it.

How this calculator works

The calculator works out your tax for the year twice, once without the sale and once with it. The difference is the tax on the sale. That way it also catches the side effects, like a gain that pushes part of your income over a line.

A long-term gain doesn’t get a single rate. The IRS stacks it on top of the rest of your taxable income. The part that fits under the first line, the income level where the 15% rate starts, pays 0%. The part between that line and the next pays 15%, and anything above pays 20%. A short-term gain is added to your income and taxed like your pay, at 10% to 37%.

With the numbers already in the boxes, you paid $15,000 for shares on August 4, 2025 and sold them for $25,000 on March 16, 2026. That’s a $10,000 gain held about seven months, so it’s short term. With $80,000 of taxable income, a single filer pays 22% on it: $2,200. Sold on August 5, 2026 or later, the same gain would be long term and pay $1,500, $700 less. That saving is gone if the price falls more than 3.29% before then.

Long-term gains and qualified dividends, 2026: taxable income, gain included
Filing status0%15%20%
SingleUp to $49,450$49,451 to $545,500Over $545,500
Married filing jointlyUp to $98,900$98,901 to $613,700Over $613,700
Head of householdUp to $66,200$66,201 to $579,600Over $579,600
Married filing separatelyUp to $49,450$49,451 to $306,850Over $306,850
Short-term gains and the rest of your income, 2026: taxable income
RateSingleMarried filing jointlyHead of householdMarried filing separately
10%$0 to $12,400$0 to $24,800$0 to $17,700$0 to $12,400
12%$12,400 to $50,400$24,800 to $100,800$17,700 to $67,450$12,400 to $50,400
22%$50,400 to $105,700$100,800 to $211,400$67,450 to $105,700$50,400 to $105,700
24%$105,700 to $201,775$211,400 to $403,550$105,700 to $201,750$105,700 to $201,775
32%$201,775 to $256,225$403,550 to $512,450$201,750 to $256,200$201,775 to $256,225
35%$256,225 to $640,600$512,450 to $768,700$256,200 to $640,600$256,225 to $384,350
37%Over $640,600Over $768,700Over $640,600Over $384,350
The 2025 lines, for a sale in 2025
Long-term gains and qualified dividends, 2025: taxable income, gain included
Filing status0%15%20%
SingleUp to $48,350$48,351 to $533,400Over $533,400
Married filing jointlyUp to $96,700$96,701 to $600,050Over $600,050
Head of householdUp to $64,750$64,751 to $566,700Over $566,700
Married filing separatelyUp to $48,350$48,351 to $300,000Over $300,000
Short-term gains and the rest of your income, 2025: taxable income
RateSingleMarried filing jointlyHead of householdMarried filing separately
10%$0 to $11,925$0 to $23,850$0 to $17,000$0 to $11,925
12%$11,925 to $48,475$23,850 to $96,950$17,000 to $64,850$11,925 to $48,475
22%$48,475 to $103,350$96,950 to $206,700$64,850 to $103,350$48,475 to $103,350
24%$103,350 to $197,300$206,700 to $394,600$103,350 to $197,300$103,350 to $197,300
32%$197,300 to $250,525$394,600 to $501,050$197,300 to $250,500$197,300 to $250,525
35%$250,525 to $626,350$501,050 to $751,600$250,500 to $626,350$250,525 to $375,800
37%Over $626,350Over $751,600Over $626,350Over $375,800

Sources: IRS, Revenue Procedure 2025-32 for 2026 and IRS, Revenue Procedure 2024-40 for 2025, with the 2025 standard deduction from the One Big Beautiful Bill Act. The 3.8% tax: IRS, Net investment income tax.

A sale in 2025 uses the 2025 lines, and a sale in 2026 or later uses the 2026 ones. When the IRS publishes the 2027 lines, usually in October or November, they go into the calculator.

Short term or long term

The holding period starts the day after you buy and includes the day you sell. Shares bought on March 1 are long term if you sell them on March 2 of the next year or later. It goes by the trade date, the day the order went through, not the day the money settled.

If some of your shares are still short term, the calculator shows the day they turn long term and the tax if you sold that day at the same price. It also shows how far the price could fall before that saving is gone. The price can move either way while you wait.

Inherited shares are always long term, however long anyone held them. Shares you got as a gift keep the giver’s cost and purchase date.

Several lots, and selling only part

If you bought a stock more than once, each buy is a lot, with its own cost and its own date. So is each dividend that bought more shares. When you sell only part, the lots you sold decide your gain and whether it’s short or long term.

US brokers sell your oldest shares first unless you tell them otherwise. That’s first in, first out. You can also pick the exact shares, or a rule like highest cost first, but you have to choose by the time the trade settles. You can’t switch at tax time.

Under the result, the calculator runs the same sale four ways. Two are the usual broker rules, first in, first out and last in, first out, the two most brokers let you pick. The other two sell the costliest shares first, or the shares that add the least tax at your rates. Pick “Whichever order leaves the least tax” and it uses the cheapest of the four.

The fees you paid to buy go into each lot’s cost. The fee to sell comes out of what you got, split across the shares you sold.

Losses, and the $3,000 limit

Losses offset gains in a set order. Short-term losses go against short-term gains first, and long-term against long-term. Whatever is left on one side then offsets the other. If you still have a loss, up to $3,000 of it comes off your other income this year, or $1,500 if you’re married filing separately.

The rest carries over to next year and keeps its type, short or long term. It doesn’t expire. Type last year’s carryover under “Other gains, losses and deductions”, and the calculator shows what carries into next year, using the IRS carryover worksheet.

Selling at a loss and buying the same stock within 30 days before or after is a wash sale. The loss doesn’t count yet. It moves into the cost of the new shares, and their holding period starts back when you bought the old ones. A reinvested dividend in those days counts as a purchase, and so do shares your spouse buys. If the new shares are in your IRA, the loss is gone for good. In “Several lots”, the calculator checks your own lots for this, reinvested dividends included.

The 3.8% tax, and your state

Above a certain income there’s another 3.8% on investment income, called the net investment income tax. It applies when your modified adjusted gross income, which is close to your income before deductions, goes over $200,000 single or head of household, $250,000 married filing jointly or $125,000 married filing separately. Those lines haven’t moved since the tax started in 2013, because they don’t rise with inflation. The tax hits the smaller of two amounts: your investment income, or the part of your income above the line.

Most states tax a gain like any other income, at their own rates. Nine don’t tax it at all: Alaska, Florida, Missouri from 2025, Nevada, New Hampshire, South Dakota, Tennessee, Texas and Wyoming. Washington has no income tax, but it has its own tax on long-term gains above a large yearly deduction. Arizona, Arkansas, Hawaii, Montana, New Mexico, North Dakota, South Carolina, Vermont and Wisconsin go easier on long-term gains, and Massachusetts charges more on short-term ones. Pick your state and the calculator applies its 2026 brackets and these rules.

The state number is an estimate. It uses your federal taxable income in place of the state’s, since every state has its own deductions, and the single brackets unless you file jointly. Where the 2026 numbers weren’t out, the calculator says so next to the result. City and county taxes, like New York City’s or the Maryland counties’, go in the local tax box.

State data: Tax Foundation, State Individual Income Tax Rates and Brackets, 2026, checked against each state’s tax department or its laws where the rules changed after February 2026 or the 2026 numbers weren’t final: Georgia, Arkansas, South Carolina, West Virginia, Massachusetts, Washington, New Mexico, Montana, Hawaii, California, Idaho, North Dakota and Vermont. Read on October 22, 2026.

If you don’t pay tax in the US

This is a US tax calculator. If you live outside the US and aren’t a US citizen or resident, the US usually doesn’t tax your gain on US stocks, unless you spent 183 days or more in the US that year. The 3.8% tax doesn’t apply to you either. Your own country probably taxes the gain. Pick “My own rates”, type your country’s rates for short and long term, and choose your currency at the top.

What a simpler calculator gets wrong

A quick estimate can be off by a lot, usually for one of these reasons.

  • Income before deductions typed as taxable income. The brackets go by your income after deductions. Type your pay before them and the tax comes out too high. If that’s the number you know, pick “Before deductions” under “Your income is” and the calculator takes the standard deduction off for you.
  • One rate for the whole gain. A gain that crosses a line pays two rates. Taxing all of it at the higher one overstates the tax.
  • The 3.8% tax left out. Above $200,000 of income, or $250,000 married filing jointly, it adds 3.8% to part or all of the gain.
  • Reinvested dividends left out of the cost. You paid tax on those dividends the year you got them. Leave them out of the cost and you pay tax on the same money twice.
  • Company shares with no cost on the form. Shares from a stock award or an employee stock purchase plan often show a cost of $0, or one that’s too low, on the 1099-B, the form your broker sends. The part you were already taxed on as pay belongs in the cost.
  • Old tables. Some calculators labeled 2026 still use the 2025 lines. This one prints its sources and the year next to each table.
  • A loss with nowhere to go. Many calculators don’t handle a loss at all. This one uses it against your other gains, then against up to $3,000 of your other income, and carries the rest over.

For what a stock really made you, dividends and fees included, try the stock profit calculator. For your average cost across many buys, there’s the stock average calculator.

Questions people ask

How is capital gains tax calculated on stocks?

Subtract what the shares cost you, fees included, from what you sold them for after the fee to sell. That’s the gain. Held more than a year, it’s a long-term gain and pays 0%, 15% or 20%, stacked on top of your other taxable income. Held a year or less, it’s added to your income and taxed like your pay. Above $200,000 of income ($250,000 married filing jointly) there may be another 3.8%, and most states add their own tax.

Will a capital gain push me into a higher tax bracket?

It doesn’t raise the rate on your pay. A long-term gain sits on top of your other income, so only the part of it above a line pays the higher rate. But the gain does raise your income for other things: the 3.8% tax, the senior deduction from 2025 to 2028, how much of your Social Security is taxed, and Medicare premiums two years later. The calculator counts the first two.

When does a stock become long term?

When you’ve held it more than one year. The count starts the day after you buy, so shares bought on March 1, 2025 are long term from March 2, 2026. It counts from the trade dates, the days the orders went through.

How much long-term gain can I have at 0%?

In 2026, long-term gains pay 0% while your taxable income, gain included, stays at or below $49,450 single, $98,900 married filing jointly or $66,200 head of household. The calculator shows how much more long-term gain still fits at 0% this year. The wash sale rule only applies to losses, so it doesn’t stop you from selling at a gain and buying the same stock back. Your state may still tax that gain.

Should I type my taxable income or my income before deductions?

Either one, as long as you pick which. Taxable income is the line on your return after deductions, and the brackets go by it. If you only know your income before deductions, pick that, and the calculator takes off the 2026 standard deduction ($16,100 single, $32,200 married filing jointly and $24,150 head of household), the extra amount for people 65 or older or blind, and the senior deduction.

How does the 3.8% net investment income tax work?

It’s 3.8% of the smaller of two amounts: your investment income, like gains, dividends, interest and rent, or the part of your modified adjusted gross income above $200,000 single or head of household, $250,000 married filing jointly or $125,000 married filing separately. Those lines don’t rise with inflation. The test uses your income before most deductions, so don’t take the standard deduction off first. There’s more on the IRS page about it.

What’s my cost basis?

What you paid for the shares, plus fees, plus any dividends that bought more of them. Inherited shares take their value on the day the owner died. Shares you got as a gift keep the giver’s cost and dates. If they were worth less than that cost when you got them, a loss is measured from that lower value, and its holding period starts on the day of the gift. Shares from a stock award take their value on the day they vested, the amount you were taxed on as pay. IRS Publication 551 has the details.

How do capital losses work?

They offset your gains first, short against short and long against long, and then across. A loss that’s left comes off up to $3,000 of your other income a year, or $1,500 married filing separately. The rest carries over to the next year with its type, short or long term, for as long as it takes to use it up.

What is a wash sale?

In the US, if you sell a stock at a loss and buy the same stock within 30 days before or after the sale, the loss doesn’t count yet. It goes into the cost of the new shares, so it comes back when you sell those. A reinvested dividend counts as a purchase, and so does a purchase by your spouse or in your IRA. In an IRA, the loss is gone for good.

Which shares count as sold if I sell only some?

The first ones you bought, unless you told your broker which ones when you sold. That’s first in, first out. You can pick specific shares, or a rule like highest cost first, but you have to do it by the time the trade settles. For mutual funds, many brokers use the average cost instead. Open “Several lots” to see the tax under each order.

Do I have to pay the tax right away?

It’s due with your return for that year. After a big gain, though, you may owe a penalty unless you pay some during the year, through estimated payments. For 2026 they’re due on April 15, June 15 and September 15, 2026, and January 15, 2027. You usually avoid the penalty if, by each of those dates, your withholding and estimated payments are on pace for 90% of this year’s tax or 100% of last year’s. That’s 110% of last year’s if your adjusted gross income was over $150,000, or $75,000 married filing separately. After a gain late in the year, the IRS lets you match the payments to when the income came in, with Form 2210.

I sold in December. Which year does it count for?

The year of the trade date. A sale on December 31 counts for that year, even though the money settles in January. The wash sale window can run into the new year, though: buying back in early January can still put off a December loss.

Does this work for funds, gold ETFs or a house?

For stock funds and ETFs, yes, the same way. Funds that hold the metal itself, like most gold and silver ETFs, are taxed as collectibles, at up to 28% on a long-term gain, and this calculator doesn’t do that rate. A fund of gold-mining stocks is just stocks. The calculator doesn’t do real estate either, where part of the gain can pay up to 25% and part or all of the gain on your main home can be left out of income. A fund can also pay you a capital gain without you selling anything. Type that under other long-term gains.

I don’t live in the US. Does this apply to me?

Usually not. If you aren’t a US citizen or resident, the US doesn’t tax your gains on US stocks unless you spent 183 days or more in the US that year, and the 3.8% tax doesn’t apply to you. Pick “My own rates” and type your country’s rates, and choose your currency at the top.

Before you decide

This calculator is an educational tool. It does the math on the numbers you enter. It also shows data from other sources, like the history of the S&P 500. And it shows figures measured in Bufetico’s own data. This page gives the source and date of each one. That data can have errors and can go out of date. The past doesn’t tell you what comes next. The calculator doesn’t know your situation. Its result is hypothetical and changes with every input. It doesn’t guarantee anything. None of this is investment, tax or legal advice, or a recommendation to buy, hold or sell any security. Neither Bufetico nor JH Grandgerard is a registered investment adviser, a broker or a tax adviser. Bufetico sells a subscription to a stock screener, and this page links to it.

The tax figures are rough estimates for the year shown. Tax rules change, so check yours with your tax office or a tax professional.

Terms for the free tools

Sold too early, or held on too long?

Join the waitlist and I'll email you when Bufetico opens, plus a new article or tool now and then.

No more than one email a week. You can unsubscribe anytime, and the Privacy Policy explains how we handle your name and email.

Can't tell a cheap stock from a dying one?

The Bufetico Filter checks more than 30,000 companies against six layers and shows you only the ones that pass. You decide how strict each layer is. Bufetico opens soon.

Join the waitlist »