GST Automation in India: From OCR to Compliance in 5 Weeks

By , Founder & CTOUpdated 7 min read

Short answer

GST invoice automation works when you route each invoice to the right extraction method by quality, validate every GSTIN with its checksum (and optionally the GST portal), check tax arithmetic and rates against the invoice date, handle multi-rate, credit-note and reverse-charge cases explicitly, match purchases to GSTR-2B before claiming input tax credit, and send the ambiguous remainder to a human review queue with fields pre-filled.

Key takeaways

  • Invoice quality varies widely, so route clean PDFs, scans and poor images to different extraction paths.
  • Validating GSTINs upstream prevents input-credit claims on invalid numbers.
  • Tax rates must be checked against the invoice date: the 12% and 28% slabs were removed from 22 September 2025, but older invoices still carry them.
  • Edge cases like reverse charge and credit notes need explicit logic; a review queue handles the rest.

Indian GST compliance sounds straightforward until you're in it. HSN/SAC code classification alone has thousands of entries. GSTIN validation requires checksum logic. Multi-rate invoices — one line item at 5%, another at 18%, a third exempt — are the norm, not the exception.

Building a reliable automation layer on top of this required us to be precise about what we were automating and humble about what still needed human review. This post walks through how we built the pipeline for an Indian accounting client, and the checks and design choices any GST automation needs to get right.

What is GST invoice automation?

GST invoice automation is software that reads purchase and sales invoices, extracts the fields GST compliance depends on (GSTINs, invoice number and date, HSN/SAC codes, taxable values and tax amounts), validates them, and posts clean data to the books and returns. Done well, it turns bookkeeping from typing numbers into reviewing exceptions.

The hard part is not reading text off a page. It's knowing whether the numbers are right: whether the GSTIN exists, whether the tax type matches the place of supply, whether the rate was valid on the invoice date, and whether the supplier has reported the invoice so input tax credit can be claimed.

The OCR Problem

Not all invoices are created equal. We receive PDFs generated by modern accounting software, scanned paper invoices from the 1990s, handwritten chalan slips, and everything in between.

We built a pre-processing pipeline that detects invoice quality, applies appropriate denoising, and routes to the right OCR engine. Clean PDFs go to our structured parser. Scanned images go to Google Document AI for layout-aware extraction. Low-quality scans get flagged for human review with a pre-filled partial extraction.

Routing matters because each path fails differently. A digital PDF has exact text but unpredictable layouts. A scan has a predictable layout but noisy characters, where an 8 becomes a B and a GSTIN quietly breaks. Treating every invoice the same way means you either overpay for heavy OCR on clean files or under-process the messy ones. For a broader look at how this extends beyond invoices, see our guide to intelligent document processing with LLMs.

Which fields does a GST invoice need?

Rule 46 of the CGST Rules sets out what a tax invoice must contain. For automation, these are the fields worth extracting and validating:

FieldWhy it matters
Supplier name, address and GSTINIdentifies who charged the tax; the GSTIN drives credit eligibility
Invoice number and dateNumber must be unique per financial year (up to 16 characters); date decides which tax rates apply
Recipient name, address and GSTIN (for registered buyers)Confirms the invoice is actually yours
HSN code (goods) or SAC (services)Classifies the item and determines the rate
Description, quantity and unitNeeded to check line arithmetic
Taxable value per lineThe base for every tax calculation
Tax rate and amount: CGST + SGST/UTGST, or IGSTMust match the type of supply
Place of supply (for inter-state supplies)Decides whether IGST or CGST + SGST applies
Whether tax is payable on reverse chargeChanges who pays the tax

HSN depth also depends on the supplier's size. Since 1 April 2021, businesses with aggregate turnover above ₹5 crore must show a 6-digit HSN code, and smaller businesses at least 4 digits on B2B invoices. A missing or too-short code is worth flagging, not silently accepting.

GSTIN Extraction & Validation

Once text is extracted, GSTIN identification uses a regex pattern — GSTINs follow a known 15-character alphanumeric format. But extraction alone isn't enough. We validate each GSTIN against a checksum algorithm and optionally verify against the GST portal API.

A GSTIN has a fixed structure:

  • Characters 1–2: state code (for example, 27 is Maharashtra and 29 is Karnataka)
  • Characters 3–12: the holder's PAN
  • Character 13: entity number for registrations under the same PAN in that state
  • Character 14: the letter Z by default
  • Character 15: a check character computed from the first 14

The check character catches most single-character OCR errors. Here's the validation in TypeScript:

const CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

function gstinCheckChar(first14: string): string {
  let sum = 0;
  for (let i = 0; i < 14; i++) {
    const product = CHARS.indexOf(first14[i]) * (i % 2 === 0 ? 1 : 2);
    sum += Math.floor(product / 36) + (product % 36);
  }
  return CHARS[(36 - (sum % 36)) % 36];
}

export function isValidGstin(input: string): boolean {
  const gstin = input.trim().toUpperCase();
  if (!/^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z][1-9A-Z]Z[0-9A-Z]$/.test(gstin)) return false;
  return gstinCheckChar(gstin.slice(0, 14)) === gstin[14];
}

A checksum proves the number is well-formed, not that it's active. That's why the portal check is a second step: a cancelled or suspended registration passes the checksum but shouldn't support a credit claim.

Invalid GSTINs are flagged immediately. Input credit claims on invalid GSTINs are a common audit trigger — catching them upstream saves clients significant headaches.

Which validation checks catch the most errors?

Field extraction gets you data. Validation tells you whether to trust it. Every invoice should pass a set of deterministic checks before anything is posted:

  • Arithmetic: quantity × rate equals the line value; line values add up to the taxable total; tax equals taxable value × rate, within a rounding tolerance.
  • Tax type vs place of supply: when the supplier's state (the first two digits of the GSTIN) differs from the place of supply, the invoice should carry IGST, not CGST + SGST. A mismatch is one of the most common real errors on supplier invoices.
  • Rate vs invoice date: the GST Council moved to two main slabs, 5% and 18% with a 40% rate for specified goods, from 22 September 2025. Invoices dated before that still legitimately show 12% or 28%. Rate checks have to be date-aware, or you'll flag every older invoice as wrong. Item-level rates are set by the Council's notifications, which are the source to check against.
  • Duplicates: the same supplier GSTIN, invoice number and financial year seen twice usually means a duplicate upload, not two purchases.
  • HSN sanity: the code exists, has enough digits for the supplier's size, and is plausible for the item description.

These checks are cheap, explainable and don't involve a model at all, which is why they belong at the core of the system: the extraction model gets things mostly right; the rules decide what "right" means.

What We Learned

The edge cases are where real systems earn their keep. Invoices with multiple GSTINs (inter-state transactions). Credit notes with negative line items. Reverse charge mechanism invoices. Each required explicit handling logic that no generic OCR vendor provides.

A few that deserve explicit design rather than hope:

  • Credit and debit notes reference an original invoice. Linking them back is what keeps the totals right; treating them as standalone negative invoices distorts both the books and the return.
  • Reverse charge invoices shift the tax liability to the recipient. The tax shouldn't be read as paid to the supplier, and the reverse charge flag on the invoice has to be captured, not ignored.
  • Mixed-rate invoices need per-line rates. A single "tax rate" field for the whole invoice is wrong more often than you'd expect.
  • E-invoices for businesses above the ₹5 crore threshold carry a signed QR code with the IRN and key invoice details. Where it's present, it's a strong cross-check on the OCR result.

The automation now handles the large majority of invoices without human intervention. The rest get routed to a review queue with extracted data pre-filled and the ambiguity highlighted. That's the right tradeoff.

How should the human review queue work?

A review queue is only useful if reviewers can clear it quickly. The design choices that matter:

  • Show why it's there. "GSTIN checksum failed" or "IGST expected for inter-state supply" beats a generic "low confidence."
  • Pre-fill everything. The reviewer corrects one or two fields instead of re-keying the invoice.
  • Show the source. The original image next to the extracted fields, with the problem region highlighted.
  • Learn from corrections. Every fix is labelled data for evaluating and improving extraction. Our guide to evaluating LLM applications covers how to turn this into a test set.

Reconciling purchases with GSTR-2B

Extraction and validation make your purchase register accurate. Input tax credit depends on something else: whether your supplier has reported the invoice. That shows up in your GSTR-2B, the auto-drafted statement of credit available to you.

Matching the purchase register against GSTR-2B before filing catches the expensive problems early: invoices the supplier hasn't reported, amounts that don't match, and invoices recorded under the wrong GSTIN. It turns a month-end scramble into a list of specific suppliers to chase. From there, the same clean data can pre-populate GSTR-1 and GSTR-3B, so filing becomes a review-and-submit step.

What to measure

If you're building or buying GST automation, track these from day one:

  • Field-level accuracy on a labelled sample, especially GSTIN, invoice number, date, taxable value and tax amounts
  • Straight-through rate: the share of invoices posted with no human touch
  • Error escape rate: wrong data that got past both the checks and the review queue (the number that actually matters)
  • Review time per invoice in the queue

A high straight-through rate with a high escape rate is worse than a lower straight-through rate you can trust.

We build document automation like this through our computer vision and OCR and data engineering services, and you can see the full accounting system on our projects page. If you're automating GST or invoice workflows, tell us what you're working with.

Frequently asked questions

Can GST invoice processing be fully automated?

Most invoices can be processed without human input, but a well-designed system routes low-confidence or unusual invoices to a review queue instead of guessing.

How is a GSTIN validated?

A GSTIN is a 15-character code: a 2-digit state code, the 10-character PAN, an entity number, the letter Z by default, and a final checksum character. Software checks the format and checksum, and can confirm registration status through the GST portal.

What makes GST invoices hard to automate?

Mixed tax rates on one invoice, inter-state transactions, credit notes with negative lines, reverse charge invoices, HSN/SAC classification, rate changes over time and poor-quality scans.

Which OCR is best for invoices?

There is no single best engine. We use a structured parser for digital PDFs and a layout-aware service such as Google Document AI for scans, and flag low-quality images for review.

How many HSN digits must a GST invoice show?

Since 1 April 2021, businesses with aggregate turnover above ₹5 crore must show a 6-digit HSN code on tax invoices, and businesses at or below ₹5 crore must show at least 4 digits on B2B invoices.

Why reconcile purchase invoices with GSTR-2B?

Input tax credit can generally only be claimed when the supplier has reported the invoice, which shows up in your GSTR-2B. Matching your purchase register against GSTR-2B before filing catches missing or mismatched invoices early.

Written by

Ved Patel · Founder & CTO, KeyVed

Full-stack engineer with 8+ years building distributed systems. Led engineering at two fintech startups before founding KeyVed. Obsessed with production-grade AI infrastructure.

Meet the team →

Want to see how we build these systems for clients?

Let's talk →

Keep reading