---
title: "Convert HTML, MD & URL to Image API"
slug: convert-html-md-url-to-image
url: https://apyhub.com/sarvasoft/service/convert-html-md-url-to-image
provider: SARVASOFT OPC PRIVATE LIMITED
categories: [Output Kit, Media Kit]
tags: [screenshot-capture, html-rendering, page-snapshot, url-to-image, markdown-rendering]
auth: api_key
version: 2.0.0
service_type: sync
endpoints: 1
atoms: 8
mcp: true
---

# Convert HTML, MD & URL to Image API

HTML to image API: send HTML, Markdown or a web page URL and get a PNG or JPEG screenshot, full page or viewport, as a file or JSON. Free tier, no card.

## Endpoints

| Method | URL | Description | Atoms |
| --- | --- | --- | --- |
| POST | `https://api.eu.apyhub.com/sarvasoft/convert-html-md-url-to-image` | What it does Renders a web page, raw HTML or Markdown in Chromium and returns a PNG or JPEG screens… | 8 |

## Endpoint reference

### Capture a screenshot image from HTML or URL

`POST https://api.eu.apyhub.com/sarvasoft/convert-html-md-url-to-image` · 8 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `url` | body | string (uri) | no | Public web page to capture. Must be http or https. Provide exactly one of url, html or markdown. Example: `https://example.com`. |
| `html` | body | string | no | Raw HTML to render and capture. Provide exactly one of url, html or markdown. Example: `<h1 style='font-family:Arial'>Hello</h1>`. |
| `width` | body | integer | no | Viewport width in pixels. Default: `1280`. Example: `1280`. |
| `height` | body | integer | no | Viewport height in pixels. Default: `720`. Example: `720`. |
| `cookies` | body | array of object | no | Cookies set in the browser before loading the page. Example: `[{"name":"session","value":"abc123","domain":"example.com"}]`. |
| `scripts` | body | array of string | no | Inline scripts or script URLs to run before capture. Example: `["document.querySelector('.cookie-banner')?.remove()"]`. |
| `timeout` | body | integer | no | Load and capture timeout in milliseconds. Default: `30000`. Example: `30000`. |
| `filename` | body | string | no | Name of the image file. Default: `screenshot.png`. Example: `homepage.png`. |
| `markdown` | body | string | no | Markdown to convert to HTML, render and capture. Provide exactly one of url, html or markdown. Example: `# Release notes

- Faster exports`. |
| `auth_type` | body | string | no | Login used when loading url. One of: none, basic, bearer. Default: `none`. Example: `basic`. |
| `full_page` | body | boolean | no | Capture the full scrollable page, not only the viewport. Default: `false`. Example: `true`. |
| `style_url` | body | string | no | Public URL of a CSS file to load before capture. Example: `https://example.com/capture.css`. |
| `custom_css` | body | string | no | CSS injected into the page before capture. Example: `.cookie-banner { display: none; }`. |
| `script_url` | body | string | no | Public URL of a JavaScript file to load before capture. Example: `https://example.com/setup.js`. |
| `wait_until` | body | string | no | When the page counts as loaded. One of: load, domcontentloaded, networkidle, networkidle0, networkidle2. Default: `networkidle`. Example: `networkidle`. |
| `image_format` | body | string | no | Image format. One of: png, jpeg. Default: `png`. Example: `png`. |
| `extra_headers` | body | object | no | Extra HTTP headers sent when loading url. Example: `{"Accept-Language":"en-GB"}`. |
| `response_mode` | body | string | no | How the image is returned: binary (the file itself), base64, json (base64 plus size and creation time) or url (a temporary download link). One of: binary, base64, json, url. Default: `binary`. Exampl… |
| `auth_credentials` | body | string | no | Login value for auth_type: username:password for basic, the token for bearer. Example: `user:secret`. |
| `wait_for_timeout` | body | integer | no | How long to wait for the selector or function, in milliseconds. Example: `5000`. |
| `wait_for_function` | body | string | no | JavaScript expression to wait for until it is true. Example: `document.fonts.status === 'loaded'`. |
| `wait_for_selector` | body | string | no | CSS selector to wait for before capture. Example: `#hero`. |
| `execute_javascript` | body | boolean | no | Run the page's JavaScript before capture. Default: `true`. Example: `true`. |

#### Quickstart

Capture a screenshot from a URL with the default viewport and return it as JSON.

```bash
curl -X POST "https://api.eu.apyhub.com/sarvasoft/convert-html-md-url-to-image" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "response_mode": "json"
  }'
```

#### What you'll get back

Returns a JSON object. Depending on `response_mode`, the object contains either `filename` and `image_base64`, or `filename`, `size`, `created_at`, and `image_base64`, or `file_url`, `expires_at`, and `expires_in_seconds`.


```json
{
  "filename": "screenshot.png",
  "size": 4893,
  "created_at": "2026-01-15T10:30:00Z",
  "image_base64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/q842iQAAAABJRU5ErkJggg=="
}
```

## About

## What it does
The Convert HTML, MD & URL to Image API turns a web page, raw HTML or Markdown into a PNG or JPEG. Send one of `url`, `html` or `markdown`, and get back a screenshot rendered in Chromium.

Set the viewport with `width` and `height` (defaults `1280` by `720`). Turn on `full_page` to capture the whole scrollable page. Pick `png` or `jpeg` with `image_format`, which defaults to `png`.

For live pages, `wait_until` and `wait_for_selector` hold the capture until content loads. `custom_css` and `scripts` can hide cookie banners or set the page up first. `cookies`, `extra_headers` and `auth_type` reach pages behind a login. `response_mode` returns the image as a file by default. It can also return base64, JSON with size and time, or a temporary download link.

Teams use this HTML to image API to make social cards and link previews from HTML templates. They also capture website screenshots for archives, QA checks and reports. Markdown input turns release notes into shareable images. Because it takes raw markup, this HTML to image API needs no hosted page at all.

After capture, the [Convert PNG to WebP API](https://apyhub.com/apyhub/service/convert-png-to-webp) makes the image lighter for the web. The [Compress Images API](https://apyhub.com/apyhub/service/compress-images) shrinks it further.

AI agents can call it through ApyHub MCP.

## Usage

Base URL: `https://api.eu.apyhub.com` (default region — see
`GET https://apyhub.com/api/public/regions` for the rest).

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/sarvasoft/service/convert-html-md-url-to-image
