Mammoth.js

Convert Word .docx documents into clean, semantic HTML and Markdown in JavaScript.

Library
npm
v1.12.1
6,284stars
BSD-2-Clause

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
66/100Good
Development Activity56
Maintenance36
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture82
Code Quality83
Innovation86
Learning Curve85

Mammoth.js converts Word .docx documents — including those authored in Microsoft Word, Google Docs, and LibreOffice — into clean, semantic HTML rather than a pixel-perfect copy of the original formatting. It leans on the document’s semantic styles, mapping a paragraph styled as “Heading 1” to an h1 element instead of trying to reproduce fonts, sizes, and colors, which keeps the generated markup simple and predictable.

The library runs in both Node.js and the browser and ships with a CLI, a promise-based API, and a small style-map DSL that lets you customize how your own document styles translate to HTML. It supports headings, lists, tables, footnotes, images, links, comments, and common inline formatting, making it a practical tool for ingesting Word content into web applications and content pipelines.

What You Get

  • A promise-based convertToHtml / convertToMarkdown / extractRawText API for Node.js and the browser
  • A mammoth CLI for converting documents and exporting images to a directory
  • A customizable style-map DSL for mapping your own Word styles to specific HTML elements and classes
  • Support for headings, lists, tables, footnotes, endnotes, images, links, comments, and inline formatting
  • Pluggable image converters for controlling how embedded images are emitted (inline data URIs or external files)

Common Use Cases

  • Importing Word documents authored by non-technical users into a CMS or web application
  • Building content pipelines that normalize .docx uploads into semantic HTML
  • Extracting raw text from Word documents for search indexing or analysis
  • Mapping bespoke corporate Word styles to a consistent set of HTML components

Under The Hood

Architecture Mammoth is organized as a clean multi-stage pipeline centered on lib/index.js, which orchestrates conversion via convert(). Input is opened with lib/unzip.js (a .docx is a zip archive), then lib/docx/docx-reader.js and its collaborators — body-reader.js, document-xml-reader.js, notes-reader.js, styles-reader.js, numbering-xml.js, and relationships-reader.js — parse the OOXML parts into an internal document model defined in lib/documents.js. The parsed document is then handed to DocumentConverter in lib/document-to-html.js, which applies the resolved style map and emits output through pluggable writers in lib/writers/ (HTML or Markdown). Style mappings are parsed by lib/style-reader.js using the lop parser-combinator DSL, and results/warnings flow through a Result monad in lib/results.js that threads conversion messages alongside values.

Tech Stack Written in JavaScript (99.5% of the repo) targeting Node.js >=12. Core runtime dependencies include @xmldom/xmldom for XML parsing, jszip for reading the zip container, bluebird for promises, lop for the style-map grammar, underscore for utilities, argparse for the CLI, plus base64-js, dingbat-to-unicode, path-is-absolute, and xmlbuilder. Browser builds are produced with browserify, and a browser/ directory provides browser-specific implementations of unzip.js and docx/files.js via the package’s browser field.

Code Quality The project is well tested: 33 .tests.js suites run under Mocha with hamjest/duck matchers, covering the readers, converters, style parsing, images, and raw-text extraction. ESLint runs as a pretest step, and error handling is disciplined — rather than throwing on recoverable issues, conversions accumulate warnings through the Result type and return them alongside the output, giving callers structured feedback. A hand-written lib/index.d.ts provides TypeScript types.

API Design The public API is small and ergonomic: a handful of promise-returning functions (convertToHtml, convertToMarkdown, extractRawText) take a simple input descriptor ({path}, {buffer}, or {arrayBuffer}) and an options object. Getting started requires almost no boilerplate, while the string- or array-based styleMap option and pluggable convertImage handlers offer deep customization without complicating the common case. The README is thorough, with extensive examples and a full style-map syntax reference.

Used by 23 apps in this directory

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
65
Dependency
Built with
TypeScript99%
Updated today
TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
95%
Apache 2.0

AionUi

AI Agents · Productivity

32,102

Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.

View details
88
Repo Health
76
Technical
66
Dependency
Built with
TypeScript95%
Updated today
JavaScript
95%
MIT

AnythingLLM

Developer Tools · Automation · AI Assistants

64,914

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
91
Repo Health
78
Technical
68
Dependency
Built with
JavaScript95%
Updated today
TypeScript
66%
Apache 2.0

Appsmith

Developer Tools · Automation · No Code Platforms

40,707

Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.

View details
94
Repo Health
79
Technical
68
Dependency
Built with
TypeScript66%
Java22%
Updated today
TypeScript
99%
MIT

Cate

AI Code Assistants

2,087

A desktop IDE built on an infinite canvas — spread code editors, terminals, browsers, docs, and AI agents across freeform space instead of stacking windows and tabs, with layouts restored automatically.

View details
79
Repo Health
71
Technical
72
Dependency
Built with
TypeScript99%
Updated today
TypeScript
97%
Apache 2.0

Cline

AI Code Assistants

66,453

An open-source AI coding agent that lives in your editor and terminal — reads and edits your codebase, runs commands, browses the web, and requires human approval for every action by default.

View details
90
Repo Health
74
Technical
67
Dependency
Built with
TypeScript97%
Updated today
TypeScript
97%
MIT

DenchClaw

CRM · AI Agents

1,643

An AI-native CRM you self-host on your own machine, built on the OpenClaw agent framework, with a DuckDB backend and pre-built agent skills for managing contacts, deals, reports, and 500+ outreach integrations from natural-language chat.

View details
69
Repo Health
73
Technical
71
Dependency
Built with
TypeScript97%
Updated 2 months ago
TypeScript
95%
AGPL 3.0

Docmost

Productivity · Note Taking · Collaboration

21,411

Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.

View details
89
Repo Health
70
Technical
71
Dependency
Built with
TypeScript95%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search