Extract document data to JSON with a schema and validation

Turn invoices, contracts or forms into valid JSON against a defined schema, with missing fields as null, normalized dates and amounts, and a list of uncertain fields to review. Designed for ChatGPT, Claude, Gemini and Microsoft Copilot. It includes 4 customizable variables and you can copy it for free in one click.

Advanced · Text · Pending editorial review

Prompt

Act as a data engineer who specializes in extracting information from documents with language models.

Context:
- Document type: {{document_type}}
- Fields I need: {{fields}}
- Output structure: {{structure}}
- Document text:
"""
{{document_text}}
"""

Deliverables:
1. A JSON Schema (2020-12) for the requested fields, with types, formats and required fields. Normalize dates to ISO 8601 (YYYY-MM-DD), amounts as numbers without symbols and currency as an ISO 4217 code.
2. Extraction: valid JSON that matches the schema, with data taken only from the document.
3. Review block: a list of fields you left as null, found ambiguous or normalized, with the literal snippet from the document that supports each one.
4. Consistency checks: for example, that line items add up to the total, that dates make sense or that the tax ID has a plausible format. Report only what does not add up.
5. A reusable prompt to batch-process more documents of the same type, with the schema included.

Constraints:
- Never infer or fill in data: if a field does not appear, its value is null.
- The JSON in deliverable 2 must be valid: no comments, no trailing commas and no mixed-in text.
- If the document does not look like the stated type or is incomplete, say so before extracting.
- If the requested fields are ambiguous (for example, "date" without saying which), ask me first.
- If the document contains personal data, remind me to handle it under the applicable data protection rules.

Format: each deliverable under its own heading and the JSON in separate code blocks.

How to use it

Paste the document text (or upload it if your tool accepts files) and list the fields using the names your system expects. Validate the JSON against the schema before importing and always check the review block.

Usage example

Document: supplier invoice · Fields: number, issue date, supplier, tax ID, subtotal, sales tax, total, line items · Structure: one object per document.

Sample output

1. Schema (excerpt)

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "required": ["invoice_number", "issue_date", "supplier", "total"],
  "properties": {
    "invoice_number": { "type": "string" },
    "issue_date": { "type": "string", "format": "date" },
    "supplier": { "type": "string" },
    "tax_id": { "type": ["string", "null"] },
    "subtotal": { "type": "number" },
    "sales_tax": { "type": "number" },
    "total": { "type": "number" },
    "currency": { "type": "string", "pattern": "^[A-Z]{3}$" },
    "line_items": { "type": ["array", "null"] }
  }
}

2. Extraction

{"invoice_number": "2026-0147", "issue_date": "2026-11-03", "supplier": "Lakeside Supply LLC", "tax_id": "12-3456789", "subtotal": 1200.00, "sales_tax": 96.00, "total": 1296.00, "currency": "USD", "line_items": null}

3. Review

  • line_items: null; the text has no descriptions or quantities.
  • issue_date: normalized from "11/03/2026", read as month/day (US format). Confirm if the supplier uses day/month.
  • tax_id: "EIN 12-3456789" kept without the prefix.

4. Consistency checks

1,200.00 + 96.00 = 1,296.00 ✔ and 8% of the subtotal is 96.00 ✔. Line items are missing, so the per-line sum can't be checked…

Key facts

Category
Business automation · Internal assistants
Output type
Text
Level
Advanced
Designed for
ChatGPT, Claude, Gemini and Microsoft Copilot
Verified in
Pending editorial verification
Variables
Document type, Fields, Output structure and Document text
Language
English
Price
Free, no sign-up
Updated
Nov 7, 2026

Frequently asked questions

Why use null instead of leaving a field empty?

Null clearly says the data is not in the document, while an empty string or a zero can be mistaken for a real value and slip into your accounting or reports.

Can I automate this for hundreds of documents?

Yes, with the reusable prompt and an API. Validate each response against the schema in code and send any that fail or have uncertain fields to manual review.

What is this prompt for?

Turn invoices, contracts or forms into valid JSON against a defined schema, with missing fields as null, normalized dates and amounts, and a list of uncertain fields to review.

Which AI tools does it work with?

It is designed for ChatGPT, Claude, Gemini and Microsoft Copilot. We have not verified it in these tools yet, so results may vary between them.

How do I customize the prompt?

Click “Customize” and fill in the variables (Document type, Fields, Output structure and Document text). The text updates instantly and you can then copy it in one click. Values are stored only in your browser.

Do I need experience to use it?

It is advanced: it is meant for people with experience in the topic who can evaluate and adjust the result.

Is this prompt free?

Yes. Every HomeCasa Prompts prompt is free, with no sign-up or subscription. You can also use them in professional projects.

Can I trust the AI output?

Treat it as a high-quality draft: always check data, figures and important claims before publishing or making decisions.

Related prompts