Mintdoc
Mint perfect documents from templates.
A templating engine for .docx files. Define your template once, generate thousands of pixel-perfect
documents programmatically.
Dear {firstName},
Invoice {invoiceId}
Total: {amount | currency}
{#items}
· {name}
{/items}
Dear Alice Martin,
Invoice INV-2024-001
Total: €1,250.00
· Consulting
· Support
Features
Everything you need to generate documents
A focused, well-crafted API for document generation. No bloat, no complexity.
Template Syntax
Simple {tag} syntax inside your .docx files. Variables with dot notation, loops, conditionals — everything you need.
Loops & Conditions
Iterate over arrays with loop metadata, show or hide sections with if/else. Build complex documents with simple logic.
Formatters & Pipes
Transform values with built-in or custom formatters using pipe syntax. Uppercase, dates, currency and more.
TypeScript First
Written in TypeScript with full type definitions. Autocomplete and type safety in your IDE.
Zero Dependencies
Lightweight core with no external runtime dependencies. Fast installs, minimal footprint.
Plugin System
Extend Mintdoc with plugins. Add custom formatters, hook into rendering, and build your own extensions.
Quick Start
From zero to document in minutes
Follow these steps to generate your first document.
Install the package
Install the package
Terminal$ npm install mintdoc Create a .docx template
Create a .docx template
template.docx
Open Word or Google Docs and write your document normally. Use {tag} syntax to mark dynamic fields:
Dear {firstName} {lastName},
Welcome to {company.name}!
Your position: {role}
Start date: {startDate} Write the generation script
Write the generation script
generate.tsimport { Mintdoc } from 'mintdoc'
import { readFileSync, writeFileSync } from 'fs'
const doc = new Mintdoc()
const template = readFileSync('template.docx')
const output = doc.render(template, {
firstName: 'Alice',
lastName: 'Martin',
company: { name: 'Acme Corp' },
role: 'Software Engineer',
startDate: 'March 1, 2026',
})
writeFileSync('welcome-letter.docx', output) Run and verify
Run and verify
Terminal$ npx tsx generate.ts
✓ welcome-letter.docx generated successfully
Open welcome-letter.docx — all {tags} have been replaced with your data.
Reference
Template Syntax
A non-exhaustive overview of the tags you can use inside your .docx templates.
{variable} Insert a value
{name} → Alice
{object.property} Dot notation access
{company.name} → Acme Corp
{#items}...{/items} Loop over an array
Repeats content for each item
{#if cond}...{/if} Conditional section
Show/hide blocks based on data
{#if cond}...{:else}...{/if} If/else branching
Conditional with fallback
{value | formatter} Apply a formatter
{name | uppercase} → ALICE
| Syntax | Description | Example |
|---|---|---|
{variable} | Insert a value | {name} → Alice |
{object.property} | Dot notation access | {company.name} → Acme Corp |
{#items}...{/items} | Loop over an array | Repeats content for each item |
{#if cond}...{/if} | Conditional section | Show/hide blocks based on data |
{#if cond}...{:else}...{/if} | If/else branching | Conditional with fallback |
{value | formatter} | Apply a formatter | {name | uppercase} → ALICE |