npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mintdoc

v0.1.1

Published

Mint perfect documents from templates. A modern document templating engine for .docx files.

Readme


Features

  • Variables{firstName}, {company.name} (dot-notation)
  • Loops{#items}...{/items} with automatic table row duplication
  • Conditions{#if premium}...{:else}...{/if}
  • Formatters{name | uppercase} with built-in and custom formatters
  • Loop metadata{@index}, {@first}, {@last}, {.}
  • Headers & footers — template tags work everywhere in the document
  • TypeScript — full typings included
  • Zero server dependency — works in Node.js and the browser

Installation

npm install mintdoc

Quick Start

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",
  company: { name: "Acme Corp" },
  premium: true,
  items: [
    { name: "Widget", price: "10 €" },
    { name: "Gadget", price: "20 €" },
  ],
});

writeFileSync("output.docx", output);

Or use the shorthand function for simple cases:

import { render } from "mintdoc";

const output = render(template, { name: "Alice" });

Template Syntax

Create your template in Word, then use these tags in your document:

| Syntax | Description | |---|---| | {variable} | Simple variable | | {object.property} | Dot-notation path | | {variable \| formatter} | Apply a formatter | | {#items}...{/items} | Loop over an array | | {#if condition}...{/if} | Conditional block | | {#if condition}...{:else}...{/if} | Conditional with else |

Loop Metadata

Inside a loop, these special variables are available:

| Variable | Description | |---|---| | {@index} | Current iteration index (0-based) | | {@first} | true on the first iteration | | {@last} | true on the last iteration | | {.} | Current item (for primitive arrays) |

{#items}
  {name} — item {#if @first}(first){/if}{#if @last}(last){/if}
{/items}

Table Row Duplication

Place a loop around a table row to duplicate it for each item:

| {#items}{name} | {price}{/items} |

Mintdoc automatically detects loop tags inside table cells and wraps the entire row — no manual configuration needed.


Built-in Formatters

| Formatter | Example | Output | |---|---|---| | uppercase | {name \| uppercase} | ALICE | | lowercase | {name \| lowercase} | alice | | capitalize | {name \| capitalize} | Alice |

Formatters can be chained: {name | lowercase | capitalize}


Custom Formatters

Register your own formatters with addFormatters():

const doc = new Mintdoc().addFormatters({
  date: (value) => new Date(String(value)).toLocaleDateString("en-US"),
  euros: (value) => `${value} €`,
  truncate: (value) => String(value).slice(0, 50),
});

Then use them in your template:

Invoice date: {createdAt | date}
Total: {amount | euros}

Plugin System

Mintdoc has an open plugin API. Register plugins using use():

import { Mintdoc } from "mintdoc";
import { imagePlugin } from "@mintdoc/pro"; // Pro module (coming soon)

const doc = new Mintdoc().use(imagePlugin);

Plugins can add formatters and new tag types. Third-party plugins can use the same API.


Error Handling

Mintdoc throws typed errors for clear debugging:

import { Mintdoc, MintdocParseError, MintdocRenderError } from "mintdoc";

try {
  const output = doc.render(template, data);
} catch (e) {
  if (e instanceof MintdocParseError) {
    // Malformed template (unclosed tag, mismatched tags…)
    console.error("Template error:", e.message);
  } else if (e instanceof MintdocRenderError) {
    // Data mismatch (unknown formatter, loop on non-array…)
    console.error("Render error:", e.message);
  }
}

API Reference

new Mintdoc()

Creates a reusable instance. Configure once, render multiple times.

| Method | Description | |---|---| | .use(plugin) | Register a plugin | | .addFormatters(map) | Register custom formatters | | .render(template, data) | Render a .docx template |

All methods are chainable:

const doc = new Mintdoc()
  .use(myPlugin)
  .addFormatters({ date: (v) => new Date(String(v)).toLocaleDateString() });

render(template, data, options?)

Shorthand function — no instance required.

import { render } from "mintdoc";

const output = render(template, data, {
  formatters: { date: (v) => new Date(String(v)).toLocaleDateString() },
});

Browser Usage

Mintdoc works in the browser. Pass an ArrayBuffer instead of a Buffer:

import { render } from "mintdoc";

const response = await fetch("/templates/invoice.docx");
const template = await response.arrayBuffer();
const output = render(template, { name: "Alice" });

License

MIT — see LICENSE.


Pro modules — images, charts, dynamic tables, Excel, PowerPoint — coming soon at mintdoc.dev.