Skip to main content

odf-kit

Library to generate, fill, read, and convert OpenDocument (.odt, .ods) files in Node.js and browsers using JavaScript or TypeScript.

odf-kit

odf-kit is an open-source TypeScript library for working with OpenDocument Format (ODF) documents programmatically. It provides thirteen distinct document modes in a single package: build ODT documents from scratch, fill existing .odt templates with data, convert DOCX to ODT, HTML to ODT, Markdown to ODT, TipTap JSON to ODT, Lexical editor state to ODT, build ODS spreadsheets, read ODT and ODS files, convert XLSX to ODS, convert ODT to Markdown, and export ODT to Typst for PDF generation. All modes work in Node.js 22+ and modern browsers — documents can be generated entirely client-side with no server required. The template engine fills existing .odt files created in LibreOffice with data using {placeholders}, loops for repeating content, conditionals for optional sections, and dot notation for nested data. It automatically handles LibreOffice's XML fragmentation of placeholder text. The ODT builder produces documents with rich text formatting, tables with cell merging and formatting, bullet and numbered lists with up to 6 levels of nesting, embedded images, hyperlinks, internal bookmarks, headers and footers with page numbers, and full page layout control. Generated files open in LibreOffice, Google Docs, Microsoft Word, and any ODF-compliant application. The DOCX-to-ODT converter handles headings, paragraphs, text formatting, tables with merged cells, nested lists, images with actual dimensions, hyperlinks, bookmarks, footnotes and endnotes, headers and footers, page layout, and tracked changes. The HTML-to-ODT and Markdown-to-ODT converters support all common elements including tables, lists, inline styles, and code blocks. HTML input is automatically normalized to polyglot markup before parsing, so good HTML5 from Markdown renderers, rich-text editors, and templating engines converts correctly without manual preprocessing. Compliance-sensitive users can substitute their own normalizer or parser implementations through documented hooks. The Lexical-to-ODT converter translates Lexical editor state (SerializedEditorState) directly to ODT, making it suitable for integration with Lexical-based editors such as Proton Docs. The ODS spreadsheet builder supports multiple sheets, auto-typed cells (string, number, date, boolean, formula), number formats (currency, percentage, decimal, integer), cell and row formatting, column widths, row heights, freeze rows and columns, merged cells, tab colors, and hyperlinks. The XLSX-to-ODS converter preserves strings, numbers, booleans, dates, formulas, merged cells, freeze panes, and multiple sheets with no additional dependencies. The ODT and ODS readers parse existing files into structured document models and can convert directly to HTML. The ODT-to-Markdown converter supports GFM and CommonMark output. The ODT-to-Typst emitter converts any ODT file to Typst markup for compilation to PDF — making it a zero-dependency alternative to LibreOffice headless for PDF generation. odf-kit generates ODF 1.2+ compliant files per ISO/IEC 26300, the international standard mandated by the European Union, many national governments, and public sector organisations for vendor independence and long-term document accessibility. Every generated file is validated against the official OASIS ODF validator in CI. The library has zero transitive runtime dependencies beyond fflate for ZIP packaging.

Software-Details

Created at

05/08/26

Last updated

05/28/26

Status

stable

Platform
web
Software-Version

0.13.4

License

Apache-2.0

Last updated