Skip to content

Quick Start: WebAssembly

EdgeParse compiles to WebAssembly, enabling client-side PDF extraction in any modern browser. The same Rust engine that powers the CLI, Python, and Node.js SDKs runs locally in the user’s browser tab.

Key properties:

  • PDF data never leaves the user’s device
  • Works offline after initial WASM load (~4 MB)
  • Same accuracy as the native CLI for born-digital PDFs
  • Optional in-browser OCR for image tables via @edgeparse/web
  • Zero backend infrastructure

On the official odl-bench board, EdgeParse WASM scores 0.854 overall (TEDS 0.776).

Terminal window
npm install edgeparse-wasm
# or with the product SDK
npm install @edgeparse/web edgeparse-wasm
Terminal window
# Install wasm-pack (one-time)
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
# Build for browser use
cd crates/edgeparse-wasm
wasm-pack build --target web --release

Output goes to crates/edgeparse-wasm/pkg/.

import init, { convert_to_string } from 'edgeparse-wasm';
// Load WASM binary (call once at startup)
await init();
// Read a PDF file (from user upload, fetch, etc.)
const response = await fetch('/my-report.pdf');
const bytes = new Uint8Array(await response.arrayBuffer());
// Extract Markdown
const markdown = convert_to_string(bytes, 'markdown');
console.log(markdown);
// Extract structured JSON
const json = convert_to_string(bytes, 'json');
// Extract HTML
const html = convert_to_string(bytes, 'html');
// Extract plain text
const text = convert_to_string(bytes, 'text');

For async host OCR (used by @edgeparse/web):

import init, { ParseSession } from 'edgeparse-wasm';
await init();
const session = ParseSession.open(bytes, {
tableMethod: 'cluster',
fileName: 'report.pdf',
}, (phase, done, total) => {
console.log(phase, done, total);
});
const candidates = session.candidates(); // [{id, page, width, height, hash}]
for (const c of candidates) {
const gray = session.candidate_gray(c.id);
// Run OCR on gray, then:
// session.provide_ocr(c.id, words);
}
const markdown = session.finish('markdown');
import init, { convert_to_string } from 'edgeparse-wasm';
await init();
const fileInput = document.getElementById('pdf-input') as HTMLInputElement;
fileInput.addEventListener('change', async () => {
const file = fileInput.files?.[0];
if (!file) return;
const bytes = new Uint8Array(await file.arrayBuffer());
const markdown = convert_to_string(bytes, 'markdown');
document.getElementById('output')!.textContent = markdown;
});

Use convert_to_string() with 'json' format and JSON.parse() to get the same structured schema as the Python/Node.js SDKs — a flat kids array with element objects:

import init, { convert_to_string } from 'edgeparse-wasm';
await init();
const bytes = new Uint8Array(await file.arrayBuffer());
const doc = JSON.parse(convert_to_string(bytes, 'json'));
for (const el of doc.kids) {
console.log(`[${el.type}] page ${el['page number']}: ${el.content ?? ''}`);
}
// Parse only pages 1-5
const markdown = convert_to_string(bytes, 'markdown', '1-5');
// Parse specific pages
const json = convert_to_string(bytes, 'json', '1,3,7');
// Default: ruling-line detection (best for tables with borders)
const md1 = convert_to_string(bytes, 'markdown', 'all', 'auto', 'default');
// Cluster method: for borderless tables
const md2 = convert_to_string(bytes, 'markdown', 'all', 'auto', 'cluster');
vite.config.ts
import { defineConfig } from 'vite';
export default defineConfig({
optimizeDeps: {
exclude: ['edgeparse-wasm'],
},
build: {
target: 'esnext',
},
});
webpack.config.js
module.exports = {
experiments: {
asyncWebAssembly: true,
},
};

Try EdgeParse WASM in your browser: edgeparse.com/demo/

Upload any PDF and see extracted Markdown, JSON, HTML, or text — all processing runs locally.