# docx-templates

> Template-based docx report creation for both Node and the browser

Source: https://talira.ai/catalog/docx-templates-w28fxj7t
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [documents / generation / word templates](https://talira.ai/categories/documents/generation/word-templates), [languages / javascript](https://talira.ai/categories/languages/javascript)
- Platforms: web[^1]
- Licence: MIT[^1][^2]
- Pricing: Free and open source[^2]
- Pricing notes: MIT-licensed and free.
- Free tier: yes[^2]
- Self-hostable: yes[^1]
- Creator: Guillermo Grau Panea

docx-templates fills Word (.docx and .docm) templates in Node.js, Deno or the browser. Commands in the document (`+++INS name+++`, or custom delimiters such as `{ }`) insert values, and `FOR`/`END-FOR` and `IF`/`END-IF` repeat table rows and show content conditionally, with plain JavaScript expressions; `IMAGE`, `LINK` and `HTML` insert pictures, hyperlinks and HTML, and a `QUERY` command lets the template declare the data it needs (GraphQL, for example). Because templates run JavaScript, its README warns against running templates uploaded by users on a server. It's MIT-licensed and written in [TypeScript](https://talira.ai/catalog/typescript-w0asrgz8.md).

## Links

- GitHub: https://github.com/guigrpa/docx-templates

## Problems it solves

- generate Word reports in Node.js where the template can run JavaScript to filter and sort the data
- let a .docx template declare its own GraphQL query for the data it needs
- insert QR codes or charts generated on the fly as images in a Word report from JavaScript
- make a .docx in the user's browser from a template, nothing uploaded to a server
- loop over table rows in a Word template with a free npm package, no paid image module
- list all the commands and errors in a Word template before running it
- fill Word templates from Deno

## Features

- INS, EXEC, IMAGE, LINK, HTML, FOR/END-FOR, IF/END-IF, ALIAS and QUERY commands
- JavaScript expressions in templates, run in a Node vm sandbox or one you provide
- loops over table rows, nested loops and filter/sort in JavaScript
- dynamic images, hyperlinks and HTML insertion
- literal XML insertion
- custom command delimiters
- error collection (failFast: false) and template inspection
- .docx and .docm templates; Node, Deno, browser and Web Workers
- TypeScript type definitions

## Limitations

- Isn't safe for running templates that users upload: templates run JavaScript, and the default Node vm sandbox isn't a security boundary[^1]

## Trust

Overall: 0.23 out of 1.
Signals: backing 0.20, extensibility 0.00.

- created by Guillermo Grau Panea

Warnings:

- GitHub activity not fetched yet

## Alternatives

- [docxtemplater](https://talira.ai/catalog/docxtemplater-gjcbyhm2.md): Powerful Word, PowerPoint and Excel generation
- [easy-template-x](https://talira.ai/catalog/easy-template-x-cyxb4adx.md): Generate docx documents from templates, in Node or in the browser
- [Carbone](https://talira.ai/catalog/carbone-hz5gt655.md): Generates PDF, DOCX and other documents from JSON data and Office templates
- [docxtpl](https://talira.ai/catalog/docxtpl-yhjaa0ty.md): Use a docx as a jinja2 template
- [Sablon](https://talira.ai/catalog/sablon-5bjabghv.md): Ruby document template processor based on docx templates and Mail Merge fields
- [Aspose.Words](https://talira.ai/catalog/aspose-words-4k0hy0ew.md): Create, edit, render and convert Word documents to multiple formats without using external software

## Sources

[^1]: https://github.com/guigrpa/docx-templates/blob/master/README.md (checked 20 Nov 2026)
[^2]: https://github.com/guigrpa/docx-templates/blob/master/LICENSE (checked 20 Nov 2026)
