Capital Gains Calculator

Estimate federal capital gains tax liability on short-term vs long-term stock, ETF, crypto, and asset sales.

Calculate federal income taxes owed when selling investments. Accurately applies short-term capital gains rates (ordinary income tax brackets) vs preferential long-term capital gains brackets (0%, 15%, 20%) based on your filing status.

How this calculator works

Gain = Net Proceeds - Cost Basis. If holding period > 1 year: tax rate is 0%, 15%, or 20% based on statutory income thresholds. If <= 1 year: tax rate equals ordinary income marginal bracket.

Key benefits

Assumptions & exclusions

Frequently asked questions

What qualifies as a long-term capital gain in the US?

An asset must be held for more than one year (at least 366 days) before being sold to qualify for preferential long-term capital gains tax rates. Assets held for one year or less are classified as short-term and taxed at higher ordinary income rates.

Can capital losses offset my capital gains?

Yes. Capital losses first offset capital gains of the same type. If net losses exceed gains, you can deduct up to $3,000 per year against ordinary income, carrying forward any remaining losses to future tax years.

How is my cost basis calculated when I sell shares?

Your cost basis is generally what you paid for the shares, including purchase commissions, plus any reinvested dividends that bought additional shares over the years. Subtracting the basis for the shares sold from the sale proceeds gives your gain or loss.

What tax rate applies to a short-term capital gain?

Short-term gains, on assets held one year or less, are taxed at your ordinary income tax rates, which run higher than the preferential long-term rates. The exact rate depends on your taxable income and filing status for the year of the sale.

Do I owe capital gains tax if I sell at a loss?

No. Tax applies only to net gains. A realized loss can offset gains from other sales, and if your losses exceed your gains you may deduct a limited amount against other income each year, carrying the rest forward.

When is capital gains tax actually paid?

The tax is reported on the return for the year in which you sold the asset, even though the sale happened months earlier. Investors with large gains sometimes make an estimated tax payment during the year to avoid an underpayment penalty.

Formula-Based Calculator · By QalcTools Editorial Team. Formulas tested against independent reference values · Content reviewed November 2026 by the QalcTools Editorial Team.

Methodology note: Internal Revenue Code (IRC § 1(h)) preferential capital gains rate and bracket schedules.

Related calculators

Category: Investments & Retirement Calculators

About this calculator

Selling an investment for more than it cost you creates a capital gain, and this calculator works that event from both ends: the investment result itself — what you paid, what the sale brings in, and the profit between them — and the federal tax the gain is likely to draw. Enter buy and sell prices, the share count, how long you held the position, your taxable income, and your filing status, and it returns the gain, whether it counts as long-term, the rate the model applies, the estimated tax, and the proceeds and profit left after tax. It is built for the moment before a sale, while timing and size are still choices.

How it works

The tool multiplies your buy price by the shares to build the cost of the position, and your sell price by the shares to build the sale proceeds; the difference is the gain or loss. Your holding period then classifies it — more than twelve months makes it long-term — and your income and filing status select the rate the model applies: preferential 0, 15, or 20 percent brackets for long-term gains, or an ordinary-income marginal rate for short-term ones. Tax is charged only on a positive gain. Subtracting it from the proceeds gives your after-tax take, and subtracting it from the gain gives your after-tax profit.

The formula, explained

Gain = (Shares × Sell price) − (Shares × Buy price); Tax = Gain × Applicable rate (gain > 0 only); After-tax profit = Gain − Tax

The engine first totals the position: cost is shares times buy price plus any cost basis adjustment passed to it (this page passes none, so the adjustment is zero), and proceeds are shares times sell price. The gain is proceeds minus cost. A holding period above twelve months flags the gain as long-term, and the engine then picks a rate from fixed income thresholds for your filing status — for a single filer, 0 percent up to $47,025 of taxable income, 15 percent up to $518,900, and 20 percent above — while short-term gains use a stepped ordinary-income scale running from 12 to 37 percent. Tax is the gain times that rate when the gain is positive, and zero on a loss. Proceeds and profit are then reported after tax, rounded to cents.

Inputs and variables

VariableMeaningExample
Buy Price per ShareWhat you paid for one share. Multiplied by the share count it sets your cost basis — the amount the sale must beat before any gain exists.$150 per share
Sell Price per ShareThe price at which the shares are sold. Multiplied by the share count it sets gross proceeds, the starting point for both profit and tax.$185 per share
Number of SharesHow many shares the sale covers. Gain, proceeds, and tax all scale directly with this count, so partial sales can be modelled by entering only the shares actually sold.100 shares
Holding Period (Months)How long you owned the shares before selling. Above twelve months the gain is long-term and reaches the preferential rate scale; at or below, it is short-term.18 months
Annual Taxable IncomeYour taxable income for the year, used to place the gain in the rate scale. It is the input most likely to change the applied rate without any change to the trade itself.$95,000
Filing StatusSingle, married filing jointly, or head of household. The long-term thresholds differ by status, so the same gain and income can draw different rates under different statuses.Single

Worked example

An investor sells 100 shares bought at $150 for $185 after holding them 18 months, with $95,000 of taxable income and single filing status.

  1. Cost basis: 100 × $150 = $15,000. Gross sale proceeds: 100 × $185 = $18,500.
  2. Capital gain: $18,500 − $15,000 = $3,500 — a 23.3% rise on the amount invested in the position.
  3. Classification: 18 months is more than twelve, so the gain is long-term. At $95,000 of taxable income for a single filer, the model applies the 15% long-term rate.
  4. Estimated federal tax: $3,500 × 15% = $525.
  5. After tax: proceeds of $18,500 − $525 = $17,975 in hand, and an after-tax profit of $3,500 − $525 = $2,975.

A $3,500 long-term gain on $18,500 of proceeds, taxed at 15% for an estimated $525, leaving $17,975 of after-tax proceeds and $2,975 of after-tax profit.

Two numbers deserve equal billing here. The investment result — $3,500 on a $15,000 position — is solid, and the long-term classification is what protects it: the same sale at eleven months would have been priced on the ordinary-income scale, at 22% on this income in the model, costing $770 instead of $525. The $245 difference is the cash value of waiting past the one-year line, and it is exactly the comparison to run before selling a winner late in its first year. IRS Topic 409 is the official reference for how gains and losses are classified.

Understanding your results

Separate the two verdicts the page delivers. The gain line grades the investment: proceeds against cost basis, before any government share. The tax lines grade the timing and the seller’s tax situation: the same $3,500 gain costs $0, $525, or $700 at the long-term rates depending on income, and more again if it is short-term. A good investment can still be sold at a needlessly expensive moment, and this split is how you see that before trading.

The after-tax profit, not the headline gain, is the figure that compounds into your next decision. It is also the figure most sensitive to inputs people guess at — taxable income especially. If your income estimate is rough, rerun the page at a lower and a higher income to see whether the applied rate changes; near a bracket threshold, a bonus, a Roth conversion, or bunching the sale across two tax years can move the rate on the whole gain in this simplified model.

Assumptions and limitations

This is a single-rate estimate: it applies one flat rate to the entire gain based on where your income falls, while a real return stacks the gain on top of your other income, so part of a large gain can cross into the next bracket and be taxed at a higher rate than the rest. The model works from the prices and share count entered, with no adjustment for commissions, reinvested dividends that raise basis, wash sales, or corporate actions. State taxes and any additional federal taxes that can apply at higher incomes sit outside the estimate, as do loss carryforwards. Confirm a material sale against IRS Topic 409 and your full tax picture.

Common mistakes to avoid

Sources