NewShare or split payments with friends and family
mooola
Get mooola

Get mooola

Choose your phone or tablet’s platform to get started.

How to parse a bank statement PDF into transactions

Why bank statement PDFs are hard to parse, the three ways developers do it, how to check the result against the statement’s balances, and working Python and TypeScript examples.

Your users have a bank statement PDF, and your product needs the transactions in it: for an affordability check, a bookkeeping import, a budget or a loan application. There is rarely a bank feed for the account you need, and even where there is one, users often have the PDF to hand already.

This guide covers why statement PDFs are harder to parse than they look, the three ways developers usually do it, and the one check every approach needs: making sure the transactions you extracted add up to the balances printed on the statement.

Why bank statement PDFs are hard to parse

A PDF has no table in it. It is a set of text fragments placed at coordinates on a page, so the rows and columns you see have to be reconstructed. Bank statements add their own problems on top:

  • Every bank has its own layout, often several: current accounts, credit cards, savings and business accounts differ, and banks change them without notice.
  • Direction is printed differently. Some statements use separate debit and credit columns, some print signed amounts, and some mark credits with a Cr suffix.
  • Descriptions wrap onto a second or third line, and a wrapped line can look like a new transaction.
  • Dates often have no year. A statement from 15 December to 14 January prints “03 Jan” without saying which year it belongs to.
  • Number formats vary by country: 1,234.56, 1 234.56 and 1.234,56 are the same amount.
  • One PDF can hold several accounts, each with its own opening and closing balance.
  • Many statements are password-protected, and the password belongs to your user, not to you.
  • Some PDFs are scans with no text layer at all, so there is nothing to extract without OCR.

None of this is a reason not to parse statements. It is a reason to check every result, which comes up again below.

Option 1: write your own parser

If you only need one bank’s statements, a parser of your own can be a few dozen lines. In Python, pdfplumber extracts the text of each page and can open a password-protected file; a regular expression then picks out the transaction lines of one known layout.

python
import re
import pdfplumber

# One layout only: "03 Oct  Card purchase Woolworths  -245.50  12 754.50"
ROW = re.compile(r"^(\d{2} [A-Z][a-z]{2})\s+(.+?)\s+(-?[\d ]+\.\d{2})\s+(-?[\d ]+\.\d{2})$")

def cents(text):
    return round(float(text.replace(" ", "")) * 100)

rows = []
with pdfplumber.open("statement.pdf", password="from-your-user") as pdf:
    for page in pdf.pages:
        for line in (page.extract_text() or "").splitlines():
            match = ROW.match(line.strip())
            if match:
                date, description, amount, balance = match.groups()
                rows.append({"date": date, "description": description,
                             "amount": cents(amount), "balance": cents(balance)})

This works until the second bank, the second account type or the bank’s next redesign. Each layout needs its own pattern, its own handling of wrapped descriptions and its own rule for the year. Budget for maintenance, and keep real sample statements to test against, with your users’ consent.

Option 2: table extraction tools or an LLM

General PDF table extractors such as Camelot and tabula-py find tables by ruling lines or text alignment. They save you writing coordinates by hand, but you still have to map each bank’s columns to dates, amounts and direction, and they need a PDF with a text layer.

A large language model can read almost any layout, which makes it tempting. It can also drop a row, merge two, misread a minus sign or produce a plausible transaction that is not on the statement, and nothing in its answer tells you when that happened. Sending statements to a model provider is also a data-protection decision: under POPIA in South Africa or GDPR in the UK and EU, it is processing your users’ financial information by a third party.

For scanned statements, OCR such as Tesseract produces text, but every OCR error becomes a wrong amount. Ask users for the statement they download from online banking instead of a photo or scan whenever you can.

Always check the result against the statement

Whichever approach you choose, a statement can check itself. It prints an opening balance, a closing balance and usually a running balance on each row. If the transactions you extracted reproduce those numbers, every amount and direction is right. If they do not, something was missed, duplicated or read the wrong way round.

python
def check(rows, opening, closing):
    """Return None when the rows reproduce the statement's own balances."""
    balance = opening
    for row in rows:
        balance += row["amount"]
        if balance != row["balance"]:
            return f"Running balance breaks at {row['date']} {row['description']}"
    if balance != closing:
        return "The transactions do not add up to the closing balance"
    return None

Keep amounts as integers in cents, never floats, so that the comparison is exact. A failed check should stop the import or send the statement to a person, not quietly save numbers that do not add up. A transaction list that does not match the statement is worse than no list, because it looks correct.

Option 3: use a bank statement API

If statements are an input to your product rather than the product itself, an API saves you maintaining layouts. The mooola statement API takes a statement PDF and returns its transactions as JSON or CSV, in one schema across banks. It is built on the reader behind statement imports in the mooola app.

request
curl -X POST "https://parse.mooola.co.za/v1/parse?currency=ZAR" \
  -H "Authorization: Bearer $MOOOLA_API_KEY" \
  -H "Content-Type: application/pdf" \
  --data-binary @statement.pdf

Every result has a status. verified means every transaction was checked against the statement’s own balances or totals. needs_review means every transaction was read but a check did not pass, with warnings that say which. A statement the API cannot stand behind is refused with NOT_VERIFIED and a reason, rather than returned with guessed numbers.

response
{
  "status": "verified",
  "statement": {
    "periodStart": "2026-10-01",
    "periodEnd": "2026-10-31",
    "openingBalanceMinor": 100000,
    "closingBalanceMinor": 243425
  },
  "accounts": [{
    "accountNumber": "9876543210",
    "currency": "ZAR",
    "transactions": [{
      "postingDate": "2026-10-02",
      "description": "Salary deposit",
      "moneyInMinor": 250000,
      "moneyOutMinor": null,
      "balanceMinor": 350000,
      "verified": true
    }]
  }]
}

Amounts are integers in minor units: 250000 is 2,500.00. The same request in Python, including the password of a protected PDF:

python
import os, requests

with open("statement.pdf", "rb") as pdf:
    response = requests.post(
        "https://parse.mooola.co.za/v1/parse",
        params={"currency": "ZAR"},
        headers={
            "Authorization": f"Bearer {os.environ['MOOOLA_API_KEY']}",
            # Only for a protected PDF. It opens the file and is never kept.
            "X-Statement-Password": statement_password,
        },
        files={"file": ("statement.pdf", pdf, "application/pdf")},
    )

result = response.json()
if response.ok:
    transactions = [t for account in result["accounts"] for t in account["transactions"]]
else:
    print(result["error"]["code"], result["error"]["message"])

And in TypeScript, with one branch per outcome:

typescript
const form = new FormData()
form.set('file', pdfBlob, 'statement.pdf')

const response = await fetch('https://parse.mooola.co.za/v1/parse?currency=ZAR', {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.MOOOLA_API_KEY}` },
  body: form,
})
const result = await response.json()

if (response.ok && result.status === 'verified') save(result.accounts)
else if (response.ok) saveForReview(result.accounts, result.warnings)
else if (result.error.code === 'PASSWORD_REQUIRED') askForPassword()
else tellUser(result.error.message)

Error codes such as PASSWORD_REQUIRED, UNREADABLE and QUOTA_EXCEEDED are stable, and their messages are written so you can show them to your users as they are. The quickstart lists every outcome, and the API is described as OpenAPI 3.1 at parse.mooola.co.za/openapi.json.

What to know before you choose it

  • Free tier: 300 statements a month per account, up to 10 MB and 50 pages per PDF, and 30 requests a minute per key.
  • PDFs are not stored. A statement is read for the request and discarded. Each request sends us anonymised diagnostics, the shape of the document with every value masked, which is what keeps the tier free. See exactly what is kept.
  • Scans are refused as UNREADABLE. The PDF needs a text layer, as statements downloaded from online banking have.
  • Measured on real statements: 73% of statements read, 69% of those fully verified, and 27% refused rather than guessed, at 0.23 seconds on average. Results vary by bank.

You can try a statement in the browser without a key before signing up.

Which banks’ statements can be parsed?

These are the banks whose statements the API has read so far, by country. The bank coverage page shows how each one fares: the share of its statements read and the share fully verified.

CountryBanks
South AfricaFNB, Capitec, Absa, TymeBank, Standard Bank, Discovery Bank, RMB Private Bank
United StatesAlly Bank, Capital One, Charles Schwab, Chase, DCU, SoFi, Synchrony, USAA, Webster Bank, Wells Fargo, Woodforest National Bank, Associated Bank, Bank of America, Cash App, Chime, Comerica, Credit One Bank, Discover, Five Star Bank, Frost Bank, GO2bank, Green Dot, HSA Bank, Huntington, IBC Bank, KeyBank, Marcus by Goldman Sachs, Merrick Bank, Navy Federal Credit Union, Optum Bank, PNC Bank, Prosperity Bank, Synovus, U.S. Bank, Walmart MoneyCard
IndiaAxis Bank, HDFC Bank, ICICI Bank, State Bank of India, UCO Bank, Union Bank of India
United KingdomBarclays, Halifax, Lloyds Bank, NatWest, Revolut, Standard Chartered, The Co-operative Bank, Ulster Bank, Virgin Money, first direct, iFAST Global Bank, HSBC
CanadaCIBC, RBC Royal Bank, Scotiabank, Simplii Financial, Tangerine, BMO, Laurentian Bank
Sri LankaCommercial Bank of Ceylon
NigeriaFidelity Bank
PhilippinesGoTyme Bank
AustraliaGreat Southern Bank
KenyaNCBA
QatarQNB
FranceBNP Paribas, Crédit Agricole
GermanyDeutsche Bank, N26
AustriaRaiffeisen
LuxembourgSogexia

A bank that is not listed may still work: send a statement and the API says whether it can verify it.

Parsing South African bank statements

South African statements bring a few local details. Many arrive by email as password-protected PDFs, so plan for asking your user for the password and sending it with the request. Some Absa statements arrive as Striata .emc files rather than PDFs; renaming one does not convert it, so ask the user to download the statement from banking instead. Our guide to Absa statement passwords and Striata files explains the difference.

Statements do not always print a currency, so send ?currency=ZAR and every account without one is returned in rand. FNB, Capitec, Absa, TymeBank, Standard Bank, Discovery Bank, and RMB Private Bank statements have been read so far; check South African coverage for each bank’s figures.

Which approach to choose

ApproachGood forWatch for
Your own parserOne or two banks you know well, full controlA new pattern for every layout, and maintenance when banks change them
Table tools or an LLMPrototypes and one-off extractionSilent errors, and for an LLM, sending statements to a third party
A statement APIMany banks, production imports, users you do not want to ask twiceCoverage of the banks your users have, limits, and what the provider keeps

Whichever you choose, check every statement against its own balances before you trust its transactions.

Ask your AI about mooola

Get an independent summary of what mooola does, how it keeps your data private and which banks it supports.