Lossless detail
Keep text, icons, charts, and interface elements crisp without compression artifacts.
HTML to PNG API
Send HTML and CSS to the API and receive a hosted .png image URL. HCTI manages Chromium, rendering, storage, and delivery.
Live demo
Edit the HTML and CSS, choose the image settings, and render a PNG with the same API used in production.
Format advantages
PNG preserves sharp edges, text, and transparency, making it ideal for interface captures and designed graphics.
Keep text, icons, charts, and interface elements crisp without compression artifacts.
Preserve transparent HTML backgrounds for overlays, product graphics, badges, and reusable assets.
Use PNG when exact colors and sharp edges matter more than achieving the smallest possible file.
HTML to image API
Send HTML and CSS to the API with the format set to png. Chromium renders the content and the response URL points to the generated .png image.
Send complete markup and styles, including browser-supported fonts, images, SVG, and JavaScript.
Set format to png and use the hosted .png URL returned by the API.
Set viewport dimensions and device scale, or crop the result to a CSS selector.
Choose light or dark mode, timezone, and screen or print media.
How it works
Submit the content with format set to png and any viewport or browser settings.
The API loads the markup, styles, fonts, and assets in a managed browser environment.
Embed the hosted result, download the file, or save it in your own storage and application records.
Output formats
Keep the same HTML and CSS. Choose lossless detail, compact compatibility, modern web delivery, or a paginated document.
Looking to capture a webpage as PNG? Explore URL to PNGSmaller files and broad compatibility for photography, previews, and content-heavy pages.
Explore JPEGStrong visual quality, transparency, and modern compression for web delivery.
Explore WebPPaginated documents with page sizing, margins, backgrounds, and print styles.
Explore PDFExample code
Choose a language and copy a complete request using this page's simple HTML and CSS example.
const apiId = process.env.HCTI_API_ID;
const apiKey = process.env.HCTI_API_KEY;
if (!apiId || !apiKey) {
throw new Error("Missing HCTI_API_ID or HCTI_API_KEY");
}
const authorization = `Basic ${Buffer.from(`${apiId}:${apiKey}`).toString("base64")}`;
const request = {
html: `<div class="card">
<h1>Hello, world!</h1>
<p>Generated from HTML and CSS.</p>
</div>`,
css: `.card {
width: 480px;
padding: 40px;
background: #f0fdf4;
color: #052e16;
font-family: sans-serif;
}`,
format: "png",
};
const response = await fetch("https://hcti.io/v1/image", {
method: "POST",
headers: {
Authorization: authorization,
"Content-Type": "application/json",
},
body: JSON.stringify(request),
});
if (!response.ok) {
throw new Error(`HCTI request failed: ${response.status} ${await response.text()}`);
}
const result = await response.json() as { url: string };
console.log(result.url);
Ready to render?
Send HTML and CSS to the API and receive a hosted .png image URL without running browser infrastructure.