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

advanced-html-to-docx

v1.0.4

Published

Convert HTML content to DOCX with full style support

Readme

advanced-html-to-docx

advanced-html-to-docx converts HTML content to a DOCX file. It runs in Node.js and produces a buffer/blob that you can write to disk.

Installation

Install from local source or your preferred distribution method.

Usage

const fileBuffer = await HTMLtoDOCX(htmlString, headerHTMLString, documentOptions, footerHTMLString);

Examples are under example/.

Header, Footer, Page Number

  • Enable with header: true and/or footer: true in documentOptions.
  • headerHTMLString and footerHTMLString should be simple HTML. Use a top-level <p> for reliable rendering.
  • Page numbers are appended to the first footer paragraph when pageNumber: true is set.

Supported HTML (Common)

  • Headings: h1 to h6
  • Text: p, span, strong, b, i, u, s, del, strike, sub, sup
  • Lists: ol, ul, li
  • Tables: table, thead, tbody, tr, td, th, colgroup, col
  • Images: img (base64 data URLs are supported; external URLs require network access)
  • Blockquote: blockquote
  • Page break: <div class="page-break" style="page-break-after: always;"></div>

Lists

list-style-type on <ol> is supported:

<ol style="list-style-type:lower-alpha;">
  <li>List item</li>
</ol>

Supported ordered list styles:

  • upper-alpha
  • lower-alpha
  • upper-roman
  • lower-roman
  • lower-alpha-bracket-end
  • decimal-bracket-end
  • decimal-bracket
  • decimal (default)

To start at a specific value, set data-start="n". Example: <ol data-start="3"> starts at c. for lower-alpha.

Tables

Table widths are based on width in pixels, cm, or inches. Column widths can be set on <col> or on cells:

<table style="width: 600px; table-layout: fixed;">
  <tr>
    <td style="width: 200px;">Col 1</td>
    <td style="width: 200px;">Col 2</td>
    <td style="width: 200px;">Col 3</td>
  </tr>
</table>

Images

Use base64 data URLs for reliable output:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" />

External image URLs depend on network access and may be blocked in some environments.

Document Options

  • orientation: portrait or landscape
  • pageSize: { width, height } (TWIP or px/cm/in)
  • margins: { top, right, bottom, left, header, footer, gutter }
  • headerType: default, first, even
  • footerType: default, first, even
  • header: boolean
  • footer: boolean
  • pageNumber: boolean (only if footer is enabled)
  • font, fontSize, complexScriptFontSize
  • table.row.cantSplit: boolean
  • skipFirstHeaderFooter: boolean
  • lineNumber, lineNumberOptions
  • numbering.defaultOrderedListStyleType
  • decodeUnicode: boolean
  • lang: language code

Returns

Promise<Buffer|Blob>

Notes

  • Font family mapping varies across word processors.
  • For browser usage, a blob polyfill may be required.

License

MIT