Comparison · Template Engine · Free & Open Source

Free docxtemplater alternative for ODF / .odt templates

docxtemplater is a popular JavaScript library for filling document templates — but its ODF support requires a paid module. odf-kit offers a free, open-source template engine for .odt files with loops, conditionals, dot notation, and browser support. No license fees, no per-document charges.

The problem with docxtemplater for ODF

docxtemplater is well-established for .docx template filling. It has a large user base, good documentation, and a mature API. If you need to fill Word document templates, it's a solid choice.

However, if you need to fill .odt templates — the OpenDocument Format used by LibreOffice and required by many governments — docxtemplater's ODF support is a paid add-on module. The open-source core only handles .docx, .pptx, and .xlsx. To use .odt templates, you need a commercial license.

For developers building tools for non-profits, governments, community organizations, or open source projects, a paid per-developer license may not be practical — especially when the entire point of using ODF is to avoid vendor lock-in and proprietary dependencies.

Feature comparison

Feature odf-kit docxtemplater
.odt template filling ✓ Free
Placeholder replacement
Loops ({#items}...{/items})
Conditionals ({#flag}...{/flag})
Dot notation ({company.name})
Create documents from scratch
Browser support
Node.js support
Placeholder healing (fragmented XML) ✓ Automatic
.docx support ✓ Free
Runtime dependencies Zero Multiple (pizzip, etc.)
License Apache 2.0 MIT (core) + commercial (modules)
Image insertion in templates

To be clear: docxtemplater is a good library. If you need .docx templates, it's a strong option. This comparison is specifically about .odt template filling, where odf-kit provides a free alternative to docxtemplater's paid ODF module. odf-kit does not handle .docx files.

Template syntax comparison

Both libraries use curly-brace placeholder syntax. If you're already familiar with docxtemplater's syntax, odf-kit's will feel familiar:

Feature odf-kit docxtemplater
Simple replacement {name} {name}
Nested property {company.address.city} {company.address.city}
Loop {#items}...{/items} {#items}...{/items}
Conditional {#showNotes}...{/showNotes} {#showNotes}...{/showNotes}

The syntax is intentionally similar. If you have existing .odt templates designed for docxtemplater's ODF module, they will likely work with odf-kit with little or no modification.

Quick start with odf-kit

$ npm install odf-kit

Step 1: Create a template in LibreOffice. Type {customer}, {date}, and {#items}...{/items} directly in the document text.

Step 2: Fill the template with data:

import { fillTemplate } from "odf-kit";
import { readFileSync, writeFileSync } from "fs";

const template = readFileSync("invoice-template.odt");

const result = fillTemplate(template, {
  customer: "Acme Corp",
  date: "2026-03-01",
  items: [
    { product: "Widget", qty: 5, price: "$125" },
    { product: "Gadget", qty: 3, price: "$120" },
  ],
  showDiscount: true,
  discount: "10%",
});

writeFileSync("invoice.odt", result);

That's it. No configuration, no license keys, no paid modules. The fillTemplate() function reads the .odt file, replaces all placeholders, expands loops, evaluates conditionals, and returns a new .odt file as a Uint8Array.

Placeholder healing

When you type {placeholder} in LibreOffice, the application sometimes splits the text across multiple XML elements — for example due to spell-check annotations, formatting boundaries, or editing history. This means the raw XML might contain <span>{</span><span>placeholder</span><span>}</span> instead of a single {placeholder} text node.

odf-kit automatically detects and reassembles these fragmented placeholders before doing replacements. You don't need to manually edit the XML or use any special LibreOffice settings when creating templates.

Browser support

odf-kit works entirely in the browser — no server needed. Users can upload a template via a file input, fill it with data from a form, and download the result. The template and data never leave the browser, which is ideal for privacy-sensitive applications.

import { fillTemplate } from "odf-kit";

const input = document.querySelector("#template-file");

input.addEventListener("change", async (e) => {
  const file = e.target.files[0];
  const buffer = new Uint8Array(
    await file.arrayBuffer()
  );

  const result = fillTemplate(buffer, {
    name: "Alice",
    company: "Acme Corp",
  });

  const blob = new Blob([result], {
    type: "application/vnd.oasis.opendocument.text",
  });
  const url = URL.createObjectURL(blob);
  const a = document.createElement("a");
  a.href = url;
  a.download = "filled.odt";
  a.click();
  URL.revokeObjectURL(url);
});

What about creating documents from scratch?

Unlike docxtemplater, odf-kit can also create .odt documents from scratch — no template file needed. This is useful for generating reports, invoices, letters, or any structured document programmatically:

import { OdtDocument } from "odf-kit";

const doc = new OdtDocument();
doc.addHeading("Invoice #1042", 1);
doc.addParagraph("Date: March 1, 2026");
doc.addTable([
  ["Item",    "Qty", "Price"],
  ["Widget", "5",   "$125"],
  ["Gadget", "3",   "$120"],
], { border: "0.5pt solid #000" });

const bytes = await doc.save();

See the full Node.js guide or the browser guide for complete examples with formatting, images, page layout, headers, and footers.

When to use docxtemplater instead

If your primary format is .docx and you only occasionally need .odt, docxtemplater's ecosystem is broader and more mature for Word documents. If you need advanced features like image insertion inside templates, chart generation, or HTML-to-document conversion, docxtemplater's paid modules cover those use cases. odf-kit is focused specifically on ODF — it does that format well and for free, but it doesn't handle .docx at all.

Summary

If you need to fill .odt templates with data in JavaScript or TypeScript, odf-kit gives you loops, conditionals, dot notation, placeholder healing, and browser support — all free and open source under Apache 2.0. If you also need to create .odt documents from scratch, odf-kit handles that too. No paid modules, no license keys, zero dependencies.

Fill .odt templates for free

Loops, conditionals, dot notation. Works in Node.js and browsers. Apache 2.0.

$ npm install odf-kit