🔄

Grayscale Filter

Convert an image to grayscale (black and white)

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

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

Try It Live

Live Demo

Description

Convert an image to grayscale (black and white)

How to Use

1

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

2

2. Optionally configure the output `format` and `quality` parameters.

About This Tool

Use the Grayscale Filter to convert any colour image to black and white. The endpoint uses luminance-based conversion via PIL's ImageOps module, producing natural-looking grayscale output.

This is commonly used for artistic effects, print preparation, accessibility improvements, and reducing visual complexity. The converted image is returned in your chosen output format with configurable quality.

Why Use This Tool

Frequently Asked Questions

Does grayscale conversion preserve transparency?
The image is converted to grayscale and then back to RGB mode, so alpha channels are not preserved. Use PNG format if you need lossless output.
Can I adjust the intensity of the grayscale effect?
This endpoint applies full grayscale conversion. For partial desaturation, use the Saturation Adjustment endpoint with a factor between 0.0 and 1.0.
What algorithm is used for grayscale conversion?
PIL's ImageOps.grayscale uses the ITU-R 601-2 luma transform (0.299R + 0.587G + 0.114B), which matches human perception of brightness.

Start using Grayscale Filter now

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