Short answer. Classify the statement, extract the header and rows into a typed schema, then prove the arithmetic: opening balance plus the sum of signed amounts must equal closing balance, and every row's running balance must follow the previous row. Parse at least 30 layouts before trusting the pipeline, mask account numbers before any model call, and send only reconciled statements downstream.
Why parsing is a reconciliation problem
A bank statement is a ledger with a built-in checksum: the running balance. That makes it different from an invoice or a receipt. You do not need to trust the model's confidence score if the arithmetic closes; you also cannot trust a high confidence score if the arithmetic does not.
The hard parts are layout, not language. Columns shift between pages, headers repeat, descriptions wrap onto a second line, debits appear in parentheses or with a trailing minus, and some institutions print a page subtotal that looks like a transaction. A parser that handles one bank's digital PDF will fail on a scanned credit-union statement with a different column order.
The 30-layout test set
Build the test set before you build the parser. Thirty layouts expose the common failure modes. Use ten institution archetypes and three formats each: a digital PDF with a text layer, a scanned PDF, and a multi-page table with repeated headers or page subtotals.
| Archetype | Digital PDF | Scanned PDF | Multi-page table |
|---|---|---|---|
| National retail bank | ✓ | ✓ | ✓ |
| Regional bank | ✓ | ✓ | ✓ |
| Credit union | ✓ | ✓ | ✓ |
| Neobank / app statement | ✓ | ✓ | ✓ |
| Business account | ✓ | ✓ | ✓ |
| Credit card statement | ✓ | ✓ | ✓ |
| Multi-currency account | ✓ | ✓ | ✓ |
| Brokerage cash account | ✓ | ✓ | ✓ |
| Payroll / prepaid card | ✓ | ✓ | ✓ |
| Legacy statement with narrow columns | ✓ | ✓ | ✓ |
Use synthetic statements for the public test harness and consented, redacted statements for the private one. Record the expected opening balance, closing balance, transaction count and total credits and debits for each file. A layout that parses but does not reconcile is a failure, not a partial pass.
Transaction schema
Use decimal strings, not floating-point numbers. Money bugs are data bugs, and a float that rounds a cent will break reconciliation. Keep the raw description and a normalised merchant name; do not overwrite the bank's text.
{
"statement_id": "stmt_01J...",
"institution": "US retail bank",
"account_id_masked": "****1234",
"currency": "USD",
"period_start": "2026-10-01",
"period_end": "2026-10-31",
"opening_balance": "1240.55",
"closing_balance": "3820.10",
"transactions": [
{
"date": "2026-10-03",
"posted_date": "2026-10-04",
"description_raw": "CARD PURCHASE 04OCT GROCERY STORE 1234",
"merchant": "Grocery Store",
"amount": "-42.19",
"direction": "debit",
"balance_after": "1198.36",
"reference": null,
"page": 2,
"row": 14,
"confidence": 0.94
}
],
"totals": {"credits": "3200.00", "debits": "620.45", "count": 47}
}
Pipeline and code
Start with the text layer. If the PDF has one, extract text with coordinates before sending anything to a model; it is cheaper and more accurate. If it is a scan, use a vision or OCR model and keep the page image alongside the text for evidence. Then extract the header and rows in separate calls so a bad header does not poison the row extraction.
import json
from decimal import Decimal
from openai import OpenAI
client = OpenAI(api_key="PLUGSKY_KEY", base_url="https://api.plugsky.com/v1")
resp = client.chat.completions.create(
model="plugsky-parse",
response_format={"type": "json_object"},
messages=[
{"role": "system", "content": "Extract the statement header and every transaction row. Return JSON. Use negative amounts for debits. Copy descriptions exactly."},
{"role": "user", "content": page_text},
],
)
stmt = json.loads(resp.choices[0].message.content)
opening = Decimal(stmt["opening_balance"])
closing = Decimal(stmt["closing_balance"])
credits = sum(Decimal(t["amount"]) for t in stmt["transactions"] if Decimal(t["amount"]) > 0)
debits = sum(Decimal(t["amount"]) for t in stmt["transactions"] if Decimal(t["amount"]) < 0)
assert opening + credits + debits == closing, "statement does not reconcile"
The assertion is the product. If it fails, do not send the ledger to accounting. Route the statement to a review queue with the page and row evidence, and fix the parser before retrying.
Running-balance and multi-page validation
Validate at three levels. First, the statement: opening + sum(signed amounts) = closing. Second, each row: previous balance + amount = this balance. Third, the sequence: dates are non-decreasing, row numbers are contiguous within a page, and no transaction appears twice.
Multi-page statements need care. Repeat the header on each page, parse rows with the account and period in context, then stitch by page order. Drop repeated headers and page subtotals before summing. Join a wrapped description only when the amount and balance columns are empty on the first fragment; otherwise you merge two real transactions.
PII and data handling
Bank statements contain names, addresses, account numbers, card fragments and a detailed spending history. Treat all of it as personal data. Mask the account number before storage, encrypt the raw file at rest, restrict access to the reconciliation team, and set a retention period that matches your policy and the customer's consent.
Do not put a full account number in a prompt. Redact it in the text layer or parse inside your environment. Log the masked identifier, file hash and parser version, not the raw statement. Confirm retention and training terms in the contract; do not assume zero retention.
Financial data may attract sector rules beyond a standard DPA. This is an engineering guide, not legal advice; have counsel and security review the data flow.
Reconciliation, accuracy and cost
Reconciliation matches each parsed bank transaction to a ledger entry. Start with exact amount and date, then widen the date window and use the reference or counterparty for the remainder. Route unmatched items to a human queue with a reason code: missing in ledger, duplicate, amount mismatch, date mismatch or parse failure.
Report accuracy by layout and field, not an aggregate. Track row detection, date and amount accuracy, balance continuity, duplicates and reconciliation match rate. One aggregate number hides that difference. Publish per-layout results.
Cost is driven by pages and vision. A 5-page statement at 1,200 tokens per page is 6,000 input tokens; 100 statements is 600,000 input tokens. Plugsky Hobby is $8 per month with 2 million tokens per day, so the batch fits a day within the request cap. Scans and retries cost more; Starter is $20 and Builder $60.
FAQ
Can an LLM parse bank statements accurately?
It can extract most fields, but accuracy depends on layout variety, scan quality and whether you validate the result. Use a text-layer PDF when available, require page and row evidence, and reject any statement whose running balance does not reconcile.
How do I handle multi-page statements?
Parse each page with its header context, stitch rows by statement ID and page order, drop repeated headers, and validate the running balance across page boundaries. A page-level extraction that looks correct can still break the sequence.
What is running-balance validation?
It checks that opening balance plus signed amounts equals the closing balance, and that each row's balance equals the previous row's balance plus or minus that row's amount. A break means a missing row, a duplicated row or a parsing error.
How should I handle account numbers?
Mask or tokenise them before storage and before any model call, keep the raw document in an access-controlled store, and log only the masked identifier. Treat names, addresses and transaction descriptions as personal data too.
What does parsing 100 statements cost?
A 5-page statement at about 1,200 tokens per page is roughly 6,000 input tokens, so 100 statements is about 600,000 input tokens plus output. That fits inside Plugsky Hobby at $8 per month if the daily request and token caps are respected; scanned pages and vision models cost more.
Reviewed 20 November 2026. Sources checked 20 November 2026: statement structure against the ISO 20022 message catalogue; PII guidance against NIST SP 800-122; consumer data-access context against the CFPB. No vendor accuracy claim is made; measure on your own layouts. PII and retention rules require counsel review.