Media
中文

background-removal-js: 7K Stars for In-Browser Background Removal

IMG.LY's open-source in-browser background removal library with 7.1K stars. Runs on ONNX locally, no uploads, privacy-friendly for e-commerce and creative tools.

image-processingbackground-removaljavascriptonnxfrontendprivacy

广告

background-removal-js: 7K Stars for In-Browser Background Removal

I used to remove image backgrounds either by tracing carefully in Photoshop or uploading to some online tool. Online tools are fast, but privacy always bothered me — product images getting uploaded to someone else’s server before they’re even published. background-removal-js solves exactly that problem.

What This Project Is

background-removal-js is an open-source, in-browser background removal library from IMG.LY, written in TypeScript, with 7.1K stars. Its standout feature is that all processing happens locally in the browser using an ONNX model, so images never need to be uploaded to any server.

IMG.LY itself makes image editing SDKs, including the PhotoEditor SDK. So they know what they’re doing when it comes to image processing.

Core Highlights

Pure frontend execution. Images never leave the user’s device. This is ideal for privacy-sensitive scenarios like e-commerce product photos, ID photos, and design assets.

No extra costs. Without a backend server, there are no API call fees. This advantage becomes huge as user volume grows.

Good enough quality. While it can’t beat a professional designer’s manual work, edges for people and products look quite natural. Thumbnails, product hero images, and social avatars are all perfectly fine use cases.

Simple API. Just a few lines of code:

import { removeBackground } from '@imgly/background-removal';

const blob = await removeBackground('/path/to/image.png');
const url = URL.createObjectURL(blob);

Configurable. You can adjust output quality, format, and model precision to balance speed and quality.

Quick Start

Install via npm:

npm install @imgly/background-removal

Then use it in your project:

import { removeBackground } from '@imgly/background-removal';

async function processImage(file) {
  const blob = await removeBackground(file, {
    output: {
      format: 'image/png',
      quality: 0.8
    }
  });
  return URL.createObjectURL(blob);
}

The model files download automatically on first use — roughly a few dozen MB. After that, it can run offline.

Pros and Cons

Pros:

  • Runs entirely in the browser, privacy-safe
  • No backend server needed, zero API costs
  • Easy integration with just a few lines of code
  • Quality is good enough for common scenarios
  • Configurable output format and quality
  • Open source and free for commercial use

Cons:

  • First load downloads the model, which is fairly large
  • Inference can be slow on low-end devices
  • Complex backgrounds or hair details aren’t as good as professional software n- Single image only; batch processing needs custom queue implementation
  • High precision settings use significant memory

Comparison

SolutionPrivacyCostQualityIntegrationBest For
background-removal-js✅ LocalFreeMediumEasyPrivacy-sensitive, frontend integration
remove.bg API❌ UploadPay-per-useExcellentEasyHigh-quality commercial use
Photoshop✅ LocalPaidBestHardProfessional design
Python rembg✅ LocalFreeMediumMediumBackend batch processing
Online tools❌ UploadPartially freeMediumEasiestOne-off use

If you’re building privacy-sensitive web apps like ID photo generators, e-commerce editing tools, or avatar makers, background-removal-js is a great fit.

Who Should Use It

Three scenarios fit well:

  1. Frontend tool products — image editors, poster generators, avatar makers
  2. E-commerce SaaS — batch product image processing, white-background generation
  3. Privacy-sensitive use cases — ID photos, medical imaging, internal documents

I tested it on dozens of product images. Most came out usable directly, and only a few with complex edges needed manual cleanup. For teams that don’t want to build a backend image service, it saves a lot of work.


About the Author

Liudingyu is a full-stack developer and heavy GitHub user. With 900+ starred repos over the past 3 years, this site only covers tools I’ve actually used or deeply researched.

📧 Found a great tool to recommend? Email [email protected]

广告

Related Posts