Create images with transparent backgrounds for logos, overlays, and more
Simplified method (recommended)
Section titled “Simplified method (recommended)”We’ve simplified transparent backgrounds. You can now set transparent_background to true directly on the create image request:
{ "html": "<div class='content'>Your content here</div>", "transparent_background": true}The parameter works with both HTML/CSS and URL-based images. For a URL screenshot, replace html with url.
Implementation
Section titled “Implementation”To render an image with a transparent background, pass the CSS via the css parameter:
{ "html": "<div class='content'>Your content here</div>", "css": "body { background-color: transparent; }"}Examples
Section titled “Examples”Basic Example
Section titled “Basic Example”This image demonstrates a transparent background:

Code Example
Section titled “Code Example”<div class="logo-container"> <img src="logo.png" alt="Company Logo"></div>body { background-color: transparent;}.logo-container { padding: 20px; /* Any background styling here will be included in the image */}Common Use Cases
Section titled “Common Use Cases”- Logos: Create logo variations with transparent backgrounds
- Overlays: Generate images that layer well with other content
- Icons: Design icons that work on any background
- Watermarks: Create watermarks that blend seamlessly
Best Practices
Section titled “Best Practices”- Always use PNG format for transparent backgrounds
- Test your image on different colored backgrounds
- Consider adding a subtle shadow for better visibility
- Use the
device_scaleparameter for higher quality
Don’ts
Section titled “Don’ts”- Don’t use JPG format when transparency is needed
- Don’t assume white is transparent
- Don’t forget to set
background-color: transparent
URL-based Screenshots
Section titled “URL-based Screenshots”When capturing screenshots from URLs, add the CSS via the API parameters:
{ "url": "https://example.com", "css": "body { background-color: transparent; }"}Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”-
White Background Appears
- Ensure you’re using PNG format
- Verify CSS is being applied
- Check you are passing CSS using the
cssparameter
-
Partial Transparency
- Look for background colors in child elements
- Check for overlapping elements
- Verify CSS inheritance
Example Fix
Section titled “Example Fix”/* Send this CSS in the request's css parameter. */body { background-color: transparent; }Browser Compatibility
Section titled “Browser Compatibility”Transparent PNGs are supported in all modern browsers:
- Chrome
- Firefox
- Safari
- Edge
- Opera
- Mobile browsers
Need help?
Talk to a human. Email support@htmlcsstoimage.com and we’ll help you get started.