Profile
Back to NewsBack
GitHub Trending 5 min
Reader Mode
invoice-x/invoice2data: Extract structured data from PDF invoices

invoice-x/invoice2data: Extract structured data from PDF invoices

11 hours ago

invoice2data

Data extractor for PDF invoices - invoice2data

![Read the documentation at https://invoice2data.readthedocs.io/][read the docs] Version</a> Support Python versions</a> ![License][license] ![Tests][tests] ![Coverage][coverage] ![pre-commit][pre-commit] Ruff</a>

[pypi status]: https://pypi.org/project/invoice2data/ [read the docs]: https://invoice2data.readthedocs.io/ [tests]: https://github.com/invoice-x/invoice2data/actions?workflow=Tests [coverage]: https://github.com/invoice-x/invoice2data/actions?workflow=Tests [pre-commit]: https://github.com/pre-commit/pre-commit [ruff badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json [ruff project]: https://github.com/charliermarsh/ruff

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:
  1. 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).
  1. searches for regex in the result using a YAML or JSON-based template system
(with an optional
AI fallback).
  1. 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][installation].

Documentation

Full documentation:

  • [How it works][how-it-works] — the extraction pipeline
  • [Installation][installation] — backends, OCR and optional extras
  • [Usage][usage] — all CLI options and common tasks
  • [Template creation][tutorial] — write templates for your invoices
  • [Recommended fields][fields] — the canonical output schema
  • [AI features][ai] — optional LLM fallback & template generation
  • [FAQ][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][gvision], plus local DL backends [docTR][doctr] and [PaddleOCR][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][ai] page
  • per-field data cleanup — the replace: key on each field
  • advanced table parsing — opt-in [Camelot][camelot] plugin (pip install invoice2data[camelot]), plus an [Excalibur → template converter][usage-excalibur]
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][odoo-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][python-stdnum] — deferred
pending Odoo core's stdnum version alignment.

Issues and pull requests welcome on any of these.

[gvision]: https://cloud.google.com/vision [doctr]: https://github.com/mindee/doctr [paddleocr]: https://github.com/PaddlePaddle/PaddleOCR [camelot]: https://github.com/camelot-dev/camelot [usage-excalibur]: https://invoice2data.readthedocs.io/en/latest/usage.html [odoo-oca-edi]: https://github.com/OCA/edi [python-stdnum]: https://arthurdejong.org/python-stdnum/

Maintainers

Contributors and Credits

Code student. invoice items.

[pypi]: https://pypi.org/ [file an issue]: https://github.com/invoice-x/invoice2data/issues [pip]: https://pip.pypa.io/

Contributions are very welcome. To learn more, see the [Contributor Guide].

Used By

Related Projects

(Commercial) (Commercial)

[license]: https://invoice2data.readthedocs.io/latest/license.html [contributor guide]: https://invoice2data.readthedocs.io/latest/contributing.html [command-line reference]: https://invoice2data.readthedocs.io/latest/usage.html [tutorial]: https://invoice2data.readthedocs.io/latest/tutorial.html [installation]: https://invoice2data.readthedocs.io/latest/installation.html [how-it-works]: https://invoice2data.readthedocs.io/latest/how-it-works.html [usage]: https://invoice2data.readthedocs.io/latest/usage.html [fields]: https://invoice2data.readthedocs.io/latest/recommended-template-fields.html [ai]: https://invoice2data.readthedocs.io/latest/ai.html [faq]: https://invoice2data.readthedocs.io/latest/faq.html

Chat with me