Convert documents in the browser with WebAssembly
The weavon-wasm crate runs Markdown, HTML, JSON, PDF, diff, chunk, and lint completely client-side with zero npm dependencies.
Compact bundles with zero dependencies
- 1.86 MiBCore bundle gzipped
- 2.04 MiBWith PDF feature gzipped
- 9.62 ms100 KB Markdown in Node.js
- 0 depsPlain ES module wrapper
Load and convert in five lines
weavon.mjs uses only standard WebAssembly, TextEncoder, and TextDecoder. It runs in every modern browser, Deno, Bun, and Node.js 22 or later.
import { createWeavon } from "./weavon.mjs";
const weavon = await createWeavon(fetch("./weavon_wasm.wasm"));
const html = weavon.convert({ input: "# Hello\n\n$x^2$", from: "markdown", to: "html", math: "svg" });
const pdf = weavon.convertBytes({ input: "# Report", from: "markdown", to: "pdf" });
Operations in the browser module
convert and convertBytes- Converts Markdown, CommonMark, GFM, HTML, JSON, plain text, and PDF.
diff- Generates HTML, CriticMarkup, Markdown, JSON, DOCX, or PDF redlines.
chunk- Splits documents into RAG JSON Lines chunks with heading paths.
lint- Checks accessibility and DocOps rules and returns human text, JSON, or SARIF.
sniffFormat- Detects the document format from its leading bytes.
compat mode- Pass
compat: "pandoc-3.13"for byte-identical Pandoc output.
Build and load the WASM module
Add the WebAssembly target
Install the
wasm32-unknown-unknowntarget with rustup.rustup target add wasm32-unknown-unknownBuild the dist module
Compile
weavon-wasmwith thepdffeature to include client-side PDF output.cargo build -p weavon-wasm --target wasm32-unknown-unknown --profile dist --features pdfInstantiate in the browser
Load
weavon_wasm.wasmthroughcrates/weavon-wasm/js/weavon.mjs.import { createWeavon } from "./weavon.mjs"; const weavon = await createWeavon(fetch("./weavon_wasm.wasm")); console.log(weavon.convert({ input: "*Ready*", to: "html" }));
Common questions
How big is the Weavon WebAssembly bundle?
The dist core bundle is 1.86 MiB gzipped (4.21 MiB raw), and adding --features pdf gives 2.04 MiB gzipped (4.67 MiB raw). The dist-wasm profile shrinks core to 1.72 MiB gzipped.
Does it send user files to a server?
No. Every conversion, diff, chunk, and lint operation executes locally inside WebAssembly linear memory.
Does the browser module need npm or wasm-bindgen?
No. weavon.mjs is a standalone ES module with zero npm dependencies.
Which formats does weavon-wasm support?
It reads Markdown, CommonMark, GFM, HTML, JSON, and born-digital PDF, and writes those formats plus plain text and PDF 1.7.
