← All libraries

browser-image-compression

JavaScript
↗ Official site

Images & file upload

Compress images in the browser before uploading.

What it does

This library reduces image file size in the browser using canvas compression. Users can upload a 5MB photo and it gets compressed to 500KB before hitting your server — saving storage and bandwidth.

When to use it

Use this when users upload images and you want to reduce file size before saving to a server or cloud storage.

Real example

Users upload high-res photos to your travel blog and your storage is filling up fast. Prompt: 'Use browser-image-compression in the file input onChange handler. Compress the file to maxSizeMB: 1 and maxWidthOrHeight: 1920. Show a progress indicator during compression. Upload the compressed file instead of the original.'

Good to know

Works entirely client-side — no server needed for compression.

Alternatives

Squoosh (manual)

Install

$ npm install browser-image-compression

Use cases

image compressionfile uploadclient-side

Language

JavaScript

Category

Images & file upload

More in Images & file upload

Other tools in the same category