Converting HEIC to JPG entirely in the browser (no upload, no server)

javascript dev.to

If you have ever received a photo from an iPhone and gotten a .heic file that Windows refuses to preview, you have met Apple's High Efficiency Image Container format. It saves space, but support outside the Apple ecosystem is still patchy in 2026.

Most online converters solve this by uploading your image to a server, converting it there, and sending it back. That works, but it means your personal photos travel to someone else's machine. For a format that is almost always personal photos, that bothered me. So I built a converter that never uploads anything.

The approach: decode HEIC client-side with WebAssembly

HEIC is essentially HEVC (H.265) intra-frames wrapped in a container. Browsers do not decode it natively, so the trick is to run a HEIC decoder compiled to WebAssembly directly in the page.

The high level flow:

  1. User drops a .heic file. You read it with the File API as an ArrayBuffer.
  2. A WASM build of libheif decodes the image into raw RGBA pixel data.
  3. You paint that data onto an offscreen canvas.
  4. canvas.toBlob() re-encodes it as JPEG, PNG or WebP at the quality you choose.
  5. You hand the user a download link via URL.createObjectURL().
const buffer = await file.arrayBuffer();
const image = await heifDecoder.decode(buffer); // libheif (wasm)
const canvas = document.createElement('canvas');
canvas.width = image.width;
canvas.height = image.height;
canvas.getContext('2d').putImageData(image.toImageData(), 0, 0);
canvas.toBlob((blob) => downloadBlob(blob, 'photo.jpg'), 'image/jpeg', 0.92);
Enter fullscreen mode Exit fullscreen mode

Why client-side is worth the effort

  • Privacy: the file never leaves the device. No upload, no retention.
  • Speed: no round trip. Conversion starts the instant the file is read.
  • Cost: no servers to run, so the tool can stay free. It is just static files on a CDN.
  • Offline: once the page is cached, it works with no network at all.

The trade-off is bundle size (the WASM decoder is a few hundred KB) and that very large batches lean on the user's CPU. For typical phone photos it is instant.

The live tool

I packaged this into a free tool if you just want to convert something now: LivePhotoKit. It does HEIC to JPG/PNG/WebP/PDF, opens .livp Live Photo files, extracts the MP4, and batch converts, all in the browser with no sign-up.

If you want the non-developer walkthrough, I wrote it up here: How to open HEIC files on Windows 11.

Have you shipped anything with a WASM media decoder? I would love to compare notes on bundle size vs decode speed trade-offs.

Source: dev.to

arrow_back Back to Tutorials