The BackgroundErase API supports three output formats: PNG, JPG, and WebP. You choose the output format using the format flag.
Quick summary: Use PNG when you need transparency, JPG when you want a flattened image with broad compatibility, and WebP when you want smaller files with modern format support.
The format flag
The API output format is controlled by the format option.
- Allowed values: png, jpg, webp
- Default: png
If you do not specify a format, the API returns PNG by default.
PNG output
PNG is the best choice when you want to preserve transparency. It is the most common output format for background removal because it supports alpha channels and is widely compatible with design tools, websites, and image editors.
- Supports transparency
- Best for cutouts and compositing
- Good for product photos, people, logos, and design assets
- Usually larger than JPG or WebP
curl -f https://api.backgrounderase.com/v2 \
-H "x-api-key: YOUR_API_KEY" \
-F 'image_file=@/path/to/image.jpg' \
-F 'format=png' \
-o output.pngJPG output
JPG is useful when you want a smaller, widely supported image file and do not need transparency. Because JPG does not support an alpha channel, any transparent output must be flattened against a background color.
- Does not support transparency
- Always opaque
- If transparency exists, it is flattened against bg_color
- If no bg_color is provided, white is used
- Best for standard image delivery where transparency is not needed
Important: JPG is a great choice for flat background replacements, but not for transparent cutouts.
curl -f https://api.backgrounderase.com/v2 \
-H "x-api-key: YOUR_API_KEY" \
-F 'image_file=@/path/to/image.jpg' \
-F 'format=jpg' \
-F 'bg_color=white' \
-o output.jpgWebP output
WebP is a modern image format that often provides smaller files than PNG while still supporting transparency. It can be a good choice for web delivery when file size matters and your target environment supports WebP well.
- Can support transparency
- Often smaller than PNG
- Good for web performance and modern browser delivery
- Not always ideal for older or legacy workflows
curl -f https://api.backgrounderase.com/v2 \
-H "x-api-key: YOUR_API_KEY" \
-F 'image_file=@/path/to/image.jpg' \
-F 'format=webp' \
-o output.webpWhich format should I choose?
- Choose PNG if you need transparency or the safest default for cutouts.
- Choose JPG if you want an opaque image with broad compatibility and smaller files.
- Choose WebP if you want a modern format with smaller files and optional transparency.
How output format interacts with other flags
Output format is closely related to the rest of your request configuration:
- bg_color is especially useful with JPG, because JPG cannot remain transparent.
- channels=rgba is typically used when you want a full image output.
- channels=alpha returns a mask PNG rather than a normal output image.
- despill is most visually useful when working with formats that preserve edge detail, such as PNG or WebP.
Common workflows
Use format=png so the output preserves transparency.
Use format=jpg with bg_color=white.
Use format=webp to reduce file size while preserving transparency.
