Generate docx, pptx or xlsx from inside your
application with {tags} using Javascript
import Docxtemplater from "docxtemplater";
const doc = new Docxtemplater(document1);
doc.render({ firstname: "John" });
import Docxtemplater from "docxtemplater";
const doc = new Docxtemplater(presentation1);
doc.render({ title: "Lorem ipsum" });
import Docxtemplater from "docxtemplater";
const doc = new Docxtemplater(spreadSheet1);
doc.render({
items: [
{
description: "description...",
unit_price: 200,
quantity: 18,
},
],
});
Description | Unit price | Quantity | |
---|---|---|---|
{#items}{description} | {unit_price} | {quantity} | {/items} |
Paid version trusted by 500+ companies
docxtemplater relies on a template-based approach, anyone that knows how to use Word can modify the look of the generated documents.
You can let your own customers edit the Word template!
With docxtemplater, you write a document template using Word or Powerpoint and filling it with tags such as `{user}`. You can call docxtemplater using Node.JS or in the browser with Javascript. The engine will take your input data as JSON and generate a document with all fields replaced by their values.
If you buy a license for docxtemplater paid software, you get support per email within 48 hours to help you for any problems you may have.
For the Entreprise Plan, the response time is of 24 hours.
Add images using the simple syntax :
{%image}
The image can be loaded from base64, from the filesystem or from an http request.
Repeat a section in your template, or show/hide a section.
{#users}
{name}
{/}
{#isAdmin}
You're the admin
{/}
Add HTML with
{~html}
This allows you to use the input from your WYSIWYG editor and put it into your report.
Or to generate a complex table.
You can manage multiple docx documents and then include multiple documents in your final document.
Usage is like this :
Title
{:include subdoc}
Other
In a few minutes you can install docxtemplater on npm, create your first template and generate some docx from Javascript objects or JSON.
docxtemplater is tested with all active Node.js versions 12 up to version 20, and in all common browsers (Chrome,Firefox,Safari,IE9+).
With the Entreprise plan, we provide a docker image. It allows you to use docxtemplater from other languages such as Python, Java, Go, C#, C++, Ruby, PHP, Node.JS (we've built an SDK for each language)
You can customize a lot of things with docxtemplater :
{user.name | upper }
or {#companies | where:'revenue > 1000'}
[[user]]
instead of {user}
Docxtemplater works with the 3 major office document formats :
The open-source core supports only docx and pptx, for xlsx, you need to have access to the XLSX Module
docxtemplater has extensive documentation to get started (in Node.JS or the browser), and configure the generation.
For questions about our paid modules, see our commercial FAQ and our technical FAQ.
For each feature, we write a full suite of tests with real Word documents to ensure that the generated documents are correct. Our current mutation testing score measured by Stryker Mutator is at 90%, which is very high and allows us to develop features without fearing of breaking existing usecases.
Add charts using the simple syntax :
{$myChart}
Insert a chart to define your style, and put a tag to bind the data to your chart.
3 minutes
Docxtemplater is an open-source project, which has basic features for templating. All paid features are available in modules, for example the HTML module allows inserting formatted text with bold, italic, links. All modules can be bought separately for a yearly fee. There are also three plans, the PRO plan, the ENTREPRISE plan and the PREMIUM plan that gives you access to a set of modules.
Yes, the license model is suitable for Software as a Service businesses. As long as you are the entity running docxtemplater software, you can use the standard licenses.
If you need to redistribute the software by installing it on your customers servers, this will need a specific "appliance" license. The standard license does not allow to redistribute the software. The Appliance license plan is 4500€ per year for PRO and 10000€ per year for ENTREPRISE version. It allows you to distribute the modules contained in the PRO or ENTREPRISE module as part of your application. You are not allowed to resell the modules as is.
For any purchase that you make (Plan or Module), you will get included support per email to answer all your questions. Usually, we respond in 24 hours, on business days. Bugfixes are also included in the support plan. For new features, it depends whether the feature makes sense for other customers and if the time required to implement it is not too long.
To have faster answers, please include the used modules, the template document, the generated document, or the expected output, your JSON data, and code relevant to the generation.
The modules are installed via npm, you'll have to run : npm install --save <secret-url>
That url will be unique for your account.
The compiled files for browser usage are also bundled inside the package.
It is not possible to convert docx to PDF with docxtemplater, because docxtemplater is a templating engine and doesn’t know how to render a given document. We recommend to use libreoffice headless for a free tool or PDFTron for a paid alternative.
Read our commercial FAQ and technical FAQ or contact us for other questions.