# Squoosh — Browser-Based Image Compression by Google > Squoosh is an open-source web app from Google Chrome Labs that compresses images using codecs like MozJPEG, AVIF, WebP, and OxiPNG directly in the browser with no server uploads required. ## Install Save as a script file and run: # Squoosh — Browser-Based Image Compression by Google ## Quick Use ```bash # Install the Squoosh CLI npm install -g @squoosh/cli # Compress a single image to WebP at quality 75 squoosh-cli --webp '{"quality":75}' input.png -d output/ # Batch compress a folder to AVIF squoosh-cli --avif '{"cqLevel":30}' images/*.jpg -d compressed/ ``` ## Introduction Squoosh is a web application and CLI tool built by Google Chrome Labs that lets developers compress and convert images using modern codecs. It runs entirely in the browser via WebAssembly, so no image data ever leaves your machine. The CLI version brings the same codec power to build pipelines and automation scripts. ## What Squoosh Does - Compresses images using MozJPEG, WebP, AVIF, OxiPNG, and other codecs in-browser via WASM - Provides a side-by-side visual comparison of original vs compressed output - Supports resize, reduce palette, and quantization controls per codec - Offers a Node.js CLI for batch processing in CI/CD pipelines - Outputs optimized images with no server round-trip or cloud dependency ## Architecture Overview Squoosh compiles each image codec (libjpeg, libwebp, libavif, oxipng) to WebAssembly so it runs at near-native speed inside the browser. The web app is a Preact-based PWA that uses Web Workers to keep the UI responsive during heavy encoding. The CLI wraps the same WASM modules in a Node.js process for headless batch use. ## Self-Hosting & Configuration - Clone the repo and run `npm install && npm run build` to produce a static site - Serve the `build/` directory behind any web server (Nginx, Caddy, S3) - No database or backend required; all processing happens client-side - The CLI is configured entirely via command-line flags per codec - Docker is not needed; a simple static file host is sufficient ## Key Features - Zero data upload — all encoding runs locally in WebAssembly - Supports next-gen formats (AVIF, WebP, JPEG XL) alongside legacy JPEG/PNG - Real-time visual diff with a draggable slider for quality comparison - Works offline as a Progressive Web App after first load - CLI enables integration into GitHub Actions, Webpack, or custom pipelines ## Comparison with Similar Tools - **ImageOptim** — macOS-only native app; Squoosh is cross-platform and browser-based - **Sharp** — Node.js library for server-side processing; Squoosh runs client-side via WASM - **TinyPNG** — cloud service with upload limits; Squoosh is fully local and unlimited - **Imgproxy** — server-side proxy for on-the-fly resizing; Squoosh is a standalone optimizer - **Caesium** — desktop GUI compressor; Squoosh adds a web UI plus CLI for automation ## FAQ **Q: Does Squoosh upload my images to a server?** A: No. All compression happens locally in your browser using WebAssembly. No data leaves your machine. **Q: Can I use Squoosh in a CI pipeline?** A: Yes. The @squoosh/cli npm package lets you batch-compress images in any Node.js environment. **Q: Which codec should I choose for web delivery?** A: AVIF offers the best compression ratio for photos, with WebP as a widely supported fallback. Use OxiPNG for graphics with transparency. **Q: Is the project still maintained?** A: The web app remains functional. The CLI package is in maintenance mode; for heavy automation consider Sharp or libvips. ## Sources - https://github.com/GoogleChromeLabs/squoosh - https://squoosh.app --- Source: https://tokrepo.com/en/workflows/asset-b35e42b3 Author: Script Depot