Skip to main content
How it works · 4 min read

Bank SMS parser for India: how it works, open source

How a bank SMS parser turns an alert into amount, merchant and account. A developer walkthrough of the parser behind Raqm, with a made-up example.

Share

Every bank in India writes its alerts a little differently. One says "debited", another says "spent", a third puts the merchant before the amount. For a developer, that is the whole difficulty: the same event, many sentences. A bank SMS parser is the piece of code that hides that mess.

What a parser has to produce

The goal is a single, predictable object, whatever the bank wrote. For each message the parser tries to return these fields:

  • Amount. Always a positive number.
  • Type. Expense, income, transfer, investment, or a balance update with no transaction.
  • Merchant. The shop or payee, when the text names one.
  • Account ending. The last four digits, so you can tell accounts apart.
  • Balance. The available balance after the payment, when the bank includes it.
  • Bank name, sender and time. Where the message came from and when.

A made-up example

Here is an invented alert: "Rs.1,500.00 debited from a/c **4321 on 20-06-2026. Info: UPI-Swiggy. Avl Bal: Rs.24,500.00". The parser reads it as an expense of 1,500, merchant Swiggy, account ending 4321, balance 24,500. The same kind of result comes back for a card spend or a credit, with a different type.

Why 120+ formats are needed

There is no standard. Sender IDs differ, wording differs, and a single bank often sends several layouts for cards, UPI, cheques and credit cards. A parser built for one bank breaks on the next. So the package keeps a separate parser per bank and picks one from the sender ID. It also has a helper to check whether a sender is a known bank at all, which is a cheap way to skip messages that are not bank alerts.

Using it in a project

The package is `@rahatsayyed/bank-sms-parser`. It is written in TypeScript, has no native dependencies and works in Node.js, React Native and plain JavaScript projects. You pass in the message text, the sender and a timestamp, and get back a transaction or nothing.

  1. Install it from npm with your usual package manager.
  2. Call the factory with the SMS body, the sender ID and the time.
  3. Check for a result. If the text is not a recognised bank alert, you get nothing back, so handle that case.
  4. Store what you get. Persist the structured fields, not just the raw text.

Where Raqm uses it

Raqm on Android reads the SMS on your phone and passes each one through this parser. The result is categorised and saved in a local database. Because the parser is plain code with no network calls of its own, the reading never needs a server. That is the basis of the private by design approach, and the capture side is covered on the capture and organise page.

How to test a parser before you trust it

If you plan to build on any SMS parser, do not judge it by the banks in the demo. Judge it by your own messages. Collect a handful of real alerts from your accounts, remove personal details, and run them through. Then check each output by eye.

  • Debits and credits. Is the type right for both a payment and a refund?
  • Odd amounts. Commas, decimals and large values such as Rs 1,25,000.00 should all come out as one correct number.
  • Missing merchant. Does it return nothing for the merchant, rather than a wrong guess?
  • Non-bank texts. Offers, one-time passwords and delivery updates should not become transactions.

A parser that says "no result" is better than one that invents a transaction. A false row in someone's spending history is harder to find and more annoying than a missing one that they can add by hand.

The package ships with its own jest test suite, which is where new bank formats are checked against sample messages. It is published on npm as @rahatsayyed/bank-sms-parser, and its source is on GitHub. Because it is licensed AGPL-3.0, read the terms before you use it in a product of your own.

Raqm

Know where your money goes, automatically.

Bank SMS read on your phone, never uploaded. Join the waitlist.

Join the waitlist

What a parser cannot do alone

Parsing gives you clean rows. It does not tell you whether a debit was a real expense. A move between your own accounts and a refund both look like ordinary transactions. Raqm adds a second step on top: matching self-transfers, refunds and duplicates. It is explained with rupee examples in self-transfers, refunds and your real spending.

Honest limits

  • Banks change wording. A new layout can slip through until a parser is updated.
  • Not every message has a merchant. Some alerts name only a reference number.
  • Fallback is manual. If a transaction is missed, any transaction can be added by hand.

If you are not a developer and just want the result, read how to track expenses from bank SMS in India. Questions about supported banks are in the FAQ.

Frequently asked questions

The package is @rahatsayyed/bank-sms-parser. It handles 120+ Indian and international bank SMS formats and is written in TypeScript.

No. It is plain code that works on text you pass in, with no native dependencies. Where the text goes next is up to the app using it.

AGPL-3.0. Read the licence terms before using it in your own product.

Rahat Sayyed

Founder, Raqm

Founder of Raqm and maintainer of the open-source bank SMS parser behind it. Builds Raqm, an on-device expense tracker for India. Writes about money, privacy and the small details of reading bank SMS.

Keep reading