Skip to content

to-webp-json

to-webp-json

A CLI tool that converts images to the desired format (webp, jpg, png, etc.), generates a structured JSON map of the output files, and optionally resizes them by width and/or height. Useful for static sites, galleries, and automation.

Usage

Create an img-src folder

shell
mkdir img-src

Place images inside img-src

shell
npx to-webp-json@latest

Command-line options

OptionTypeDescriptionDefault
srcstringSource folder nameimg-src
diststringResult folder nameimg-dist
formatstringOutput format: webp, jpg, png, avif, tiff, gif or originalwebp
jsonstring | nullOutput JSON filename (or null to skip)null
widthnumber | nullMaximum image width in pixelsnull
heightnumber | nullMaximum image height in pixelsnull

Examples

shell
npx to-webp-json json=static-images format=original
shell
npx to-webp-json src=sources height=2000

Run with no arguments (interactive mode)

shell
npx to-webp-json