Saltar al contenido
Volver al blog
Open sourcePublicado 21 de junio de 20265 min de lectura

We open-sourced peppol-validator — a free npm to validate UBL & Peppol invoices

peppol-validator is a free, MIT-licensed npm package that validates UBL 2.1 / Peppol BIS / EN 16931 documents against XSD and Schematron — no Java, bring your own rule sets.

We just published our first open-source package: peppol-validator, a small npm library that validates UBL 2.1 and Peppol BIS documents — invoices, credit notes, orders, despatch advice, catalogues, application responses — against both the XSD structure and the Schematron business rules. It is MIT-licensed and free to use.

Why open-source the validator

A document is not "valid" just because it is well-formed XML. It has to pass strict structural (XSD) and business-rule (Schematron) checks for EN 16931, Peppol BIS or XRechnung — and wiring that pipeline up correctly is fiddly. Validation, though, is a commodity: it checks documents, it does not generate them. So we extracted that layer from our platform and released it on its own.

What it does

XSD validation works out of the box — the OASIS UBL 2.1 schemas are bundled, the document root is auto-detected (Invoice, CreditNote, Order, Catalogue, ApplicationResponse and more) and the matching schema is selected. Schematron runs on SaxonJS, so there is no Java or JVM to install.

  • XSD validation out of the box (bundled OASIS UBL 2.1 schemas).
  • Schematron validation via SaxonJS — pure JavaScript, no JVM.
  • Auto-detects the document type; one API for invoices and the whole procurement family.
  • Hardened parsing: external entities, DTD loading and network access are disabled; input is size-capped.

Bring your own rule sets

One deliberate design choice: the Peppol, EN 16931 and XRechnung Schematron rule sets are not redistributed inside the package — they belong to their respective bodies. Instead, peppol-validator bundles a compiler that turns the official .sch files you download into runnable SEF artefacts locally, so you always stay within the terms you accepted when downloading them. Only the OASIS UBL XSD and the MIT-licensed ISO Schematron skeleton are shipped.

Getting started

Install it with "npm install peppol-validator". Call validateXsd(xml) for an instant structural check, or validate(xml, { sef }) to run XSD plus a compiled Schematron rule set in one call. You get back a clear report with the failing rule IDs and messages.

View peppol-validator on npm

How it relates to MyInvoice

peppol-validator is the open validation layer of MyInvoice. The validator checks documents; the MyInvoice platform goes further — it converts the data you already have (CSV, Excel, UBL, EDIFACT or legacy XML) into a compliant EN 16931 document in the profile you need, validates it the same way, and connects to your ERP. If you only need to check files, the npm package is enough; if you need to generate compliant invoices, that is what MyInvoice is for.