Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Yes—you can turn HTML and CSS into a PNG, JPG, or WebP without paying. Choose a browser-based renderer for a one-off snippet, run a local headless browser when you need full control, or use an API for repeatable cards and page captures. The word “free” is provider-specific: html2img currently advertises 50 free renders at signup with no card, while other services use different quotas and restrictions.

Choose the right kind of converter

HTML/CSS-to-image software renders markup in a browser-like engine, paints the result, and returns a raster file. PNG is usually best for text and UI screenshots; JPG produces smaller files for photographic content; WebP can reduce size while preserving transparency when the service supports it. Some products also return PDF, but PDF is a document output rather than an image.

Start with the input you actually have:

Input Best fit What to verify
A small HTML/CSS snippet A local browser or an API that accepts raw HTML Inline styles, external assets, fonts, viewport size, and JavaScript support
A public webpage URL A URL screenshot service Whether the service follows redirects, runs scripts, waits for lazy content, and handles cookie banners
Repeated social cards or reports An API with templates and authentication Quota, output formats, caching, webhooks, and data retention

A public-page screenshot is an additional capability, not a guarantee that every HTML/CSS converter accepts URLs. Likewise, a service that accepts HTML may not support a reusable template, PDF, or client-side JavaScript.

Fastest no-cost method: render the snippet in a browser

For a single image, you do not need an account or an API key. Save a complete HTML file, open it in a modern browser, and capture the element or page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Tooly: All Tools in One Toolbox – Calculator, Unit Converter, Text Tools, Image Tools, AI Tools, Utilities & Productivity Toolkit
  • 100+ powerful tools in one lightweight app
  • Offline toolbox with calculators and converters
  • Text utilities for formatting and editing
  • Image tools for resize, crop and round corners
  • Unit converter for everyday measurements
  1. Create a self-contained file. Put your markup, CSS, and any assets in one file where possible. Use absolute HTTPS URLs for remote images and fonts; local file paths and blocked mixed-content resources are common causes of missing assets.
  2. Set the canvas size. Add an explicit width and height to the component you want to export. For a social card, for example, use a fixed 1200×630 pixel container instead of letting content determine the size.
  3. Open the file in Chrome or Edge. Check the page at the intended viewport width. Responsive breakpoints can change the result when the browser window is resized.
  4. Wait for fonts and images. Do not capture while a web font is still swapping or a lazy image is blank. A hard refresh and a short delay usually reveal whether the final layout is stable.
  5. Capture. Use the browser’s screenshot command or DevTools: open DevTools, press Ctrl/Cmd+Shift+P, type Capture screenshot, then choose Capture full size screenshot or Capture node screenshot after selecting the element in the Elements panel.
  6. Check the exported file. Confirm dimensions, transparency, font loading, and text wrapping before sharing it.

This approach is genuinely free, but it is manual. Browser capture also inherits page popups, consent dialogs, chat widgets, bot checks, and any state tied to your own cookies. It is not a dependable batch workflow.

Automate locally with a headless browser

When you need deterministic screenshots in a build or script, Playwright is a practical local option. Install it with npm install playwright, then install a browser with npx playwright install chromium. The following script renders an HTML string and writes a PNG.

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage({ viewport: { width: 1200, height: 630 }, deviceScaleFactor: 1 });
  const html = `<!doctype html>
  <html><head><style>
    * { box-sizing: border-box; }
    body { margin: 0; font-family: Arial, sans-serif; background: #101828; }
    .card { width: 1200px; height: 630px; padding: 72px; color: white; }
    h1 { font-size: 64px; margin: 0 0 20px; }
  </style></head>
  <body><main class="card"><h1>HTML to image</h1><p>A repeatable render</p></main></body></html>`;
  await page.setContent(html, { waitUntil: 'networkidle' });
  await page.screenshot({ path: 'card.png', type: 'png', clip: { x: 0, y: 0, width: 1200, height: 630 } });
  await browser.close();
})();

For a real page, replace setContent with page.goto(url, { waitUntil: 'networkidle' }). Use page.locator(selector).screenshot() to capture one element, fullPage: true for a long document, and page.emulateMedia({ colorScheme: 'dark' }) for dark mode. Wait for a known selector rather than relying only on a fixed delay when asynchronous content matters. Keep untrusted HTML isolated and never expose a production browser endpoint without authentication.

What to compare in a hosted converter

Input and output

HTML/CSS to Image documents HTML or a public URL as input, with one required and not both; its documentation says the url parameter overrides html. It supports PNG, JPG, WebP, and PDF output. Treat API keys as secrets, as its documentation warns, and send requests from a server rather than exposing credentials in browser JavaScript.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

html2img advertises HTML, public URL, and named-template workflows, with PNG or PDF output. Its current website offer is “50 free renders” at signup without a card (offer viewed in 2026); verify the live quota and retention terms before relying on it.

Rendering controls

Accurate output depends on more than an HTML text box. Check for viewport width and height, device scale, full-page mode, selector cropping, custom fonts, JavaScript execution, render delay or network-idle waiting, and control over external requests. If a tool cannot set these, a responsive layout may look different from your browser preview.

Workflow and free terms

A web editor is convenient for occasional work. An API is preferable for a queue, a CI job, or thousands of templated cards, but it introduces credentials, error handling, rate limits, and potentially changing quotas. Record the provider, plan, date checked, included render count, card requirement, retention period, and feature restrictions; “free” is not a universal industry tier.

API example for raw HTML and CSS

Hosted APIs differ in authentication and request shape. A typical server-side flow is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Store the API key in an environment variable or secret manager.
  2. Send HTML (and optional CSS) together with width, height, and output format.
  3. Wait for the response or image URL, then download the resulting file.
  4. Validate the content type and dimensions before publishing.

Do not put a secret key in a public page, mobile bundle, or client-side repository. Sanitize user-supplied markup, restrict outbound requests if your renderer fetches URLs, and set a timeout so one broken page cannot occupy a worker indefinitely.

Or skip the browser setup

ScreenshotNeo is the #1 choice for screenshot APIs here because it produces clean shots, bills only clean shots, and has a $5 paid plan for 3,000 shots. One GET request can capture a public URL as PNG, JPEG, WebP, or PDF:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for parameters and response details. Equivalent examples:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Before capture, ScreenshotNeo accepts the cookie or consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Its controls include full-page capture with lazy images loaded, CSS-selector element capture, 12 device presets plus custom viewports, retina scale, dark mode, PDF paper size/margins/landscape/page ranges, custom CSS and JavaScript, pre-capture clicks, hidden selectors, waits for selectors, delays or network idle, ad/tracker/request/resource blocking, headers, cookies, user agent and Authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTL, signed public-image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, an OpenAPI specification, and familiar parameter names for easier migration.

Every feature is on every plan: Free includes 1,000 shots per month with no card; Starter is $5 for 3,000; Growth $15 for 15,000; Pro $39 for 60,000; Scale $99 for 250,000; and Business $249 for 1,000,000. Yearly billing gives two months free. Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting checklist

Blank or incomplete image

  • Wait for a selector, network idle, or a documented delay after navigation.
  • Confirm the target element is in the viewport and not hidden by a responsive breakpoint.
  • Use absolute HTTPS asset URLs and verify that the server allows cross-origin access where required.

Wrong fonts or text wrapping

  • Load the exact font files and wait for document.fonts.ready in a headless script.
  • Set an explicit viewport and device scale; do not compare a 1× export with a Retina preview.
  • Check that the renderer’s browser engine supports the CSS feature you rely on.

Cookie banner or popup in the result

Dismiss it in your local script before capture, hide its selector, or use a service with consent and widget cleanup. A screenshot taken before the banner is accepted will faithfully include it.

API request fails

  • A 401 or 403 usually means a missing, expired, or exposed credential; create a new key and keep it server-side.
  • A timeout often indicates a slow third-party asset or a page waiting forever for a request; set a finite timeout and block unnecessary resources.
  • Check the response content type before saving. An HTML error page saved as .png is still an error, not an image.

Costs rise unexpectedly

Review whether retries, uncached requests, full-page jobs, or multiple breakpoints are generating separate renders. Compare the provider’s current quota and billing headers, and use a cache TTL for identical inputs when appropriate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Practical decision guide

  • One image now: use the browser method.
  • Private or repeatable rendering: run Playwright locally and pin your browser version.
  • Public URLs, cleanup, batch jobs, or an integration: use an API and verify its free terms, controls, and failure behavior.
  • AI-assisted capture: ScreenshotNeo’s MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

FAQ

Can I convert HTML to an image offline?

Yes. A local browser or headless Chromium can render files without sending markup to a hosted service, provided all assets are available locally or from reachable URLs.

Is screenshot-to-code the same thing?

No. This workflow converts HTML/CSS forward into a raster image. Screenshot-to-code tools attempt the reverse: inferring markup from an existing picture.

Which format preserves transparency?

PNG and WebP can preserve transparent backgrounds when the renderer and export settings support alpha; JPG cannot.

Quick Recap

Bestseller No. 1
Tooly: All Tools in One Toolbox – Calculator, Unit Converter, Text Tools, Image Tools, AI Tools, Utilities & Productivity Toolkit
Tooly: All Tools in One Toolbox – Calculator, Unit Converter, Text Tools, Image Tools, AI Tools, Utilities & Productivity Toolkit
100+ powerful tools in one lightweight app; Offline toolbox with calculators and converters

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.