Render HTML to Image via API
SnapAPI renders web pages to screenshots using a full Chromium browser, capturing any URL with complete CSS, JavaScript, and web font rendering. The screenshot endpoint accepts a URL parameter pointing to any publicly accessible web page, renders it in Chromium, and returns the screenshot as a PNG or JPEG image. For developers who need to render HTML that is not hosted at a public URL — locally generated HTML, template-rendered HTML, or HTML built at request time — host the HTML content on a temporary URL or your own internal endpoint and pass that URL to the SnapAPI screenshot endpoint. SnapAPI renders the HTML by loading the URL in Chromium just as a browser would, executing any JavaScript in the HTML, applying all CSS including external stylesheets and web fonts, and capturing the rendered visual output. This approach produces accurate screenshots of HTML content that includes modern CSS features, JavaScript-rendered dynamic content, and external resources like images and fonts loaded from CDN URLs.
HTML to Image Use Cases
Dynamic image generation renders HTML templates to images for use in email campaigns, social media posts, certificates, and badges. Marketing teams create personalized email banner images by rendering an HTML template with user-specific data such as the user name and progress metric, capturing the rendered HTML as a JPEG, and including the image in the email as a personalized visual element. Certificate generation renders HTML certificate templates with the recipient name and completion date as a full-page PNG or PDF for download after completing a course or certification program. Social media card generation renders an HTML card template for each piece of content and captures it as an image for use as the og:image or Twitter card image, providing branded visual previews for all shared links without manual design work. Report generation renders HTML report templates with dynamic data from a database into PDF documents for automated report distribution, combining the flexibility of HTML layout with the portability of PDF output.
HTML Screenshot API JavaScript Support
SnapAPI executes JavaScript in the rendered page before capturing the screenshot, ensuring that JavaScript-rendered content is present in the output. Single-page applications built with React, Vue, Angular, and Svelte render their initial content via JavaScript after the page load event, and SnapAPI waits for JavaScript execution to complete before capturing the screenshot so the rendered output reflects the fully initialized component state. For HTML pages that rely on JavaScript animations, data fetching, or timers to render their final visual state, use the delay parameter to specify how many milliseconds to wait after the page load event before capturing, giving JavaScript-triggered rendering processes time to complete before the screenshot is taken. Set the delay to one thousand milliseconds for most JavaScript-animated templates and increase it to two or three thousand for templates that include data fetch calls that must complete before the content is visible in the rendered output. Test the appropriate delay value by experimenting with different delay settings and inspecting the resulting screenshots to confirm that all content is visible and correctly rendered before finalizing the integration configuration.
HTML to PDF via Screenshot API
For HTML-to-PDF conversion, use the SnapAPI PDF endpoint instead of the screenshot endpoint. The PDF endpoint renders the target URL in Chromium using the print rendering mode and returns a multi-page PDF document rather than a single image. The print rendering mode uses the CSS print media stylesheet if one is defined, applies the configured paper dimensions and margins, and generates a multi-page PDF that flows the page content across pages according to the page break rules in the CSS. The PDF endpoint parameters include format for paper size, margin settings in millimeters, landscape orientation toggle, and print_background for preserving background colors in the PDF output. Use the PDF endpoint for documents intended for printing, downloading, or archiving, and use the screenshot endpoint for images intended for display in web interfaces, email, or social media where a single-image output is more appropriate than a multi-page document.
Get Started with HTML Screenshot API
Register at snapapi.pics/register for a free API key with two hundred requests per month. No credit card required. Host your HTML content at any accessible URL and pass it to the SnapAPI screenshot or PDF endpoint. Full documentation at snapapi.pics/docs with code examples in JavaScript, Python, Go, PHP, Swift, and Kotlin covers both the screenshot and PDF endpoints for HTML rendering use cases.