Prompt
How do I turn invoices and receipts into structured data?
Latest observation
Oct 11, 2026
OpenAI APIWeb search: off
Turning invoices and receipts into structured data usually means extracting key fields like vendor, date, total, taxes, line items, and payment method into JSON, CSV, or a database table.
Common approaches
1. OCR + parsing
- OCR reads text from scanned PDFs or images.
- A parser then identifies fields from the text using rules, templates, or ML.
Good for:
- Simple documents
- Fixed invoice formats
- Lower-cost pipelines
Limits:
- Struggles with varied layouts
- Line items can be messy
2. Document AI / invoice extraction services
Use managed tools that already detect fields and line items:
- Google Document AI
- AWS Textract
- Azure Document Intelligence
- ABBYY
- Rossum
- Mistral / OpenAI + OCR pipeline depending on your stack
Good for:
- Fast setup
- Many document types
- Better handling of tables and forms
3. LLM-based extraction
Use a language model to convert document text into a schema, often after OCR.
Typical flow:
- OCR or PDF text extraction
- Send text to an LLM with a strict JSON schema
- Validate output
Good for:
- Variable layouts
- Reasoning over messy text
- Normalizing fields
Important:
- Always validate and post-process
- Keep confidence scores or human review for low-confidence cases
Typical data model
For invoices:
{
"invoice_number": "INV-10023",
"invoice_date": "2026-01-15",
"due_date": "2026-02-14",
"vendor_name": "Acme Supplies",
"vendor_tax_id": "12-3456789",
"currency": "USD",
"subtotal": 120.00,
"tax": 9.60,
"total": 129.60,
"line_items": [
{
"description": "Paper ream",
"quantity": 2,
"unit_price": 20.00,
"amount": 40.00
}
]
}
For receipts:
{
"merchant_name": "Coffee House",
"transaction_date": "2026-01-15",
"time": "08:42",
"subtotal": 8.50,
"tax": 0.68,
"tip": 1.50,
"total": 10.68,
"payment_method": "Visa",
"last4": "4242",
"items": [
{
"description": "Latte",
"amount": 5.50
}
]
}
Recommended pipeline
If documents are clean and repetitive
- PDF/text extraction
- Regex/rules
- Template-based parsing
If documents are mixed and scanned
- OCR
- Layout-aware extractor or Document AI
- Schema validation
If documents are highly variable
- OCR
- LLM extraction to JSON schema
- Human review for edge cases
Practical steps
-
Define the schema
- What fields do you need?
- What’s optional vs required?
-
Extract text
- Native PDF text if available
- OCR for scanned images
-
Extract structured fields
- Rules/regex for simple patterns
- ML or LLM for ambiguous fields
- Table extraction for line items
-
Normalize
- Dates to ISO 8601
- Currency codes
- Numeric cleaning
- Vendor name canonicalization
-
Validate
- Check totals: subtotal + tax = total
- Ensure dates are plausible
- Flag missing or low-confidence fields
-
Store/export
- JSON for APIs
- CSV for spreadsheets
- SQL tables for analytics
Good practices
- Keep the original document and extracted data linked
- Store confidence scores
- Use human review for exceptions
- Log extraction errors
- Test on real samples from all vendors
If you want, I can also give you:
- a Python example using OCR + JSON extraction,
- a no-code tool comparison, or
- a schema design for invoices/receipts.