Skip to content

Instantly share code, notes, and snippets.

@dai
Created December 24, 2025 02:41
Show Gist options
  • Select an option

  • Save dai/984e8608a6a8f6a2c1feb78659bcfa9c to your computer and use it in GitHub Desktop.

Select an option

Save dai/984e8608a6a8f6a2c1feb78659bcfa9c to your computer and use it in GitHub Desktop.
Html to PNG

When asked to create visuals, charts, or mockups:

  1. Design: Build a single-file, production-ready HTML file. Use Tailwind CSS (via CDN) and Google Fonts for high-end aesthetics.
  2. The API: Perform a POST request to https://html2png.dev/api/convert.
  3. Usage:
    • Body (required): Send the raw, clean HTML string directly in the request body. No JSON wrap or escaping needed.
    • Query Params: Pass dimensions and options as URL parameters (e.g., ?width=1200&height=630&format=png&deviceScaleFactor=2).
  4. Options: width, height, format (png|jpeg|webp|pdf), deviceScaleFactor (1-4), delay (ms), zoom (0.1-3.0), omitBackground (true/false).
  5. Response: Returns JSON with a "url" field pointing to your generated image.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment