HTML Parameter

The html parameter is required for the HTML/CSS API and accepts any valid HTML content.

Specifications

PropertyValue
Typestring
RequiredYes
DefaultNone
APIHTML/CSS API only

Description

The HTML content you want to convert to an image. This can include:

  • Plain HTML
  • Inline CSS
  • Inline JavaScript
  • External resources (images, fonts, etc.)

Examples

Basic HTML

{
    "html": "<h1>Hello World</h1>"
}

Response:

{
    "success": true,
    "credits_remaining": 95,
    "id": "abc123",
    "url": "https://i.html2img.com/abc123.png"
}

HTML with Inline Styles

{
    "html": "<div style='background: #f0f0f0; padding: 20px;'><h1 style='color: blue;'>Styled Content</h1></div>"
}

HTML with External Resources

{
    "html": "<div><img src='https://example.com/image.jpg'><h1>Image with Text</h1></div>"
}

When using external resources, ensure they are publicly accessible. The API needs to be able to download these resources to include them in the final image.