PicoWebPJS adds WebP conversion to Node.js and browser applications without installing native image libraries or shipping a WebAssembly module. Its encoder and bundled image readers run in JavaScript, with zero runtime package dependencies.
It is useful when image-processing dependencies complicate deployment, or when conversion needs to happen on the user’s device.
Where PicoWebPJS fits
- Node.js applications with deployment constraints. Add WebP encoding without packaging platform-specific native bindings or a separate command-line encoder.
- Browser upload and export tools. Convert images locally before uploading them, or let users create and download WebP files without sending their images to a conversion service.
- Applications with browser and server processing. Use the same encoding core for a browser tool and its Node.js background jobs.
Supported images
PicoWebPJS reads PNG, baseline JPEG and BMP files, and accepts raw RGB pixels. It preserves transparency and embedded ICC colour profiles, and recognises existing WebP files from their contents so they can be skipped.
The package includes a command-line interface, ESM and CommonJS builds, and TypeScript declarations.
Browser and background processing
The repository includes a Web Worker example for moving image decoding and encoding off the browser’s main thread. This lets the page remain responsive while conversion runs.
For longer Node.js jobs, staged encoding lets your application save progress and resume in another process. Your application controls scheduling and state storage.
Performance and limits
Decoding and encoding are synchronous. Use a worker for substantial browser processing and set image-size limits appropriate to your application.
Native encoders are generally faster. PicoWebPJS is useful when avoiding native dependencies matters more than maximum conversion throughput. Resumable processing lets you divide a job across runs; it does not make the encoding itself faster.
Colour compression is lossy, while transparency is compressed losslessly. Progressive JPEG input needs an additional decoder.
PicoWebPJS is available on npm under the MIT licence. The Node.js API and CLI require Node 18 or newer.
For PHP applications on restricted hosting, see PicoWebP.
Installation
npm install picowebpjs