How it works

From PDF to validated JSON, in five steps.

Whether you build the template yourself, generate one from samples, or hand it to our team, every extraction follows the same path. Walk through it below.

Step 01 of 05Plan the build

Different documents need different approaches.

Whether you're building this in-house, with a different vendor, or with us, every extraction project starts the same way: by reviewing the documents you're trying to parse. Click any question to see why it matters.

Why it matters

Document type drives method choice. Sometimes counterintuitively.

Stable forms work well with layout templates. Free-text fields need AI. But the most complex documents often want layout methods: a loss run with repeating headers or an EOB with merged cells needs a deterministic table parser, since AI would hallucinate rows.

  • Stable forms (ACORD, W2): layout templates
  • Complex tables (loss runs, EOBs): layout-based table parsers for high accuracy
  • Free-text or mixed packets: AI methods, with portfolio splitting if multi-doc
Why it matters

The JSON shape is the contract. Design it first.

Define the fields you need, the types your code expects, and what's required up front. The rest of the build is just satisfying that contract on every document. No mapping layer, no transformation logic, no busy work after extraction.

  • Match what your database or downstream API already expects
  • Skip a mapping step when the JSON is right from the start
  • Same schema whether you build it yourself or we build it
Why it matters

The risk profile shapes thresholds and validations.

Some fields are advisory (a category tag on an invoice). Others are decision-critical (a loan amount on a packet that's about to be approved). Knowing which is which up front sets the right confidence thresholds, the right validation rules, and decides what gets queued for human review.

  • High-stakes fields get tight thresholds + JsonLogic validations
  • Low-stakes fields can ship at lower confidence
  • Sets how aggressive your fall-back chains need to be
Why it matters

Volume and destination shape how the data is delivered.

A real-time application processing thousands of docs daily integrates differently than an ops team running 50 packets a week. Where the data lands also matters: a queue, a database, a spreadsheet, an MCP-aware editor, an API your code consumes.

  • High volume, real-time: webhook push into your queue
  • Batch processing: REST pull or scheduled extracts
  • AI-editor workflows: MCP into Claude Code, Cursor, or any MCP-aware tool
  • Smaller volumes: spreadsheet export or direct database write
Step 02 of 05Build the template

Templates combine layout-based and AI-based methods.

Based on what you found in step 1, you'll mix and match. Layout methods are fast and deterministic. Use them where the field is stable and labeled. AI methods handle free-text, variable layouts, or fall-backs when layout misses. Same field, two ways below.

Anchor on a row containing "Closing Date" and pull the value from the same horizontal band. Works for table-style layouts where the value sits next to a labeled row, even when it isn't the next token.

config.jsonmethod · row
{
  "fields": [
    {
      "id": "closing_date",
      "anchor": {
        "match": [
          { "text": "Closing Date", "type": "includes" }
        ]
      },
      "method": {
        "id": "row",
        "position": "right"
      },
      "type": "date"
    }
  ]
}

More layout-based methods beyond row — anchor, region, label, paragraph, signature, and others. See the full set: Layout-based methods →

Ask an LLM, scoped to the most relevant page. Use when the label moves between lender versions, when the field is free-text, or as a fall-back when the layout method misses.

config.jsonmethod · queryGroup
{
  "fields": [
    {
      "method": {
        "id": "queryGroup",
        "searchBySummarization": "page",
        "queries": [
          {
            "id": "closing_date",
            "description": "What is the closing date of this loan?",
            "type": "date"
          }
        ]
      }
    }
  ]
}

More AI-based methods beyond queryGroup — query, single-line, line-aware extraction, and others. See the full set: LLM-based methods →

Step 03 of 05Production workflow

What every document goes through, end to end.

Ten stages, in order, every time. Some run only when needed. Click through to see what happens at each one.

Document inJSON out
Stage 01 · Ingest

The file arrives. The format gets normalized.

The document hits the API. Sensible figures out what it's working with: PDF, image, Word doc, spreadsheet, email, or a mixed packet. Where a page already contains digital text (most modern PDFs do), the text is extracted directly. Where it doesn't, the page is queued for OCR in the next stage. The routing decision happens page by page, not per file.

In practice · 4-page loan packet
  • Pages 1 and 2 contain digital text, extracted directly with no OCR needed
  • Pages 3 and 4 are scanned images, queued for OCR in the next stage
  • Accepted formats: PDF, PNG, JPG, TIFF, DOCX, XLSX, CSV, EML
Stage 02 · OCRConditional

Pixel reading for image content.

For pages that arrived as images (full scans, photos, or scanned sections of a mixed packet), Sensible runs OCR. The engine is configurable per document type: Amazon, Google, or Microsoft. OCR returns confidence per character, not per page, so a smudged signature or a low-res stamp can't silently produce a confident wrong answer.

In practice · scanned page 3
  • "Closing Date: Aug 12, 2026" reads at 0.97 confidence (clean printed text)
  • "Borrower signature: J. Park" reads at 0.71, handwriting, flagged downstream
  • Per-character confidence is preserved, not collapsed to a page-level score
Stage 03 · SplitConditional · multi-doc

One file, several documents inside.

Loan applications often arrive as portfolios: the application packet plus tax returns plus paystubs, all bundled in one upload. Sensible detects boundaries between documents and segments them by page range. From here on, each segment is processed independently with its own config.

In practice · 8-page portfolio
  • Pages 1 to 4 detected as a Loan Application
  • Pages 5 to 6 detected as a Tax Return 1040
  • Pages 7 to 8 detected as Paystubs (two of them)
  • Each segment runs through its own classify, preprocess, and extract pipeline
Stage 04 · Classify

Pick the right config for each document.

Each segment is classified to determine which extraction config to run. Classification can be LLM-based (matching against the names and descriptions of your configured document types) or layout-based (matching against anchor patterns unique to each type). LLM classification works even when a document type doesn't have a reference document yet, because the model can match against the description alone.

In practice · classifying 2 segments
  • Segment 1 matched Loan Application at 0.95 confidence, runs loan_packet.yml
  • Segment 2 matched Tax Return 1040 at 0.89 confidence, runs tax_return.yml
  • If no type clears the threshold, the document is flagged as unclassified instead of running a wrong config
Stage 05 · Preprocess

Clean the input before extraction runs.

Each document type can specify a preprocessor pipeline that runs in the order you define. Preprocessors handle the practical messiness of real documents: scans tilted a few degrees, watermarks blocking text, lines that wrapped mid-sentence, multicolumn pages that need to be read column-wise rather than left-to-right.

In practice · what ran on the loan packet
  • deskew rotated page 3 by +2.4° to vertical
  • watermarkRemoval stripped "CONFIDENTIAL" from page 2
  • mergeLines rejoined 4 sentences that wrapped across page breaks
  • multicolumn read page 4 column-wise instead of row-by-row
  • headerFooter excluded repeating page numbers from extraction
Stage 06 · Extract

Run the right method for each field.

This is where Sensible actually pulls the data out. Each field in your config specifies a method. Layout-based methods (anchor on a label, pull from a region, parse a table) are fast and deterministic, and handle most fields in most documents. AI-based methods are used when a field is free-text, when its position varies, or as a fall-back when a layout method misses. Many fields use a chain: try layout first, fall back to AI when it fails.

In practice · two fields from the loan packet
  • borrower_name uses the row method anchored on "Borrower" and returns "Jordan A. Park" on the first try
  • closing_date tries row but the anchor moved in this lender's version. Falls back to queryGroup (an LLM query scoped to the relevant page) and returns "Aug 12, 2026"
Stage 07 · Compute

Coerce types. Build derived fields.

Extracted values come out as strings. This stage normalizes them to the types your schema expects. Currency strings become numbers with currency tags. Date strings become ISO format. Addresses get parsed into structured components. Computed fields combine multiple extractions into new values, like full_name from first plus last, or total from a sum of line items.

In practice · type coercions on this document
"$485,000.00"485000.00 USD
"Aug 12, 2026""2026-08-12"
"360 months"360
"CA 94705"{ state: "CA", zip: "94705" }
Stage 08 · Validate

Custom rules catch values that don't fit.

Confidence catches uncertain extractions. Validations catch certain extractions that don't make sense in context. Rules are written in JsonLogic and check things like cross-field math (total equals sum of line items), date ordering (closing date after application date), and enum membership (state in the list of valid US states). When a rule fails, the document is flagged.

In practice · 4 rules on this document
  • loan_amount > 0passes
  • closing_date >= application_datepasses
  • property_state in valid_statespasses
  • closing_date.confidence >= 0.85fails at 0.83, document queued for review
Stage 09 · Score

Per-field confidence travels with the response.

Every field comes back with a confidence score. For OCR'd content, two signals are reported: anchor confidence (how sure Sensible is about where on the page the field lives) and value confidence (how sure about what was extracted). For AI-based queryGroup fields, additional confidence signals are returned from the model itself. Your code uses these scores against the per-field thresholds you set: above clears, below queues for review.

In practice · scores from this document
Stage 10 · Return

The final JSON, ready for your code.

The response is shaped exactly like the schema you defined. Each field carries its typed value and the page plus bounding box where Sensible found it. For multi-document portfolios, the response is structured per-document with page ranges.

In practice · how the JSON gets to you
  • Webhook for real-time push, into Zapier, n8n, or your own queue
  • REST API for pull-based batch processing
  • SDK for Node or Python
  • MCP for AI-editor workflows in Claude Code, Cursor, or any MCP-aware tool
  • Spreadsheet export to CSV or Excel
  • Database write directly to Postgres, BigQuery, or Snowflake
Step 04 of 05Get the data out

Delivered the way your stack expects.

Webhook, REST, SDK, MCP, spreadsheet, database. Each field comes back with its value, type, and the page it came from.

Webhook

Real-time push. Connects to Zapier, n8n, your queue.

REST API

Submit, poll, get JSON. Useful for batch jobs.

SDK

Native libraries: Node and Python.

Spreadsheet

CSV or Excel export to Google Sheets, ops tools.

MCP

Connect via Sensible's MCP server in Claude Code, Cursor, or any MCP-aware editor.

Custom

Anything else. Webhook into your queue and route from there.

Step 05 of 05Monitor what's running

What it's like to run this in production.

Three things keep the pipeline honest day-to-day. The same three regardless of whether you built the template or our team did.

Production pipelineHealthy
01
Validations

Rules check every extraction.

JsonLogic rules run on every document. Cross-field math, date ordering, enum membership, format checks. When a rule fails, the document is flagged before it reaches your downstream systems.

Sample rules
loan_amount > 0Pass
closing_date >= app_datePass
confidence >= 0.85Flag
02
Human review

Flagged docs queue, not your customer.

When a confidence score or rule trips, the document goes to a review queue with one-click accept, correct, or reject. Corrections feed your reference set so the same edge case stops reaching review next time.

Reviewer actions
Accept value as-is→ ship
Correct value→ refeed
Reject document→ block
03
Monitor

A live dashboard tracks every extraction.

Browse every extraction across production and development, filterable by date range. Click into any document to inspect field-by-field results and trace each value back to its source coordinates.

Tracked signals
Extraction coverageAll fields
Volume + config usageBy date
Recent extractionsFilterable
Outsource the work

Steps 1 through 5 are the work. We can do every one of them for you.

If extraction is critical to your product but isn't what your team wants to focus on, our solutions engineering team handles each step on your behalf. You see clean JSON in your API response.

What managed services covers
  • Step 1 · Plan: Solutions engineers review your document types and recommend the approach
  • Step 2 · Build: We write the SenseML configs from your samples, mixing layout and AI methods
  • Step 3 · Production: Configs deploy and run through the same engine as self-serve
  • Step 4 · Delivery: JSON delivered however your stack expects (webhook, REST, SDK, MCP, spreadsheet, DB)
  • Step 5 · Monitor: We help build validations, handle drift, and update configs when extraction errors emerge

Trusted by teams turning documents into production data