
invoice2data
CLI从 PDF 发票中按 YAML/JSON 模板抽取开票方、金额、日期、票号等字段,导出 CSV、JSON 或 XML;内置多种文本抽取后端,支持扫描件 OCR 与可选的 AI 兜底。
Data extractor for PDF invoices - invoice2data
A command line tool and Python library that automates the extraction of key information from invoices to support your accounting process. The library is very flexible and can be used on other types of business documents as well.
In essence, invoice2data simplifies getting data from invoices by:
- Automating text extraction — no more manual copying and pasting.
- Using templates for structure — handles different invoice layouts.
- Providing structured output — data ready for analysis or further processing.
This makes it a valuable tool for businesses and developers dealing with a large volume of invoices, saving time and reducing manual-entry errors. It:
- extracts text from PDF files with a pluggable, cascading backend —
pdfium(default, no system deps),pdftotext,text,pdfminer,pdfplumber, or OCR (tesseract,ocrmypdf,docTR,paddleocr,gvision). - searches for regex in the result using a YAML or JSON-based template system (with an optional AI fallback).
- saves results as CSV, JSON or XML, or renames PDF files to match the content.
With the flexible template system you can:
- precisely match content PDF files
- plugins available to match line items and tables
- define static fields that are the same for every invoice
- define custom fields needed in your organisation or process
- have multiple regex per field (if layout or wording changes)
- define currency
- extract invoice-items using the
lines-plugin developed by Holger Brunn
Go from PDF files to this:
{'issuer': 'QualityHosting', 'amount': 34.73, 'date': datetime.datetime(2014, 5, 7, 0, 0), 'invoice_number': '30064443', 'currency': 'EUR', 'desc': 'Invoice 30064443 from QualityHosting', 'template_name': 'com.qualityhosting.yml'}
{'issuer': 'Amazon EU', 'amount': 35.24, 'date': datetime.datetime(2014, 6, 4, 0, 0), 'invoice_number': 'EUVINS1-OF5-DE-120725895', 'currency': 'EUR', 'desc': 'Invoice EUVINS1-OF5-DE-120725895 from Amazon EU'}
{'issuer': 'Amazon Web Services', 'amount': 4.11, 'date': datetime.datetime(2014, 8, 3, 0, 0), 'invoice_number': '42183017', 'currency': 'USD', 'desc': 'Invoice 42183017 from Amazon Web Services'}
{'issuer': 'Envato', 'amount': 101.0, 'date': datetime.datetime(2015, 1, 28, 0, 0), 'invoice_number': '12429647', 'currency': 'USD', 'desc': 'Invoice 12429647 from Envato'}
Quickstart
pip install invoice2data
invoice2data invoice.pdf # extract -> CSV
invoice2data --output-format json invoice.pdf # or JSON / XML
As a Python library:
from invoice2data import extract_data
result = extract_data("invoice.pdf")
No system libraries are required by default — the pdfium backend bundles its own
engine. Optional backends and extras (poppler, OCR, AI, ...) are covered in the
installation guide.
Documentation
Full documentation: https://invoice2data.readthedocs.io/
- How it works — the extraction pipeline
- Installation — backends, OCR and optional extras
- Usage — all CLI options and common tasks
- Template creation — write templates for your invoices
- Recommended fields — the canonical output schema
- AI features — optional LLM fallback & template generation
- FAQ — including a comparison with other tools
Development
If you are interested in improving this project, have a look at our contributor guide to get you started quickly.
Roadmap and open tasks
Everything that used to live here has shipped:
- online OCR — Google Cloud Vision, plus local DL backends docTR and PaddleOCR
- guess parameters for new invoice formats —
invoice2data --new-template SAMPLE(deterministic, no AI needed) - ML-assisted template creation —
invoice2data --new-template SAMPLE --ai(AI-1) and runtime--ai-fallback(AI-2); see the AI features page - per-field data cleanup — the
replace:key on each field - advanced table parsing — opt-in Camelot plugin (
pip install invoice2data[camelot]), plus an Excalibur → template converter
Currently open on the tracker:
- Non-invoice document schemas (waybills, delivery notes, purchase orders): the
per-template
required_fields:override lets a template opt out of the invoice-shaped default today, but canonical schemas for other document types are still deferred. - Visual template builder in Odoo — community-driven via OCA/edi
(
account_invoice_import_invoice2data_db_templates, in review). Wraps the authoring APIs listed above in a click-to-suggest UI on top of the disk templates. - Tighter identifier validators via python-stdnum — deferred pending Odoo core's stdnum version alignment.
Issues and pull requests welcome on any of these.
Maintainers
Contributors and Credits
- Harshit Joshi: As Google Summer of Code student.
- Holger Brunn: Add support for parsing invoice items.
Contributions are very welcome. To learn more, see the Contributor Guide.
Used By
- Odoo, OCA module account_invoice_import_invoice2data
Related Projects
- OCR-Invoice (FOSS | C#)
- DeepLogic AI (Commercial | SaaS)
- Docparser (Commercial | Web Service)
- A-PDF (Commercial)
- PDFdeconstruct (Commercial)
- CVision (Commercial)
相关资源

OCRmyPDF
CLI给扫描版 PDF 加上可搜索、可复制的文字层,可自动纠偏、旋转并优化体积,默认输出 PDF/A。基于 Tesseract,支持 100 多种语言,完全本地运行。
ocrmypdf/OCRmyPDF35.1k
pdfplumber
CLI精确读取电子版 PDF 中每个字符、线条和表格框的位置:命令行可导出保留版面的文字或 CSV / JSON 明细,Python 接口还能抽取表格和表单字段,适合从发票、对账单、报表里取数。需 Python 环境,本地运行;不适合扫描件,需先 OCR。
jsvine/pdfplumber10.8k
factur-x
CLI法德电子发票标准 Factur-X(即 ZUGFeRD 2.x)的 Python 库,自带命令行:把普通 PDF 发票和 XML 合成为 Factur-X 发票、从发票 PDF 中取出 XML,并按官方 XSD 校验;也支持 Order-X 订单与 UBL 格式。需本机安装 Python 3。
akretion/factur-x311
PDF
Skill读取与提取 PDF 文本和表格,合并、拆分、旋转页面,加水印、填写表单,并能对扫描件做 OCR。驱动 Claude 文档能力的 Anthropic 官方技能,源码可见但非开源。
anthropics/skills182k
Invoice Organizer
Skill读取杂乱的发票和收据(PDF、扫描件、截图),提取商家、日期、金额,按统一格式重命名并按供应商、类别或年份归档,保留原件,可汇总成 CSV 交给会计;需在 Claude Code 等能读写本地文件的 agent 里用,无需账号,税务结论需会计复核。
ComposioHQ/awesome-claude-skills77.2k
AP Processor
SkillAnthropic 官方小微企业技能,帮老板或会计处理应付账单:从邮箱、PDF 或手机照片读出供应商、金额和到期日,去重、按科目编码、核对采购单后拟定付款计划;入账和付款各需一次确认,绝不自动付款。可接 QuickBooks、Xero、NetSuite,不接也能导出文件,结果需会计复核。
anthropics/knowledge-work-plugins29.9k