Mint icon Mintdoc
Latest — v0.1.1
Mintdoc

Mintdoc

Mint perfect documents from templates.

A templating engine for .docx files. Define your template once, generate thousands of pixel-perfect documents programmatically.

$ npm install mintdoc
Documentation
TypeScript Node.js Zero dependencies ESM & CJS

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.

1

Install the package

Terminal
$ npm install mintdoc
2

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}
3

Write the generation script

generate.ts
import { 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)
4

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.

Full documentation
{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