DEV Community

DEUS Automations
DEUS Automations

Posted on

Turning a folder of PDFs into a webhook that returns JSON

Turning a folder of PDFs into a webhook that returns JSON (no OCR infra to run)

If you've ever had to pull data out of PDFs at scale — invoices, ID scans, scanned forms, shipping manifests — you know the annoying part isn't the OCR itself, it's everything around it: standing up a service, handling the queueing, storing the output somewhere useful, and doing it all without paying for a $200/mo document-AI SaaS for what's often a low-volume internal tool.

I ended up solving this with a single n8n workflow instead of a custom service, and it turned out simpler than I expected, so here's the shape of it in case you're about to build the same thing from scratch.

The pipeline

  1. Webhook in — POST a PDF URL (or upload) to a single endpoint.
  2. OCR — the file goes to OCR.space, which has a genuinely usable free tier (25k requests/month, no card required). No self-hosted Tesseract, no GPU, no Docker image to maintain.
  3. Text → structure — the raw OCR text gets parsed into a best-effort table: rows, columns, a JSON array, and a CSV export, using a mix of layout heuristics on the OCR bounding boxes.
  4. Log (optional) — every extraction gets appended to a Google Sheet automatically, so you get a free audit trail without adding a database.
  5. Response — the webhook returns plain text + structured JSON + CSV, so any app, script, or Zapier/Make alternative can call it directly.

The part worth calling out: because OCR.space is a hosted API, the whole thing runs with zero infrastructure of your own — n8n is the only thing you need to keep running, and if you already use n8n for other automations, this is just one more workflow, not a new service to babysit.

Where this breaks down

Layout-heavy PDFs (multi-column, dense tables with merged cells) will always need some manual review — no OCR pipeline gets that free. This is aimed at the 80% case: invoices, forms, receipts, single-column reports, where "close enough JSON" saves someone an afternoon of manual data entry.

If you'd rather not build it

I packaged the exact workflow — webhook, OCR.space call, structuring logic, optional Sheets logging — as a ready-to-import n8n template:

👉 https://shop.lumnika.com/pdf-ocr-extractor.html?utm_source=devto&utm_medium=article&utm_campaign=pdf-ocr

$19.99, one-time, JSON file you import into your own n8n instance — no subscription, no vendor lock-in, you can edit every node.

Curious if anyone here has fought with layout-heavy PDF extraction and found a heuristic that actually holds up — table detection is still the weakest link in every pipeline I've tried.

Top comments (0)