cd /news/developer-tools/why-i-built-a-zero-upload-credit-car… · home › topics › developer-tools › article
[ARTICLE · art-175356] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

Why I Built a Zero-Upload Credit Card Statement Splitter with Vanilla JS and CSP default-src 'none'

A developer built StatementUnpack, a fully client-side credit card statement splitter that runs on static HTML, CSS and vanilla JavaScript with no upload endpoints, enforcing a strict Content-Security-Policy (default-src 'none') and vendoring pdfjs-dist locally with pinned SHA-256 hashes. The tool parses currency into integer cents as BigInt for deterministic reconciliation, halts export with a structured review-only.json report when balances don't reconcile, and separates untrusted text cells from validated numeric fields to block CSV formula injection while preserving legitimate negative amounts for QuickBooks.

recommendation

Reconcile every parsed statement against opening and closing balances and halt export with a structured review report rather than guessing, and sanitize text cells for formula prefixes while leaving validated numeric fields untouched.

more in playbook: Verifying model output
by read3 min views2 publishedNov 24, 2026

If you have ever helped a small business or bookkeeper do catch-up bookkeeping for a corporate credit card with multiple employee cards, you have probably seen two painful things happen:

Debit and Credit columns, or I wanted to see how far you can push a 100% client-side, zero-upload bookkeeping utility using plain static HTML, CSS, and vanilla JavaScript—with zero backend upload endpoints and deterministic verification instead of probabilistic AI guesses.

The result is StatementUnpack—and along the way, I ran into several surprisingly subtle engineering and security details worth sharing.

Saying "we don't upload your files" on a landing page is easy. Making it verifiable in DevTools is much better.

StatementUnpack ships as pure static files with a strict Content-Security-Policy header on every route:

Content-Security-Policy:
  default-src 'none';
  script-src 'self';
  style-src 'self';
  worker-src 'self';
  connect-src 'self';
  img-src 'self';
  base-uri 'none';
  form-action 'none';
  frame-ancestors 'none'

What this enforces in practice:

pdfjs-dist@5.6.205) and its worker are vendored locally on the same origin and verified against pinned SHA-256 hashes at build time.form-action 'none' and connect-src 'self' block accidental data exfiltration to external domains.File.arrayBuffer() / File.text(), processed in browser memory, and exported locally as Blob downloads. You can open Chrome DevTools → (Full disclosure: the site does load Vercel's cookie-free, same-origin Web Analytics script /_vercel/insights/script.js for basic anonymous pageview counts—never file names, file contents, or transaction data.)

BigInt Cent Math Matters for Financial Parsing A surprising number of quick-and-dirty statement parsers parse currency strings with parseFloat(). That works right up until a 40-transaction statement fails an opening/closing balance check by $0.0000000000000284.

In the PDF parser (parser.js), every dollar amount is normalized directly into integer cents as a BigInt before any arithmetic runs:

const cents = value => BigInt(value.replace(/[,.]/g, ''));

const format = cents => {
  const parts = (cents < 0n ? -cents : cents).toString().padStart(3, '0');
  return (cents < 0n ? '-' : '') + parts.slice(0, -2) + '.' + parts.slice(-2);
};

Combined with deterministic column boundaries and per-account reconciliation (previousBalance + netTransactions === newBalance), the PDF splitter refuses to silently drop a row or guess a missing figure. If anything doesn't reconcile—or if a file is an unsupported layout or scanned image—it halts export and produces a structured review-only.json report instead.

Here is a security edge case that bites almost every CSV exporter: CSV / Spreadsheet Formula Injection.

If an untrusted merchant description or cardholder label starts with =, +, -, @ (or their full-width Unicode equivalents =, +, -, @, even after leading whitespace or a UTF-8 BOM), opening the exported CSV in Excel or Google Sheets can trigger formula execution.

At the same time, QuickBooks credit card CSVs require legitimate negative numbers like -42.50 in the Amount column!

So instead of blindly prefixing every cell with an apostrophe (which corrupts numeric Amount columns in QuickBooks), StatementUnpack separates untrusted text cells from validated numeric fields:

const FORMULA_PREFIX = /^[=+\-@=+-@]/u;
const CONTROL_CHARS = /[\x00-\x1f\x7f-\x9f]/u;

export function isSafeCell(value) {
  const str = String(value ?? '');
  return (
    !CONTROL_CHARS.test(str) &&
    !FORMULA_PREFIX.test(str.replace(/^[\s\uFEFF]+/u, ''))
  );
}

Amount values are formatted strictly as numeric decimals (-42.50 or 120.00). Date, Description, cardholder name) and filename is checked against FORMULA_PREFIX and CONTROL_CHARS. innerHTML) and Parsing untrusted PDFs inside a user's browser carries its own DoS/security risks: PDF JavaScript actions (OpenAction), XFA forms, huge page counts, or console-log leakage of raw PDF tokens.

To keep browser parsing predictable:

10 MiB, max 20 pages, a 30s soft timeout, max 35,000 extracted text items, and max 2,097,152 UTF-16 code units. I want to be completely transparent about what is validated today versus what isn't:

Card Member / Cardholder / Card No. columns and splits combined corporate card CSVs into one 3-column CSV per card.$/commas/parentheses/ CR/ DR, and flips reversed QuickBooks Online signs in one click. If you want to poke at the CSP headers, inspect the Network tab, or test the CSV splitter with a dummy/redacted business card export:

👉 Try the CSV Splitter (any bank): https://statementunpack.com/tools/csv-splitter/

👉 Try the PDF Splitter Demo: https://statementunpack.com/

Before I build PDF parsers for additional banks, I'm trying to learn from real-world workflows:

Drop a comment below—blunt technical or UX feedback is super welcome!

── more in #developer-tools 4 stories · sorted by recency
── more on @statementunpack 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/why-i-built-a-zero-u…] indexed:0 read:3min 2026-11-24 · —