01What is @imgly/background-removal?
It's a JavaScript library that runs an ISNet image-segmentation neural network entirely in the browser. You give it a File or Blob, it returns a transparent PNG. No backend, no cloud function, no API key, no per-image cost.
Under the hood it uses ONNX Runtime Web, the same inference engine that powers many production AI products. The model weights are downloaded once, cached by the browser, and reused on every later visit.
02The three-line minimum setup
The whole integration is smaller than most npm installs:
import { removeBackground } from "https://cdn.jsdelivr.net/npm/@imgly/[email protected]/+esm"
const file = input.files[0]
const png = await removeBackground(file)
// png is a Blob — download it, show it, whatever
The +esm suffix tells jsDelivr to bundle the ESM module. You don't need a build step, Node, or a package manager. Paste it into a <script type="module"> and it works.
03Model sizes: pick the trade-off
The library ships three ISNet variants. You choose by passing model: 'small' | 'medium' | 'large':
| Model | Size | Best for | Speed (old laptop) |
|---|---|---|---|
| small (quantized) | ~30MB | Product photos, batch jobs, slow networks | ~4–6 s |
| medium (balanced) | ~60MB | Default — portraits, e-commerce | ~6–9 s |
| large (best) | ~150MB | Fine hair, fur, complex edges | ~12–20 s |
On a machine with WebGPU (any 2023+ GPU), all three finish in under 3 seconds. On CPU-only WASM, expect the numbers above — our AMD Ryzen 5 5500 test box processes a portrait in about 8 seconds on the medium model.
04Automatic hardware fallback
You don't write any GPU detection code. The runtime picks, in order:
- WebGPU — fastest, uses the GPU directly. Supported in Chrome 113+, Edge 113+, Safari 26.
- WebGL — fallback for older browsers that still have a GPU.
- WASM (CPU) — pure software, works everywhere, slowest but always available.
This means a 2018 iPhone and a 2026 workstation both run the same code, automatically.
05More than just transparent PNG
v1.7.0 added output options that most demos don't show. You can control both the file format and what gets exported:
// PNG (transparent) — default
removeBackground(file, {
output: { format: "image/png", type: "foreground" }
})
// JPEG on a white background (JPEG can't be transparent)
removeBackground(file, {
output: { format: "image/jpeg", quality: 0.9 }
})
// WebP — smaller file, still transparent
removeBackground(file, {
output: { format: "image/webp", quality: 0.9 }
})
// Black-and-white alpha mask — for post-processing
removeBackground(file, {
output: { type: "mask" }
})
| Format | Transparent | File size | Use case |
|---|---|---|---|
| PNG | ✓ | Largest | Design overlays, stickers |
| JPG | ✗ (white bg) | Smallest | Marketplaces, eBay, Amazon |
| WebP | ✓ | Medium | Web performance, modern browsers |
| Mask (B/W) | — | Tiny | Compositing, color-background swaps |
06Progress feedback users actually see
The library emits progress events so you can show a real loading bar instead of a spinner:
await removeBackground(file, {
progress: (key, current, total) => {
if (total === 0) return
const pct = Math.round((current / total) * 100)
console.log(`${key}: ${pct}%`) // download → load → run → postprocess
}
})
The four stages map naturally to a UX: download the model (only first visit), load it into WASM/WebGPU, run inference, postprocess the alpha mask. On returning visitors, download takes 0ms because the model is already in the browser cache.
07Why this beats remove.bg and other cloud tools
| @imgly/background-removal | Cloud tools (remove.bg etc.) | |
|---|---|---|
| Cost per image | Free forever | Credits / subscription |
| Photo leaves device | No | Yes — uploaded to server |
| API key required | No | Yes |
| Uptime dependency | None (after first load) | Depends on their service |
| Batch large images | Unlimited (local CPU) | Rate-limited |
| Offline after first load | Yes | No |
With remove.bg shutting down on December 1, 2026, browser-side inference isn't a niche curiosity anymore — it's the most reliable free path forward for e-commerce sellers, designers, and anyone who cares about privacy.
08Known limits (and what's coming)
- Busy backgrounds: ISNet can sometimes over-cut around wispy hair or thin branches. A follow-up version with brush-based refinement is on the way.
- First-load wait: 30–150MB model download. You can preload it on page open (like we do) so the user never sees the wait after upload.
- Very large images: downscaled internally before inference. For print-resolution output, run the large model.
Who actually benefits from local browser background removal?
For e-commerce sellers, this library is a game changer. If you're a small seller processing 50-100 product photos a week, paying remove.bg credits adds up fast — at $0.20 per image, that's $10-20 a week, or $500-1000 a year, just to cut out product backgrounds. With local browser processing, you can process all those photos for free, no per-image fees, and since the photos never leave your computer, you don't have to worry about your product shots being leaked to a random server. A lot of sellers have told us they were shocked at how good the local model is — it's not as perfect as the paid cloud model on super wispy hair, but for standard product photos on plain backgrounds, it's indistinguishable, and it's free. You can even run batch jobs: drop 20 product photos in at once, and the library processes them one after another locally, no upload queue, no rate limits, no waiting for a server to process each file. That's a huge upgrade over cloud tools that cap you at 2 free images a day on their free plan.
Privacy-focused users also love this approach. If you're cutting out personal photos — family portraits, headshots, photos of your kids — you probably don't want those images being uploaded to a random AI company's server, even if they say they delete them after processing. With local inference, the photo never touches any external server at all: it's decoded in your browser, the AI runs on your own CPU/GPU, and the output file stays on your device. There's no log of your photo on someone else's hard drive, no risk of it being leaked in a server breach, no terms of service that let the company train their model on your uploaded photos. For anyone who cares about personal privacy, that's a much better option than uploading sensitive personal photos to a cloud tool. We built our background remover specifically around this library, because we think people shouldn't have to sacrifice their privacy just to get a transparent PNG of their own photo.
One common question is whether this library works on older computers. The short answer is yes, but slower: on a 2017 laptop with no dedicated GPU, the small model will process a portrait in about 10 seconds, which is totally usable for occasional use. It's not instant, but it's free, and you don't have to wait for an upload to a remote server either — the whole process happens on your machine, so even on old hardware it's comparable in speed to uploading a photo to a cloud tool and waiting for the result. On modern laptops with WebGPU support, it's faster than any cloud tool, because there's no network round trip at all. The model runs entirely on your GPU, and the whole process from upload to download takes under 2 seconds, which feels like magic the first time you use it. You don't need a fancy new computer to use it, either — even a 5-year-old Chromebook will run it, just a bit slower. There's also no vendor lock-in: since the model runs in your browser, you can use this tool even if your internet goes down for a few minutes after the first page load, which is useful if you're working on a spotty coffee shop wifi connection. Cloud tools won't work at all if your internet cuts out, but once the model is cached locally, the background remover keeps working fully offline. That's a small but meaningful advantage for anyone who travels a lot, or works in an area with unreliable internet. You don't have to be a developer to benefit from this technology either — our web tool wraps all the complexity of the library into a simple drag-and-drop interface, so you don't have to write a single line of code to get a clean transparent PNG. Just upload your photo, wait a few seconds, and download the result, no setup required. This is the future of browser-based AI tools: powerful, private, free, and running right on your own device, no cloud subscription required.
Try it free, right now
No sign-up. No watermark. Your photo never leaves your browser.
✂️ Open AI Background Remover