Extract structured data from a document

The extraction prompt that gives you parseable JSON on the first try — including what to do when a field is missing.

When to use it

Pulling structured records out of a document when the output feeds code rather than a person.

What it prevents

Helpful inference. Without an explicit null rule, models fill missing fields with plausible guesses — and a plausible guess in a finance pipeline is worse than a blank, because nothing downstream can tell it apart from real data.

The prompt

Copy this, then adapt it
Extract every invoice from the statement below.

### Output format
Return JSON and nothing else: [{"invoice": "string", "total": 0.00, "date": "YYYY-MM-DD"}]

### Requirements
- If a field is not present in the source, use null. Do not infer it.
- Preserve the invoice reference exactly as written, including any leading zeros.

### Example
[{"invoice": "INV-0104", "total": 82.50, "date": "2026-03-01"}]

### Statement
"""
INV-0104  01/03/2026  82.50
INV-0105  02/03/2026  19.00
"""

Instant checks

9 key structural practices evaluated locally

100% Coverage7/7
  • States a concrete task

    Passed
  • Avoids vague language

    Passed
  • Specifies an output format

    Passed
  • Avoids dangling references

    Passed
  • Includes an example

    Passed
  • Separates data from instructions

    Passed
  • Avoids over-aggressive phrasing

    Passed
Not a claim — the real checker, run on this prompt, in your browser.

Why each part is there

Every section of that prompt exists because a specific failure happens without it. These are the checks it passes, and what each one is protecting you from:

How to adapt this one

Change the fields in the JSON shape and the example, and keep the null rule word for word: “if a field is not present, use null — do not infer it”. In an extraction that feeds code, a confident guess is more dangerous than a blank, because nothing downstream can tell an inferred value from a real one. The example row is not decoration; it pins the exact types you expect.

The mistake this prompt avoids

Omitting the null rule and getting helpful guesses. Ask a model to extract a field that is missing and it will supply a plausible value rather than admit the gap — a made-up date, a rounded total. In a pipeline, that plausible guess is the bug you find three weeks later in a reconciliation report. Forbid inference explicitly.

A variation

Extracting from scanned or OCR’d documents, where a field might be present but unreadable? Add a third state — “null for absent, the string “unclear” for present-but-illegible” — so a review queue can tell a genuinely missing field from one the OCR mangled. Collapsing both into null throws away the signal that tells you which pile to look in.

Check your version

Once you have adapted it, run it through the checker. The same nine checks that graded this page will grade yours, free and in your browser — paste it in, or build one from scratch by answering a few questions.

More extraction prompts