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

@docmux/wasm

v0.5.0

Published

Universal document converter — WASM bindings for docmux

Downloads

94

Readme

@docmux/wasm

Universal document converter — WASM bindings for docmux.

Convert between Markdown, LaTeX, Typst, MyST, HTML, DOCX, and plaintext in the browser or Node.js.

Install

npm install @docmux/wasm

Usage

import { convert, convertStandalone } from "@docmux/wasm";

// Fragment conversion (no document wrapper)
const result = await convert("# Hello\n\nWorld!", "markdown", "html");
if (result.error) {
  console.error(result.error);
} else {
  console.log(result.output);
  // <h1>Hello</h1>
  // <p>World!</p>
}

// Standalone conversion (full HTML document with <head>, <body>, etc.)
const doc = await convertStandalone("# Hello", "markdown", "html");
// Returns a complete HTML page with doctype, head, body

Format conversion examples

import { convert } from "@docmux/wasm";

// Markdown → HTML
await convert("**bold** and *italic*", "markdown", "html");

// Markdown → LaTeX
await convert("# Chapter\n\nSome text.", "markdown", "latex");

// LaTeX → HTML
await convert("\\textbf{bold} and \\textit{italic}", "latex", "html");

// Typst → Markdown
await convert("= Heading\nSome *emphasized* text.", "typst", "markdown");

// HTML → Plaintext
await convert("<h1>Title</h1><p>Content</p>", "html", "plaintext");

Binary formats (DOCX)

DOCX files are binary — use the Bytes variants with Uint8Array input:

import { convertBytes, convertBytesStandalone, parseBytesToJson } from "@docmux/wasm";

// From a File input
const file = document.querySelector("input[type=file]").files[0];
const bytes = new Uint8Array(await file.arrayBuffer());

// DOCX → HTML
const result = await convertBytes(bytes, "docx", "html");

// DOCX → Standalone HTML (full page)
const standalone = await convertBytesStandalone(bytes, "docx", "html");

// DOCX → AST JSON (inspect the parsed structure)
const ast = await parseBytesToJson(bytes, "docx");

Parsing to AST

Inspect the parsed document structure as JSON:

import { parseToJson } from "@docmux/wasm";

const ast = await parseToJson("# Hello\n\n- item 1\n- item 2", "markdown");
if (!ast.error) {
  console.log(JSON.parse(ast.output));
  // { blocks: [{ Heading: { level: 1, ... } }, { List: { ... } }], meta: { ... } }
}

Supported formats

| Format | Input name | Reader | Writer | |--------|-----------|--------|--------| | Markdown (CommonMark + GFM) | "markdown" or "md" | ✅ | ✅ | | HTML5 | "html" | ✅ | ✅ | | LaTeX | "latex" or "tex" | ✅ | ✅ | | Typst | "typst" | ✅ | ✅ | | MyST Markdown | "myst" | ✅ | — | | DOCX (binary) | "docx" | ✅ | ✅ | | Plaintext | "plaintext" or "txt" | — | ✅ |

List formats programmatically:

import { getInputFormats, getOutputFormats } from "@docmux/wasm";

const inputs = await getInputFormats();   // ["markdown", "md", "latex", ...]
const outputs = await getOutputFormats();  // ["html", "latex", "typst", ...]

Error handling

All functions return a ConvertOutcome discriminated union:

type ConvertOutcome = ConversionResult | ConversionError;

interface ConversionResult {
  output: string;
  error: null;
}

interface ConversionError {
  output: null;
  error: string;  // Human-readable error message
}

Check result.error to narrow the type:

const result = await convert(input, "markdown", "html");
if (result.error) {
  // result is ConversionError — result.output is null
  showError(result.error);
} else {
  // result is ConversionResult — result.output is string
  render(result.output);
}

Raw bindings

For advanced use cases, import directly from @docmux/wasm/raw to get the raw wasm-bindgen functions without the wrapper:

import { convert, inputFormats } from "@docmux/wasm/raw";

// Functions are synchronous and throw on error (no ConvertOutcome wrapper)
try {
  const html = convert("# Hello", "markdown", "html");
} catch (e) {
  console.error("Conversion failed:", e);
}

const formats = inputFormats(); // string[]

Environment support

  • Bundler (Vite, Webpack, etc.) — import normally, the bundler handles .wasm loading
  • Node.js — WASM loads automatically from the filesystem

License

MIT — see LICENSE.