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

@office-open/docx

v0.8.1

Published

Generate, parse, and patch .docx documents with a declarative TypeScript API

Readme

@office-open/docx

npm version npm downloads npm license

Generate, parse, and patch .docx documents with a declarative TypeScript API. Works in Node.js and browsers.

Features

  • 📄 Document Generation — Create Word documents with sections, headers, footers, and page numbers
  • ✍️ Paragraphs & Text — Rich text support with bold, italic, underline, strikethrough, and more
  • 📊 Tables — Full table support with merged cells, borders, and styles
  • 🖼️ Images — Inline and floating images with sizing, positioning, and wrapping
  • 🔗 Hyperlinks — External and internal hyperlinks with custom styling
  • 📑 Headers & Footers — First, last, even/odd page headers and footers
  • 📋 Lists — Numbered and bulleted lists with multiple levels and custom formats
  • 🎨 Styles — Paragraph, character, and table styles with inheritance
  • 📖 Table of Contents — Auto-generated table of contents with custom styling
  • 📝 Footnotes & Endnotes — Comprehensive footnote and endnote support
  • 📈 Charts — Bar, line, pie, area, and scatter charts with customization
  • 🔢 Math Equations — Full mathematical equation support via Office MathML (OMML)
  • 🧩 SmartArt — Built-in SmartArt graphic generation
  • 📚 Bibliography — Source management and citation support
  • 💬 Comments — Document comments with author and date tracking
  • 📝 Track Revisions — Insertions, deletions, and formatting changes
  • 📋 Content Controls — Structured document tags (SDT) for form-like documents
  • 📦 Text Boxes — Floating text boxes with content and styling
  • ☑️ Checkboxes — Form checkbox support in documents
  • 🖌️ DrawingML — Shapes with fills, shadows, effects, and transformations
  • 🔤 Custom Fonts — Font embedding and custom font tables
  • 🔧 Template Patching — Patch existing DOCX templates via placeholder replacement
  • ⚙️ Settings — Comprehensive document settings and compatibility options

Installation

# pnpm
pnpm add @office-open/docx

# npm
npm install @office-open/docx

# yarn
yarn add @office-open/docx

# bun
bun add @office-open/docx

Quick Start

import { Document, Paragraph, TextRun, Packer } from "@office-open/docx";
import { writeFileSync } from "node:fs";

const doc = new Document({
  sections: [
    {
      children: [
        new Paragraph({
          children: [
            new TextRun("Hello World"),
            new TextRun({
              text: " - Bold text",
              bold: true,
            }),
          ],
        }),
      ],
    },
  ],
});

const buffer = await Packer.toBuffer(doc);
writeFileSync("My Document.docx", buffer);

Examples

Check the demo folder for 100+ working examples covering every feature.

Benchmark

Performance comparison against original docx (9.6.1) package (higher ops/s is better, Windows 11 / Node 24).

Default = XML DEFLATE level 1 (SuperFast, matching MS Office) + media STORE. All STORE = no compression ({ compression: { xml: 0 } }). docx (async) always uses DEFLATE for ALL entries including images (via JSZip, hardcoded, no STORE option).

// Default (matches MS Office)
await Packer.toBuffer(doc);
// All STORE (no compression)
await Packer.toBuffer(doc, { compression: { xml: 0 } });

Create + toBuffer (end-to-end)

| Scenario | Default sync | Default async | All STORE sync | All STORE async | docx | | ------------------------------ | -----------: | ------------: | -------------: | --------------: | --------: | | Simple (2p + 1 img) | 174 ops/s | 155 ops/s | 202 ops/s | 203 ops/s | 82 ops/s | | Styled paragraphs (20) + 1 img | 179 ops/s | 146 ops/s | 198 ops/s | 198 ops/s | 86 ops/s | | Table (10x5) | 949 ops/s | 565 ops/s | 1,830 ops/s | 1,867 ops/s | 190 ops/s | | Full featured + 2 imgs | 94 ops/s | 89 ops/s | 102 ops/s | 100 ops/s | 57 ops/s |

Large Files — Create + toBuffer

| Scenario | Default sync | Default async | All STORE sync | All STORE async | docx | | ------------------------------ | -----------: | ------------: | -------------: | --------------: | ---------: | | 2000 paragraphs + 20 images | 4.68 ops/s | 3.13 ops/s | 3.50 ops/s | 3.08 ops/s | 2.07 ops/s | | 200x10 table | 64.9 ops/s | 62.6 ops/s | 69.7 ops/s | 72.6 ops/s | 19.5 ops/s | | 20 sections x 100p + 40 images | 1.58 ops/s | 1.69 ops/s | 1.79 ops/s | 1.65 ops/s | 1.16 ops/s |

Large File (~100MB) — Mixed Content

500 styled paragraphs + 38 mixed-size images (1-5MB, 100MB total) + 50x10 table. Speedup is vs docx.

| Method | Speed | Speedup | | --------- | ---------: | -------: | | All STORE | 0.42 ops/s | 1.4x | | Default | 0.31 ops/s | 1.1x | | docx | 0.29 ops/s | |

License