What are .odt files?
Files with the .odt extension are OpenDocument Format text documents — an ISO international standard (ISO/IEC 26300) used by LibreOffice, Apache OpenOffice, Google Docs, and many government organizations worldwide. Under the hood, an .odt file is a ZIP archive containing XML files (content.xml, styles.xml, meta.xml) plus any embedded images. This is sometimes called a "packaged" ODF file, as opposed to a "flat" XML ODF file (.fodt) which stores everything in a single XML document.
If you're seeing references to "flat XML ODF text document" — that's the unpackaged variant. Most real-world .odt files are ZIP-packaged, and that's what the tools below handle.
Three things you can do with ODT in JavaScript
JavaScript developers working with .odt files generally need one of three things: parsing and extracting text from existing documents, converting them to other formats like HTML or PDF, or generating new .odt files programmatically. The ecosystem has different tools for each task, with varying levels of maturity and maintenance.
1. Parse and extract text from .odt files
If you need to read an existing .odt file and extract its text content — for indexing, search, text analysis, or display — these are your options:
officeparser Active
The most actively maintained option for extracting text from .odt files. Returns a structured AST with metadata, formatting, and attachment support. Works in Node.js and browsers. Handles the ZIP extraction and XML parsing internally.
import { parseOffice } from "officeparser"; const ast = await parseOffice("/path/to/document.odt"); const text = ast.toText(); console.log(text); // plain text content console.log(ast.metadata); // author, title, dates
textract Stale
A versatile text extraction library that supports a wide range of file types. Last published 6+ years ago but still functional. Some formats require system dependencies (like pdftotext). Good if you need to extract text from many different file types in a single pipeline.
odt2html Abandoned
Converts ODT to HTML by parsing the ODF XML structure and mapping it to HTML elements. Not actively maintained and may fail on modern documents. For an actively maintained pure JavaScript alternative, see odf-kit's odtToHtml() function below.
2. Convert .odt to HTML or PDF
Converting an .odt file to another format is a more complex task than text extraction. The document's formatting, styles, tables, and images all need to be translated. Here are the approaches:
LibreOffice headless (most reliable)
The most reliable way to convert .odt files to HTML or PDF is to use LibreOffice in headless mode. This is a command-line approach that doesn't require JavaScript at all, but it's commonly used in Node.js workflows via child_process:
// Convert .odt to PDF using LibreOffice headless import { execSync } from "child_process"; execSync(`libreoffice --headless --convert-to pdf document.odt`); // produces document.pdf in the same directory // Convert to HTML execSync(`libreoffice --headless --convert-to html document.odt`);
This produces high-fidelity output because LibreOffice understands the full ODF specification. The downside is that LibreOffice must be installed on the server, and headless mode can be slow and resource-heavy. For a pure JavaScript approach that generates .odt files without requiring LibreOffice at all, see the Generate .odt Without LibreOffice guide.
Pure JavaScript ODT to HTML — odf-kit
odf-kit v0.5.0 adds a built-in ODT reader and HTML converter — the first actively maintained pure JavaScript library for ODT-to-HTML conversion. It handles paragraphs, headings, tables, lists, bold, italic, underline, strikethrough, superscript, subscript, and hyperlinks. Zero dependencies, works in Node.js and browsers.
import { odtToHtml, readOdt } from "odf-kit/reader"; import { readFileSync } from "node:fs"; const bytes = new Uint8Array(readFileSync("document.odt")); // Convert to HTML in one step const html = odtToHtml(bytes, { fragment: true }); // Or parse to a structured model first const doc = readOdt(bytes); console.log(doc.metadata.title); // document title from meta.xml console.log(doc.body.length); // number of paragraphs, headings, tables... const html = doc.toHtml(); // full HTML document
For full-fidelity conversion including fonts, colors, page layout, and embedded images, LibreOffice headless remains the most complete option. odf-kit's reader covers the common case — semantic content — and is the right choice when you don't want a LibreOffice dependency or need browser compatibility.
3. Generate new .odt files
If you need to create .odt files programmatically — generating reports, invoices, contracts, letters, or any structured document from your application data — this is the area where the ecosystem was historically weakest.
odf-kit Active
The only actively maintained JavaScript library for creating, filling, and reading ODF documents. Generate .odt files from scratch, fill existing .odt templates with data using a Mustache-style template engine, or convert .odt files to HTML with the built-in reader. Works in Node.js and browsers with the same API. Zero runtime dependencies.
// Generate a new .odt document from scratch import { OdtDocument } from "odf-kit"; const doc = new OdtDocument(); doc.addHeading("Quarterly Report", 1); doc.addParagraph("Generated automatically from application data."); doc.addTable([ ["Region", "Revenue", "Growth"], ["North", "$1.2M", "+12%"], ["South", "$890K", "+8%"], ]); const bytes = await doc.save(); // → valid .odt file, opens in LibreOffice, Google Docs, Word
// Fill an existing .odt template with data import { fillTemplate } from "odf-kit"; const result = fillTemplate(templateBytes, { name: "Alice Johnson", date: "2026-03-04", items: [ { description: "Consulting", amount: "$5,000" }, { description: "Development", amount: "$12,000" }, ], }); // → .odt with {name}, {date}, {#items}...{/items} replaced
simple-odf Abandoned
The predecessor in this space. Only produced flat XML (.fodt) files, not proper ZIP-packaged .odt documents. No support for tables, images, page layout, or templates. Abandoned since 2021. See the simple-odf migration guide for a comparison with odf-kit.
Quick comparison
| Task | Best option | Pure JS? | Browser? |
|---|---|---|---|
| Extract text from .odt | officeparser |
Yes | Yes |
| Convert .odt → HTML | odf-kit |
Yes | Yes |
| Convert .odt → PDF | LibreOffice headless | No | No |
| Generate new .odt | odf-kit |
Yes | Yes |
| Fill .odt templates | odf-kit |
Yes | Yes |
The gap in the ecosystem
The .docx ecosystem in JavaScript is mature — libraries like docx for generation and mammoth for conversion are well-established and widely used. The .odt ecosystem has historically lagged behind, with most tools either abandoned, limited to text extraction, or dependent on LibreOffice as a backend.
This is significant because .odt is the ISO standard format, required by the European Union, NATO, and 20+ national governments for official documents. Many organizations, schools, and non-profits default to LibreOffice and ODF. If you're building tools for these users, you need .odt support — and until recently, the JavaScript options were limited.
odf-kit was built specifically to fill these gaps. It's the only actively maintained library for creating, filling, and reading .odt files in JavaScript, and it works both server-side and in the browser with zero dependencies.
Common workflows
Generate .odt from a web application
Use odf-kit in the browser to generate .odt files entirely client-side. User data never leaves the page. See the browser generation guide for a complete walkthrough.
Fill templates in a CI/CD pipeline
Create a template in LibreOffice with {placeholder} fields, then use odf-kit's fillTemplate() in Node.js to produce personalized documents at build time. See the template guide.
Convert .odt files to HTML without LibreOffice
Use odf-kit's built-in reader to convert .odt files to HTML entirely in JavaScript. No LibreOffice installation required, no server-side dependencies, works in the browser. Import from odf-kit/reader to keep the main bundle lean.
Parse uploaded .odt files and index their content
Use officeparser to extract text from .odt files uploaded by users. The extracted text can be stored in a database for full-text search, content analysis, or document management.
Generate .odt for government compliance
Many public sector organizations require ODF format for document submissions and archives. Use odf-kit to generate compliant documents without requiring LibreOffice on your servers. See the government compliance guide.
More guides
- Generate .odt files in Node.js — step-by-step document creation
- Generate .odt files in the browser — client-side generation, no server needed
- Fill .odt templates with JavaScript — template engine walkthrough
- ODF for government compliance — ISO 26300 mandates and implementation
- Generate .odt without LibreOffice — lightweight alternative
- Free docxtemplater alternative for ODF — comparison for .odt templates
- Migrating from simple-odf — comparison and migration guide