Files

Client-Side File Conversion with WebAssembly

How modern browsers can convert images, PDFs, audio and video without ever uploading your files to a server.

OneCalc Team 22 December 2025 8 min read

Why conversion belongs in the browser

Uploading a file to convert it means handing a copy of that file to somebody else's disk. For payslips, medical scans, contracts and identity documents that is an unacceptable default. Local conversion removes the transfer entirely: the bytes never leave the tab.

The secondary benefit is latency. A 40 MB video no longer needs a round trip; the only cost is CPU time on a machine the user already owns.

What WebAssembly changes

WebAssembly is a portable binary instruction format that runs at near-native speed inside the browser sandbox. Mature C and C++ codebases — FFmpeg, libvips, Ghostscript, Tesseract — compile to WASM largely unchanged, which means decades of battle-tested media code is available client-side.

Crucially, WASM inherits the browser's security model. A malformed file that would trigger a buffer overflow on a server is contained inside a linear memory sandbox with no filesystem or network access.

The practical toolchain

Images: the Canvas and OffscreenCanvas APIs handle raster conversion, resizing and compression natively; heic2any covers Apple's HEIC container.

Documents: pdf-lib for merge, split, rotate and encrypt; pdf.js for rasterising pages; mammoth for DOCX to HTML; SheetJS for spreadsheet formats.

Media: ffmpeg.wasm for audio and video transcoding. Text recognition: tesseract.js for OCR in 100+ languages.

Keeping the UI responsive

Run every conversion inside a Web Worker. A synchronous FFmpeg call on the main thread freezes the tab, and users interpret a frozen tab as a crash.

Stream progress back with postMessage so the progress bar reflects real work rather than a fake animation. Use transferable objects for ArrayBuffers to avoid copying large payloads between threads.

Honest limitations

Memory is the hard ceiling. A 32-bit WASM module addresses at most 4 GB, and mobile Safari often caps far lower. Very large videos and 500-page scanned PDFs remain server territory.

Codec licensing also applies: H.264 and HEVC encoding may require licensed builds, whereas VP9, AV1 and Opus are royalty-free and safe to ship.

Frequently asked questions

Are my files really never uploaded?

For browser-based conversion, yes — processing happens in your tab's memory and results are written to a local blob URL you download.

Why is the first conversion slower?

The WASM binary (often 10–30 MB for FFmpeg) has to download and compile once. Subsequent conversions reuse the cached module.

Does it work offline?

Once the WASM modules are cached by a service worker, most image, PDF and archive conversions work with no network at all.

Share this article

Related articles