Eskillsfy

Home / Blog / Calculators

Calculators · 23 Nov 2026

GST Calculator: how it works and how to build one

Add or remove GST at 5%, 12%, 18% or 28%, with CGST/SGST split. This guide explains what happens behind the button and shows the code, so you can build your own.

What it does

Add GST to a price or take it out of a GST-inclusive price. Shows the GST amount, the CGST and SGST split for sales within a state, and IGST for sales between states.

When to use it

  • Invoices and quotes
  • Checking bills
  • Pricing products

How to use it

  1. Type the amount.
  2. Pick the rate and whether GST is included.
  3. Read the breakdown.

Try it free in your browser, nothing is uploaded: https://eskillsfy.com/tools/gst-calculator

How it works

Adding GST: tax = price × rate, total = price + tax. Removing GST from a price that already includes it: base = total ÷ (1 + rate). Dividing by 1.18 is not the same as taking 18% off, which is a common mistake.

Within a state, GST is split equally into CGST and SGST; between states it is charged as IGST.

Build it yourself

Here is the core of the tool. It has no dependencies unless noted, so you can paste it into any TypeScript or JavaScript project.

gst.ts (ts)

export function addGst(amount: number, ratePct: number) {
  const gst = (amount * ratePct) / 100;
  return { base: amount, gst, cgst: gst / 2, sgst: gst / 2, total: amount + gst };
}

export function removeGst(total: number, ratePct: number) {
  const base = total / (1 + ratePct / 100);
  return { base, gst: total - base, total };
}

removeGst(1180, 18); // base 1000, gst 180

Make it production-ready

  • Round to paise with Math.round(x * 100) / 100 at the end, not in between.

Questions

How do I remove GST from a price?

Divide by (1 + rate). ₹1,180 including 18% GST is ₹1,000 plus ₹180 GST.

Try the GST Calculator

Free, runs in your browser, nothing is uploaded.

Open it
Keep reading

More in Calculators

All posts