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.
Try it free, right now
No sign-up. No watermark. Your photo never leaves your browser.
โ๏ธ Open AI Background Remover