Factur-X
Generate the EN 16931 CII XML and embed it into a PDF to produce a Factur-X invoice.
@liasse/factur-x produces Factur-X invoices: a human-readable PDF carrying
an embedded, structured CII XML (EN 16931 profile) — the format that becomes
mandatory for French e-invoicing from September 2026.
This is the pure-TypeScript happy-path: a well-formed, semantically-correct EN 16931 CII plus the embedded file and Factur-X XMP — self-contained for Node and recognised by common readers (Chorus Pro). Strict PDF/A-3b conformance (ICC profile, embedded fonts) and the official EN 16931 Schematron validation are handled by the conformance sidecar, not this package.
Install
pnpm add @liasse/factur-xDescribe the invoice
import type { Invoice } from "@liasse/factur-x";
const invoice: Invoice = {
number: "2026-0412",
issueDate: "2026-09-01",
dueDate: "2026-09-30",
buyerReference: "PO-7788",
seller: {
name: "ACME SAS",
registrationId: "812449220", // SIREN
vatId: "FR40812449220",
address: { line1: "12 rue des Lilas", city: "Paris", postcode: "75011", countryCode: "FR" },
},
buyer: {
name: "Globex SARL",
vatId: "FR62123456789",
address: { city: "Lyon", postcode: "69002", countryCode: "FR" },
},
lines: [
{ name: "Liasse Pro license", quantity: 5, unitPrice: 490, vatRate: 20 },
{ name: "Training", quantity: 1, unitPrice: 600, vatRate: 10 },
],
};Totals, the VAT breakdown by rate, and the grand total are computed for you.
Generate the CII XML
import { generateCII } from "@liasse/factur-x";
const xml = generateCII(invoice); // EN 16931 CrossIndustryInvoiceThe invoice is validated (zod) and a LiasseValidationError-style error is
thrown on bad input.
Produce the Factur-X PDF
Bring your own invoice PDF (e.g. from @liasse/pdf or the invoice component)
and embed the XML:
import { facturX } from "@liasse/factur-x";
import { render } from "@liasse/core";
import "@liasse/pdf";
// 1. render a human-readable invoice PDF (any PDF works)
const pdfBytes = await render(invoiceDoc, { format: "pdf" });
// 2. embed the CII XML → a Factur-X PDF
const facturXPdf = await facturX(invoice, pdfBytes);facturX(invoice, pdf) is shorthand for embedFacturX(pdf, generateCII(invoice)).
The XML is attached as an associated file and the Factur-X XMP metadata is
written so readers recognise it as a Factur-X document.
On the roadmap
The conformance sidecar (Mustangproject, JVM) will add strict PDF/A-3b output and run the official EN 16931 Schematron validation — the part no JavaScript library fully covers today.