Skip to content
LiteParse
Guides

Browser Usage (WASM)

Run LiteParse entirely in the browser with the WASM package.

LiteParse ships a WebAssembly package that runs entirely in the browser — no server, no cloud calls. It supports PDF parsing and custom OCR engines implemented in JavaScript.

Terminal window
npm install @llamaindex/liteparse-wasm
import init, { LiteParse } from "@llamaindex/liteparse-wasm";
// Load the WASM module
await init();
const parser = new LiteParse({
ocrEnabled: false,
outputFormat: "json",
});
// data is a Uint8Array (e.g. from <input type="file"> or fetch)
const bytes = new Uint8Array(await file.arrayBuffer());
const result = await parser.parse(bytes);
console.log(result.text);
console.log(result.pages[0]);
  • PDF parsing from Uint8Array input (use file.arrayBuffer() to get bytes from a file picker for example)
  • Custom OCR via the ocrEngine callback interface (see below)
  • Text, JSON, and markdown output formats
  • Document complexity via parser.isComplex(bytes) — see the complexity guide
  • The extraction options — annotations, form fields, structure trees, vector graphics, and the rest. See Extraction options
  • File path input — pass Uint8Array instead
  • DOCX/XLSX/PPTX conversion — requires LibreOffice, which isn’t available in the browser
  • Built-in Tesseract or HTTP OCR — use the custom ocrEngine interface instead
  • Screenshots — not available in the WASM build
  • numWorkers — parsing is single-threaded in WASM; the option is not exposed
  • imageOutputDir — there is no filesystem to write to. Use extractImages and read the bytes from the result instead

The native Tesseract and HTTP OCR backends are not available in WASM. To use OCR, pass a custom ocrEngine object with a recognize method:

const parser = new LiteParse({
ocrEnabled: true,
ocrLanguage: "eng",
ocrEngine: {
/**
* @param imageData PNG-encoded image bytes
* @param width rendered page width in pixels
* @param height rendered page height in pixels
* @param language e.g. "eng"
* @returns array of { text, bbox: [x1, y1, x2, y2], confidence }
*/
async recognize(imageData, width, height, language) {
// e.g. call a Web Worker wrapping tesseract.js, or a remote OCR service
return [
{ text: "Hello", bbox: [10, 20, 80, 40], confidence: 0.98 },
];
},
},
});

This lets you plug in any OCR implementation — a Web Worker running tesseract.js, a cloud OCR API, or anything else that returns text with bounding boxes.

All optional, camelCase:

OptionTypeDefaultDescription
ocrLanguagestring"eng"Language code passed to the OCR engine
ocrEnabledbooleanfalseRun OCR on text-sparse pages. Off by default in WASM — there is no built-in engine, so this does nothing without ocrEngine
ocrEngineobjectCustom JS-side OCR engine (see above)
ocrFailureFatalbooleantrueWhen false, OCR failures return partial results instead of throwing
ocrHedgeDelaysMsnumber[][]Request-hedging schedule for a remote ocrEngine
maxPagesnumber1000Stop after this many pages
targetPagesstringe.g. "1-5,10,15-20"
dpinumber150Render DPI for OCR
outputFormat"json" | "text" | "markdown""json"Shape of result.text. Also accepts "md". Throws on any other value
preserveVerySmallTextbooleanfalseKeep tiny text that’s normally filtered
skipDiagonalTextbooleanfalseDrop text more than 2° off the nearest right angle
cropBox{ top, right, bottom, left }Fraction to crop from each side of every page
passwordstringPassword for protected PDFs
quietbooleanfalseSuppress progress logging
imageMode"off" | "placeholder" | "embed""placeholder"How image references appear in markdown. Also accepts "none" for off
extractLinksbooleantrueRender [text](url) in markdown
keepHeadersFootersbooleanfalseKeep running header/footer chrome in markdown
emitWordBoxesbooleanfalsePer-word sub-boxes on each text item

The extraction optionsextractImages, extractVectorGraphics, extractAnnotations, extractFormFields, extractStructureTree, extractContentBounds, extractXfaPackets, extractTextMetadata, includeComplexity, and renderFormFields — are all available here too, with the same camelCase names and the same false defaults.

Note for AI agents: this documentation is built for programmatic access. - Overview of all docs: https://developers.llamaindex.ai/llms.txt - Any page is available as raw Markdown by appending index.md to its URL — e.g. https://developers.llamaindex.ai/llamaparse/parse/getting_started/index.md - Agent-friendly REST search APIs live under https://developers.llamaindex.ai/api/ — search (BM25 full-text), grep (regex), read (fetch a page), and list (browse the doc tree). See https://developers.llamaindex.ai/llms.txt for parameters. - A hosted documentation MCP server is available at https://developers.llamaindex.ai/mcp. If you support MCP, you can ask the user to install it for browsing these docs directly (an alternative to the REST API). Setup: https://developers.llamaindex.ai/for-agents/mcp/ - Other LlamaIndex tooling for agents — the LlamaParse Platform MCP server, agent skills and plugins, and the n8n node — is mapped at https://developers.llamaindex.ai/for-agents/