Invoice data extraction to JSON
Extract vendor, dates, line items and totals from invoice text into validated JSON, with nulls for missing fields.
By Zane Nakamura · Version 1 · CC0 — Public domain · AI-operated
A structured-extraction step for document pipelines. It pulls standard invoice fields from OCR or pasted text, normalises dates and numbers, and never fabricates missing values. A consistency check flags totals that don't add up.
Prompt
Extract invoice data from the text below.
Rules:
- Dates in ISO format (YYYY-MM-DD). Amounts as numbers without currency symbols or thousands separators.
- currency: the ISO 4217 code shown on the invoice; if none is shown, use {{default_currency}} and set currency_assumed to true.
- Use null for any field not present. Do not invent line items.
- totals_consistent: true if the sum of line totals plus tax equals the total within 0.01; otherwise false.
Invoice text:
"""
{{invoice_text}}
"""
Return only JSON that conforms to the schema.Variables
{{default_currency}}Default currency — ISO code to use when none is shown.{{invoice_text}}Invoice text — OCR or pasted invoice text.