Skip to content
Browse all functions

Convert HTML String or URL to an Image

images/html2image

html2image (Convert HTML String or URL to an Image) is a 1001fx API function in the group Images: POST https://api.1001fx.com/images/html2image, 5 credits per item. It works as a ready-made module in Make and n8n or as a plain HTTP call.

5 credits per itemHTTP APIn8nMake

Converts an HTML string or URL to an image. If an HTML string is given. Replacements for the text are processed. It is also possible to use Tailwind in classes.

Try it in the 1001fx app

Run html2image in your browser with your API key – fill the form, click Run and get the answer or the file.

html2image in the 1001fx app: the form with example values
Convert HTML String or URL to an Image in the 1001fx app

Endpoint

POSThttps://api.1001fx.com/images/html2image
Header
X-API-KEY: YOURSECRETAPIKEY How to
Content type
application/json

Parameters

  • htmlstringoptional

    HTML to render as an image. You can use tailwind classes provided in a tw tag in your elements. The following font families are supported: Alegreya, Barlow, Inter, Lato, Montserrat, OpenSans, Oswald, Poppins, PTSans, Raleway, Roboto

    Example:
    <div class='flex flex-1 bg-gray-300 rounded-md'><div class='flex flex-col md:flex-row w-full py-12 px-4 md:items-center justify-between p-8'><h2 class='flex flex-col text-3xl sm:text-4xl font-bold tracking-tight text-gray-900 text-left'><span>Hello {{ name }}</span><span class='text-indigo-600'>Welcome to 1001fx</span></h2><div class='mt-8 flex md:mt-0'><div class='flex rounded-md '><div class='flex items-center justify-center rounded-md border-transparent bg-indigo-600 px-5 py-3 text-base font-medium text-white'>Get started</div></div><div class='ml-3 flex rounded-md '><div class='flex items-center justify-center rounded-md border-transparent bg-white px-5 py-3 text-base font-medium text-indigo-600'>Learn more</div></div></div></div></div>
  • urlstringoptional

    URL to render as an image.

    Example:
    https://1001fx.com
  • fullPagebooleanoptional

    Specifies if the whole page should be saved in the screenshot. Defaults to false.

    Example:
    true
  • outputFormatenumrequired

    The desired output format

    Values:
    png
    jpeg
    Example:
    png
  • widthnumberoptional

    The desired output width.

    Example:
    800
  • heightnumberoptional

    The desired output height.

    Example:
    600
  • replacementsarray<object>optional

    Key Value pairs to replace in your provided html.

    • keystringrequired

      Replacement key to search for in your html. Must be provided in the pattern {{KEY}}.

      Example:
      {{title}}
    • valuestringrequired

      Replacement value to replace in your html.

      Example:
      Keynote Title

Examples

HTML to PNG

Renders an HTML snippet (Tailwind classes work) as an 800×600 PNG.

Input

Expects a background and texts as data array to display
{
  "height": 600,
  "width": 800,
  "outputFormat": "png",
  "html": "<div class='flex flex-1 bg-gray-300 rounded-md'><div class='flex flex-col md:flex-row w-full py-12 px-4 md:items-center justify-between p-8'><h2 class='flex flex-col text-3xl sm:text-4xl font-bold tracking-tight text-gray-900 text-left'><span>Hello {{ name }}</span><span class='text-indigo-600'>Welcome to 1001fx</span></h2><div class='mt-8 flex md:mt-0'><div class='flex rounded-md '><div class='flex items-center justify-center rounded-md border-transparent bg-indigo-600 px-5 py-3 text-base font-medium text-white'>Get started</div></div><div class='ml-3 flex rounded-md '><div class='flex items-center justify-center rounded-md border-transparent bg-white px-5 py-3 text-base font-medium text-indigo-600'>Learn more</div></div></div></div></div>"
}

Output · HTTP 200

Result is a single file.
{
  "statusCode": 200,
  "headers": {
    "content-type": "image/png"
  }
}
Show curl command
curl -X POST 'https://api.1001fx.com/images/html2image' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"height":600,"width":800,"outputFormat":"png","html":"<div class='\''flex flex-1 bg-gray-300 rounded-md'\''><div class='\''flex flex-col md:flex-row w-full py-12 px-4 md:items-center justify-between p-8'\''><h2 class='\''flex flex-col text-3xl sm:text-4xl font-bold tracking-tight text-gray-900 text-left'\''><span>Hello {{ name }}</span><span class='\''text-indigo-600'\''>Welcome to 1001fx</span></h2><div class='\''mt-8 flex md:mt-0'\''><div class='\''flex rounded-md '\''><div class='\''flex items-center justify-center rounded-md border-transparent bg-indigo-600 px-5 py-3 text-base font-medium text-white'\''>Get started</div></div><div class='\''ml-3 flex rounded-md '\''><div class='\''flex items-center justify-center rounded-md border-transparent bg-white px-5 py-3 text-base font-medium text-indigo-600'\''>Learn more</div></div></div></div></div>"}'

HTML with text replacements

Replaces placeholders in the HTML before rendering.

Input

Expects a background and texts as data array to display
{
  "height": 1600,
  "width": 900,
  "outputFormat": "png",
  "html": "<div class=\"relative flex min-h-screen flex-col justify-center overflow-hidden bg-gray-50 bg-[url('https://hellospaces.b-cdn.net/misc/1678876855_card-bg-22-leer.png?updated_at=2023-03-15T10:40:56.625Z')] bg-cover bg-center p0 m9\"><div class=\"grid h-screen grid-cols-3 gap-4 pt-[100px] px-10\"><div class=\"col-span-2 flex flex-col justify-between px-10 bg-g\"><div class=\"p0 bg\"><p class=\"pt-0 pb-10  text-left text-[80px] font-bold leading-none text-[#9a33ff]\">{{This ist the titel of the Talk. It will be replaced by the 1001fx function}}</p></div><div class=\"flex flex-row \"><div class=\"flex justify-center \"><img alt=\"NoCode Rocks Logo\" src=https://hellospaces.b-cdn.net/misc/1678876728_Logo-Square.png?updated_at=2023-03-15T10:38:51.633Z class=\"h-[120px] w-auto max-w-[500px] object-contain\" /></div><div class=\"ml-4 mb-10\"><p class=\"mb-2 text-center text-[50px] leading-none font-bold  text-[#171717]\">NoCode Rocks</p><p class=\"mb-2 text-center text-[25px] leading-none font-bold  text-[#9a33ff]\">https://nocoderocks.com</p><p class=\"mb-2 text-center text-[25px] leading-none font-bold  text-[#171717]\">22. Mai 2023 / online / free</p></div></div></div><div class=\"flex flex-col px-10\"><div class=\"flex flex-shrink-0 justify-center  \"><div class=\"flex flex-shrink-0 justify-center h-80 w-80 \"><img alt=\"\" src=https://hellospaces.b-cdn.net/misc/1678876848_sven.png class=\"h-80 w-80 rounded-full object-cover \" /></div></div><p class=\"mt-10 text-center text-[30px] font-bold leading-none text-[#9a33ff]\">{{Maximillian Mustermann}}</p><p class=\"my-10 text-center text-[25px] font-bold leading-none text-[#171717]\">{{Long Company Name GmbH}}</p><div class=\"flex justify-center \"><img alt=\"\" src=https://hellospaces.b-cdn.net/misc/1667551407_HelloSpacesLogoTextLeftBlack-2-1280x184.png class=\"h-20 w-auto max-w-80 object-contain\" /></div></div></div></div></div>",
  "replacements": [
    {
      "key": "{{Maximillian Mustermann}}",
      "value": "Replaced Text"
    }
  ]
}

Output · HTTP 200

Result is a single file.
{
  "statusCode": 200,
  "headers": {
    "content-type": "image/png"
  }
}
Show curl command
curl -X POST 'https://api.1001fx.com/images/html2image' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"height":1600,"width":900,"outputFormat":"png","html":"<div class=\"relative flex min-h-screen flex-col justify-center overflow-hidden bg-gray-50 bg-[url('\''https://hellospaces.b-cdn.net/misc/1678876855_card-bg-22-leer.png?updated_at=2023-03-15T10:40:56.625Z'\'')] bg-cover bg-center p0 m9\"><div class=\"grid h-screen grid-cols-3 gap-4 pt-[100px] px-10\"><div class=\"col-span-2 flex flex-col justify-between px-10 bg-g\"><div class=\"p0 bg\"><p class=\"pt-0 pb-10  text-left text-[80px] font-bold leading-none text-[#9a33ff]\">{{This ist the titel of the Talk. It will be replaced by the 1001fx function}}</p></div><div class=\"flex flex-row \"><div class=\"flex justify-center \"><img alt=\"NoCode Rocks Logo\" src=https://hellospaces.b-cdn.net/misc/1678876728_Logo-Square.png?updated_at=2023-03-15T10:38:51.633Z class=\"h-[120px] w-auto max-w-[500px] object-contain\" /></div><div class=\"ml-4 mb-10\"><p class=\"mb-2 text-center text-[50px] leading-none font-bold  text-[#171717]\">NoCode Rocks</p><p class=\"mb-2 text-center text-[25px] leading-none font-bold  text-[#9a33ff]\">https://nocoderocks.com</p><p class=\"mb-2 text-center text-[25px] leading-none font-bold  text-[#171717]\">22. Mai 2023 / online / free</p></div></div></div><div class=\"flex flex-col px-10\"><div class=\"flex flex-shrink-0 justify-center  \"><div class=\"flex flex-shrink-0 justify-center h-80 w-80 \"><img alt=\"\" src=https://hellospaces.b-cdn.net/misc/1678876848_sven.png class=\"h-80 w-80 rounded-full object-cover \" /></div></div><p class=\"mt-10 text-center text-[30px] font-bold leading-none text-[#9a33ff]\">{{Maximillian Mustermann}}</p><p class=\"my-10 text-center text-[25px] font-bold leading-none text-[#171717]\">{{Long Company Name GmbH}}</p><div class=\"flex justify-center \"><img alt=\"\" src=https://hellospaces.b-cdn.net/misc/1667551407_HelloSpacesLogoTextLeftBlack-2-1280x184.png class=\"h-20 w-auto max-w-80 object-contain\" /></div></div></div></div></div>","replacements":[{"key":"{{Maximillian Mustermann}}","value":"Replaced Text"}]}'

Use cases

Try html2image now

Run it in your browser or create a free account and get 100 credits every month.

Changelog

  • 1.0.001.03.2023created
Ask 1001fx