ForHosting KIT · Finance & money

Capital gains tax estimator

Selling for 50,000 something that cost 30,000, after 400 days, gives a 20,000 long-term gain and, at 15%, a tax of 3,000. Enter proceeds, cost and days held to see the term, rate and tax. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Sale proceeds
50,000
Cost basis
30,000
You get
Capital gain
20,000
Holding term
long
Tax rate (%)
15
Capital gains tax
3,000

This calculator takes sale proceeds, cost basis, and the number of days an asset was held, then returns the capital gain, whether the gain is short- or long-term, the applied rate including any NIIT surtax, and the resulting tax owed.

How the gain, the holding period and the rate fit together

A capital gain is what you receive from a sale minus what the asset cost you. The calculator works out that gain first, then looks at how long you held the asset. If the days held exceed the threshold, 365 by default, the gain is long-term and the long-term rate applies, 15% unless you change it; otherwise it is short-term and the short-term rate applies, 37% by default. Any surtax you enter is added on top. Selling for 50,000 an asset that cost 30,000 after 400 days gives a 20,000 gain taxed at 15%, so 3,000 of tax.

Mistakes that change the bill

Selling a day too early can push a gain into the short-term rate, so check the day count before you sell: with the default threshold, exactly 365 days is still short-term. A sale at a loss gives a tax of zero, never a negative figure. The default rates are a starting point, not your tax year, so replace them with the ones that apply to you. Tax is worked out on the unrounded gain, so the rounding you see on screen never changes the amount owed. Treat the result as an estimate, not tax advice.

Pre-sale tax estimate

Before selling stock, crypto, or property, estimate the gain and tax owed and see how crossing the long-term holding threshold changes the rate and the bill.

Advisor and tooling integration

Embed a deterministic capital gains estimate in a planning tool or client memo, overriding the rate assumptions to match a specific tax year.

What rates does it use by default?

It defaults to a 37% short-term rate, a 15% long-term rate, and a 0% NIIT surtax.

What happens if I sell at a loss?

The tax is floored at zero, so a negative gain reports the actual loss in the gain field but a tax of 0. The term and rate are still returned.

Is this tax advice?

No. It is a deterministic estimate you fully control via the rate inputs.

When does a gain count as long-term?

When you held the asset for more days than the threshold, which is 365 unless you change it. Exactly 365 days still counts as short-term, while 400 days counts as long-term.

Can I add the net investment income surtax?

Yes. Enter the surtax rate and it is added to the short- or long-term rate before the tax is worked out. It stays at zero unless you set it.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/finance/capital-gains-tax

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/finance/capital-gains-tax \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"proceeds":50000,"cost_basis":30000}'
{
  "proceeds": 50000,
  "cost_basis": 30000
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "finance.capital_gains_tax",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

How the gain, term and tax are computed

Tax is then Math.max(0, gain) multiplied by that combined rate percentage, so a loss produces zero tax rather than a negative number. Worked example: proceeds 50,000, cost basis 30,000, held 400 days at a 15% long-term rate gives a 20,000 gain, term 'long', rate 15%, and tax 3,000. The tool first computes the gain as proceeds minus cost_basis. It then classifies the holding period: if holding_days is strictly greater than long_threshold_days (default 365), the gain is long-term, otherwise short-term. The applicable rate is the long-term rate (lt_rate, default 15%) or the short-term rate (st_rate, default 37%) plus any net investment income tax surtax (niit_rate, default 0%). The output returns proceeds, cost_basis, holding_days, the rounded gain, the term string, rate_percent, and the rounded tax.

Inputs, defaults, rounding and validation

A decimals field (default 2) rounds the gain and tax using an explicit half-up rule applied once per output. Note that the tax is computed from the raw gain, not the rounded gain, so display rounding never distorts the amount owed. Only proceeds and cost_basis are required; both must be finite numbers and either may be negative if you are modelling an unusual position. holding_days defaults to 400 and must be a non-negative integer — a fractional or negative day count returns a typed invalid_input error. The rate assumptions are all overridable: st_rate, lt_rate, niit_rate, and long_threshold_days let you match a specific jurisdiction or tax year without hard-coding US brackets. Because a loss is floored at zero tax, the term and rate_percent are still reported even when no tax is due.

Widget, API and multi-language landings

Reach for the API when you need to price many lots at once, back a portfolio tax-loss-harvesting sweep, or override the rate assumptions per jurisdiction across thousands of rows. API runs are billed from $0.002 against prepaid KIT balance, and only successful tasks are charged. Landings are published in eight languages with translated slugs and keywords so someone searching for a capital gains estimate in their own language reaches a local page, while the JSON field names stay identical in every locale. This is a deterministic estimate, not tax advice.

Portfolio and harvesting sweeps

Call the API across many lots with custom short-term, long-term, and NIIT rates to model tax-loss harvesting or compare jurisdictions in bulk.

How is short-term versus long-term decided?

A gain is long-term when holding_days is strictly greater than long_threshold_days (default 365); otherwise it is short-term. The threshold is configurable.

Which inputs are required and validated?

proceeds and cost_basis are required finite numbers; holding_days must be a non-negative integer. Anything else returns a typed invalid_input error.

Read the full KIT documentation →