📦

Image Compressor

Compress an image to reduce file size while maintaining visual quality

GET 10 credits /v1/image/compress
curl "https://image.toolkitapi.io/v1/image/compress?url=https://toolkitapi.io/static/samples/sample-image.png&quality=75&format=jpeg"
import httpx

resp = httpx.get(
    "https://image.toolkitapi.io/v1/image/compress?url=https://toolkitapi.io/static/samples/sample-image.png&quality=75&format=jpeg",
)
print(resp.json())
const resp = await fetch("https://image.toolkitapi.io/v1/image/compress?url=https://toolkitapi.io/static/samples/sample-image.png&quality=75&format=jpeg", {
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "image": "/9j/4AAQSkZJRgABAQ...(base64 data)...",
  "format": "jpeg",
  "quality": 75,
  "compressed_size_bytes": 524288
}

Try It Live

Live Demo

Description

Compress an image to reduce file size while maintaining visual quality

How to Use

1

1. Provide the source image via the `url` query parameter.

2

2. Set the `quality` parameter — 75 is a good default for JPEG, 80 for WebP.

3

3. Choose `format` (jpeg for photos, webp for modern browsers, png for lossless).

About This Tool

Use the Image Compressor to reduce file size for faster web delivery, email attachments, and storage optimization. Control the quality parameter from 1 (maximum compression) to 100 (lossless for PNG) to balance size and visual fidelity.

The endpoint reports the compressed file size, so you can verify the savings. JPEG and WebP formats offer the best compression ratios; PNG compression is lossless.

Why Use This Tool

Frequently Asked Questions

What quality setting should I use?
For JPEG photos, 70–80 offers good quality with significant size reduction. For WebP, 75–85 is optimal. Quality 100 with PNG format produces lossless output.
Why is my reduction percentage negative?
This can happen when compressing already-optimized images or converting from a lossy format to PNG. Try a lower quality setting or a lossy output format.
Does compression change the image dimensions?
No, compression only reduces file size through quality adjustment. Dimensions remain unchanged. To reduce dimensions, use the Resize endpoint first.

Start using Image Compressor now

Get your free API key and make your first request in under a minute.