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

@origints/mammoth

v0.3.2

Published

DOCX to HTML conversion for Origins using mammoth.js

Downloads

53

Readme

@origints/mammoth

DOCX to HTML/text conversion for Origins using mammoth.js.


Features

  • Convert DOCX to semantic HTML
  • Convert DOCX to plain text
  • Custom style mapping for headings, lists, and more
  • Configurable image handling
  • Conversion warnings and messages
  • Integrates with Origins transform registry

Installation

npm install @origints/mammoth @origints/core

Usage with Planner

Convert a DOCX file and extract the HTML

import { Planner, loadFile, run } from '@origints/core'
import { docxToHtml } from '@origints/mammoth'

const plan = new Planner()
  .in(loadFile('document.docx'))
  .mapIn(docxToHtml())
  .emit((out, $) => out.add('html', $.get('html').string()))
  .compile()

const result = await run(plan, { readFile, registry })
// result.value: { html: '<h1>Title</h1><p>Content...</p>' }

Convert with custom style mapping

import { docxToHtml } from '@origints/mammoth'

const plan = new Planner()
  .in(loadFile('report.docx'))
  .mapIn(
    docxToHtml({
      styleMap: [
        "p[style-name='Title'] => h1.document-title",
        "p[style-name='Heading 1'] => h1",
        "p[style-name='Heading 2'] => h2",
        "p[style-name='Quote'] => blockquote",
      ],
      idPrefix: 'doc-',
    })
  )
  .emit((out, $) => out.add('content', $.get('html').string()))
  .compile()

Extract plain text from a DOCX file

import { docxToText } from '@origints/mammoth'

const plan = new Planner()
  .in(loadFile('document.docx'))
  .mapIn(docxToText())
  .emit((out, $) => out.add('text', $.get('text').string()))
  .compile()

const result = await run(plan, { readFile, registry })
// result.value: { text: 'Document Title\nContent here...' }

Combine DOCX with other sources

const plan = new Planner()
  .in(loadFile('report.docx'))
  .mapIn(docxToHtml())
  .emit((out, $) => out.add('reportHtml', $.get('html').string()))
  .in(loadFile('metadata.json'))
  .mapIn(parseJson())
  .emit((out, $) =>
    out
      .add('author', $.get('author').string())
      .add('date', $.get('date').string())
  )
  .compile()

Standalone usage (without Planner)

import * as fs from 'fs'
import { docxToHtmlImpl, docxToTextImpl } from '@origints/mammoth'

const buffer = fs.readFileSync('document.docx')

// Convert to HTML
const htmlResult = await docxToHtmlImpl.execute(buffer)
console.log(htmlResult.html)

// Log conversion warnings
for (const msg of htmlResult.messages) {
  console.warn(msg.message)
}

// Convert to plain text
const textResult = await docxToTextImpl.execute(buffer)
console.log(textResult.text)

Image handling

import { docxToHtml } from '@origints/mammoth'

// Omit images
const plan = new Planner()
  .in(loadFile('document.docx'))
  .mapIn(docxToHtml({ imageHandling: 'omit' }))
  .emit((out, $) => out.add('html', $.get('html').string()))
  .compile()

API

| Export | Description | | ------------------------------------- | -------------------------------------------------- | | docxToHtml(options?) | Create a transform AST for HTML conversion | | docxToText(options?) | Create a transform AST for text conversion | | docxToHtmlImpl | Async transform implementation for HTML conversion | | docxToTextImpl | Async transform implementation for text conversion | | registerMammothTransforms(registry) | Register all mammoth transforms with a registry |


License

MIT