curatedapi

VAT and GST calculator

VAT or GST on one amount or a whole invoice, added or taken out of tax-inclusive prices, with the per-rate rounding EN 16931 e-invoices require.

The amount of each line: one item for a single price. Without tax, or with tax when amounts_include_tax is true. Negative amounts are credits. 1 to 1000 items. One per line, or separated by commas.
One tax rate for every line, in percent (20 for 20%). Unit: %.
The tax rate of each line in percent, one per amount and in the same order. Up to 1000 items. Unit: %. One per line, or separated by commas.
Use this country's standard rate for every line (see tax/vat-rates for the table). Reduced rates depend on what is sold, so give those as rate_percent. Options: AT: Austria: VAT 20%; BE: Belgium: VAT 21%; BG: Bulgaria: VAT 20%; CY: Cyprus: VAT 19%; CZ: Czechia: VAT 21%; DE: Germany: VAT 19%; DK: Denmark: VAT 25%; EE: Estonia: VAT 24%; EL: Greece: VAT 24%; ES: Spain: VAT 21%; FI: Finland: VAT 25.5%; FR: France: VAT 20%; HR: Croatia: VAT 25%; HU: Hungary: VAT 27%; IE: Ireland: VAT 23%; IT: Italy: VAT 22%; LT: Lithuania: VAT 21%; LU: Luxembourg: VAT 17%; LV: Latvia: VAT 21%; MT: Malta: VAT 18%; NL: Netherlands: VAT 21%; PL: Poland: VAT 23%; PT: Portugal: VAT 23%; RO: Romania: VAT 21%; SE: Sweden: VAT 25%; SI: Slovenia: VAT 22%; SK: Slovakia: VAT 23%; GB: United Kingdom: VAT 20%; CH: Switzerland: VAT (MWST) 8.1%; NO: Norway: VAT (MVA) 25%; AU: Australia: GST 10%; NZ: New Zealand: GST 15%; SG: Singapore: GST 9%; IN: India: GST 18%; CA: Canada (GST only): GST 5%; CA-NB: Canada: New Brunswick: HST 15%; CA-NL: Canada: Newfoundland and Labrador: HST 15%; CA-NS: Canada: Nova Scotia: HST 14%; CA-ON: Canada: Ontario: HST 13%; CA-PE: Canada: Prince Edward Island: HST 15%; GR: the same as EL; UK: the same as GB
true when the amounts already include the tax, to take it out.
Where the tax is rounded. Options: per_rate: once for each rate, on the sum of that rate's lines (EN 16931, the usual rule for invoices); per_line: on each line, then added up (till receipts, and invoices that print tax per line)
More options: rounding and decimals
Precision and rounding
Rounding mode applied once to each result. Default half_up.
Round results to this many digits after the decimal point.

Examples

Result: An invoice with two rates (the Peppol example's lines)

Net total
Total without tax.
7,000.00 exact
Tax total
Total tax: the sum of the tax of each rate.
1,250.00 exact
Gross total
Total with tax: net_total + tax_total.
8,250.00 exact

Breakdown

Rate percentNetTaxGross
255,000.001,250.006,250.00
02,000.000.002,000.00

Rounding: Half up, 2 decimal places. Calculator tax/vat@1.

How it is calculated

tax = round(net × rate / 100); from a price with tax: net = round(gross / (1 + rate / 100)), tax = gross − net; per_rate applies this to each rate's sum of lines, per_line to each line

Works out net, tax and gross for one amount or for every line of an invoice. Give amounts without tax to add it, or set amounts_include_tax to take the tax out of prices that already include it. Lines can have different rates. By default the tax is worked out once for each rate on the sum of that rate's lines and rounded to the cent, which is how the European e-invoice standard EN 16931 (and so XRechnung, Peppol and Factur-X) defines the VAT breakdown. The other choice rounds the tax on each line and adds those up, as a till receipt does; the two can differ by a few cents on a long invoice. The rate can be given, or looked up as a country's standard rate, in which case the answer names the official page it came from.

  • Amounts are rounded to the cent (2 decimals) half up by default. Set options.decimals for currencies with other minor units (0 for JPY) and options.rounding for another rule.
  • Each line amount is rounded first, because an invoice line has at most two decimals. Net, tax and gross then always add up exactly.
  • Which rate applies to a sale, and whether tax is due at all, depends on what is sold, to whom and where. This calculator does the arithmetic for the rates you give.

References

Results follow each calculator's documented rules and the sources listed. They are not financial, tax or legal advice. Check that the rules fit your case before you rely on a result. See the terms.

Use it from your code

POST /v1/calc/tax/vatVersion 1
curl https://api.curatedapi.com/v1/calc/tax/vat \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amounts": ["4000", "900", "100", "2000"],
    "rates_percent": ["25", "25", "25", "0"]
  }'
The same call in Python
import os

import requests

payload = {
    "amounts": ["4000", "900", "100", "2000"],
    "rates_percent": ["25", "25", "25", "0"],
}
response = requests.post(
    "https://api.curatedapi.com/v1/calc/tax/vat",
    headers={"Authorization": f"Bearer {os.environ['CURATEDAPI_KEY']}"},
    json=payload,
    timeout=10,
)
print(response.json()["result"])
The same call in JavaScript
const payload = {
    "amounts": ["4000", "900", "100", "2000"],
    "rates_percent": ["25", "25", "25", "0"],
};
const response = await fetch("https://api.curatedapi.com/v1/calc/tax/vat", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CURATEDAPI_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(payload),
});
console.log((await response.json()).result);

MCP tool calc_tax_vat at https://mcp.curatedapi.com. Inputs, outputs and errors in the API reference.

Put it on your website

<div data-curatedapi-widget="tax/vat" data-key="capi_public_…"></div>
<script src="https://widgets.curatedapi.com/v1/widget.js" async></script>

Use a public key registered for your site. Calculations are billed like API calls. How widgets work.

Related calculators

Add this calculator to your website

Paste two lines into your page and your visitors get this calculator. Each use counts as one call on your plan, the same as the API.

Free for up to 1,000 uses a month. 50,000 uses a month cost $9.00 on the Starter plan.