Skip to main content
AdOpenFree logoPromote your productReach more potential users and drive product growth and revenue.Advertise
Favicon of @office-kit/docx

@office-kit/docx

Free Listing

A TypeScript library for reading, editing, and writing Word .docx documents. It builds new files, edits existing templates, and runs in Node.js and browsers.

Visit office-kit/docx

Overview

docx is a TypeScript library from Office Kit for reading, editing, and writing Word .docx files. It can build a document from scratch with createDocx or open an existing .docx with openDocx, then change paragraphs, runs, lists, tables, images, headers, footers, comments, footnotes, endnotes, hyperlinks, bookmarks, and tracked changes. It runs in Node.js and modern browsers, and unmodeled elements are written back untouched.

Key Features

  • Create .docx files from scratch with createDocx and append headings, paragraphs, bullet and numbered lists, tables, inline images, headers, footers, footnotes, and a table of contents.
  • Open existing .docx files with openDocx to replace text across the body, headers, footers, footnotes, endnotes, and comments; swap images by alt text; and accept or reject tracked insertions and deletions.
  • Render a Docx value or raw bytes into a DOM element with the companion @office-kit/docx-preview package in the browser.
  • Supports page setup, styles, tables, fields, comments, bookmarks, hyperlinks, core and app properties, find and replace, outline, statistics, plain-text extraction, and validate().
  • Uses standalone tree-shakeable functions, ships ESM-only with bundled .d.ts types, has one runtime dependency, and works in Node.js and browsers.

Use Cases

  • Fill a Word template by opening an existing .docx, replacing placeholders such as {{name}}, and saving the result.
  • Generate reports, contracts, letterheads, and other structured documents programmatically from Node.js or browser code.
  • Edit existing documents by changing text, images, headers, footers, notes, comments, or tracked changes while keeping unmodeled content intact.
  • Preview Word documents in a web page without uploading the file by using the browser preview package.

Getting Started

  • Install with npm i @office-kit/docx, pnpm add @office-kit/docx, or yarn add @office-kit/docx.
  • Import createDocx to build a document from scratch, or openDocx to open an existing .docx template.
  • Use functions such as appendParagraph, addBulletList, addTable, setPageSize, replaceTextEverywhere, and toUint8Array to construct or modify the document.
  • For browser preview, pair the library with @office-kit/docx-preview and call previewToDOM.

Deployment & Requirements

  • Runs in modern browsers and Node.js.
  • Ships ESM-only with bundled .d.ts types.
  • Has no Node-only dependencies and works in browsers, including with the Blob and File APIs.
  • One runtime dependency: fflate for ZIP handling.
  • @office-kit/docx-preview wraps the OSS docx-preview renderer and runs in the browser.

Before You Adopt

  • License: MIT. Review its terms before using, modifying, or distributing the project.
  • The project is pre-1.0; core functions are stable but details may change before v1.
  • The library has one runtime dependency, fflate, for ZIP handling.
  • Merged table cells, nested tables, floating images, text boxes, charts, a typed API for content controls, ISO/IEC 29500 Strict files, and PDF rendering are not yet supported.

Comments

Sign in to leave a comment.

More like @office-kit/docx

Favicon of @office-kit/pptx

@office-kit/pptx

Free ListingStars: 0K

Read, edit, and write .pptx files in TypeScript

Document Parsing & OCR

@office-kit/pptx is a TypeScript library for reading, editing, and writing PowerPoint (.pptx) files in Node and the browser. MIT licensed, no native modules, single ESM bundle.

Favicon of anydoc

anydoc

Free ListingStars: 22.1K

Convert documents to GitHub-Flavored Markdown in Rust.

Document Parsing & OCR

anydoc is an open-source Rust library that converts Word, PowerPoint, Excel, OpenDocument, RTF, EPUB, CSV, and PDF documents into clean GitHub-Flavored Markdown, with Node.js, Python, browser, WebAssembly, and CLI bindings.

Favicon of PaddleOCR

PaddleOCR

Free ListingStars: 90.2K

Global Leading OCR Toolkit & Document AI Engine

Document Parsing & OCR

PaddleOCR is a powerful, lightweight OCR and document parsing toolkit that turns PDFs and images into structured, LLM-ready data. It supports 100+ languages, JSON and Markdown output, and helps build RAG and Agentic applications.