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

To generate an Open Graph (OG) image from HTML with HTML/CSS to Image, either send HTML and optional CSS to its image API, or configure an OG Image Config to generate cards from pages on your site. Then put the resulting public, absolute image URL in the page’s server-rendered <head>. A rendered image alone does not create a social preview: crawlers also need to find the right metadata, and both HTML/CSS to Image and the social platform may cache results.

Choose direct rendering or automatic page-based cards

Use the direct API when your application or build process creates the markup and needs an image for a particular request. Use an OG Image Config when you want image URLs mapped to pages across a public site, such as a blog or store. The first gives your application more control over the input; the second is designed to associate a site origin and page paths with generated cards.

Workflow Input and output Best fit
Direct image API POST HTML or a public page URL to https://hcti.io/v1/image; receive an image URL and ID. On-demand renders or application-controlled content.
OG Image Config Map a public site origin to path-based HCTI image URLs. Automated cards for multiple pages on a site.

Generate an image with the direct API

Choose the input

Send either an html value or a fully qualified public url, not both. Use html to render custom markup, with optional CSS in css. Use url to capture an existing public webpage; when supplied, it takes precedence over HTML input. The API documentation lists PNG, JPG, WebP, and PDF output options.

Authenticate and send a request

The endpoint is POST https://hcti.io/v1/image, authenticated with HTTP Basic: your API ID is the username and your API key is the password. Keep both credentials in trusted server-side code. The examples below use HTML input.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
curl -X POST https://hcti.io/v1/image 
  -u "YOUR_API_ID:YOUR_API_KEY" 
  -H "Content-Type: application/json" 
  -d '{"html":"<div class="card"><h1>Hello world</h1></div>","css":".card { width: 1200px; height: 630px; display: grid; place-items: center; background: #f4f6f8; font-family: sans-serif; } h1 { color: #18212f; }"}'

For a public page, send the URL instead:

curl -X POST https://hcti.io/v1/image 
  -u "YOUR_API_ID:YOUR_API_KEY" 
  -H "Content-Type: application/json" 
  -d '{"url":"https://example.com/article"}'

Use the returned image URL as the value of the page’s image metadata. Check the response for the image URL and ID before adding it to your page. See the HTML/CSS to Image API documentation for the current request and response details.

Python example

import requests

response = requests.post(
    "https://hcti.io/v1/image",
    auth=("YOUR_API_ID", "YOUR_API_KEY"),
    json={
        "html": '<div class="card"><h1>Hello world</h1></div>',
        "css": ".card { width: 1200px; height: 630px; display: grid; place-items: center; background: #f4f6f8; font-family: sans-serif; } h1 { color: #18212f; }",
    },
    timeout=60,
)
response.raise_for_status()
result = response.json()
print(result)

Node.js example

This example uses Node.js’s built-in fetch and Basic authentication. Keep the credentials in environment variables rather than in browser code.

const apiId = process.env.HCTI_API_ID;
const apiKey = process.env.HCTI_API_KEY;
if (!apiId || !apiKey) throw new Error('Set HCTI_API_ID and HCTI_API_KEY');

const auth = Buffer.from(`${apiId}:${apiKey}`).toString('base64');
const res = await fetch('https://hcti.io/v1/image', {
  method: 'POST',
  headers: {
    Authorization: `Basic ${auth}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    html: '<div class="card"><h1>Hello world</h1></div>',
    css: '.card { width: 1200px; height: 630px; display: grid; place-items: center; background: #f4f6f8; font-family: sans-serif; } h1 { color: #18212f; }',
  }),
});
if (!res.ok) throw new Error(`HCTI request failed: ${res.status} ${await res.text()}`);
const result = await res.json();
console.log(result);

Set up automatic cards with an OG Image Config

Map your public pages

An OG Image Config associates a public site origin you own or administer with an HCTI image URL. HCTI uses the path in that image URL to request the corresponding page, read its metadata, and screenshot the page or render a configured template. Page metadata can supply values such as a title, description, Open Graph fields, or explicit template variables.

  1. Configure the site’s public HTTPS origin in the OG Image Config.
  2. Use the configured domain ID in the HCTI image URL and give each page a distinct path, for example https://hcti.io/v1/og/DOMAIN_ID/articles/my-post.
  3. Put that absolute URL in the page’s server-rendered metadata, including og:image and twitter:image.
  4. Publish and verify the resulting page source and image URL.

Replace DOMAIN_ID with the ID supplied by your configuration. The path identifies the page; query strings are ignored for this mapping. Use unique paths for distinct pages.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
<head>
  <meta property="og:image" content="https://hcti.io/v1/og/DOMAIN_ID/articles/my-post">
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:image" content="https://hcti.io/v1/og/DOMAIN_ID/articles/my-post">
</head>

These tags need to be in the HTML returned by your server. Do not rely on JavaScript that inserts them only after the page loads: social crawlers may not read that change. If a theme or SEO plugin already emits image metadata, update its value or use its supported filter instead of adding competing tags. Follow the OG Image Config guide for configuration details.

Choose how images adapt to platforms

The config guide describes three approaches: use one image everywhere, render once and adapt to platform bounds, or create separate renders for recognized viewports. A single image is simplest. Adapting one render avoids stretching but may leave unused space. Separate renders can fit responsive designs more closely but use multiple renders.

HTML/CSS to Image recommends 1200 × 630 pixels as a broad fallback. Its current social-card guide lists these platform-specific recommendations; they are the service’s guidance, not a guarantee of an immutable platform standard.

Platform Recommended dimensions
Twitter 1200 × 600
Facebook 1200 × 630
LinkedIn 1200 × 627
Slack 1200 × 630

For HTML snippet rendering, output is automatically cropped to the outermost HTML element and rendered at 2× by default. That means a CSS width of 400 pixels can produce an 800-pixel-wide output. If the returned dimensions seem larger than expected, distinguish the CSS layout dimensions from the final pixel dimensions. See the dimensions guidance.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Publish metadata crawlers can read

For a useful preview, the page itself must expose the intended absolute image URL in its server-rendered <head>. The official setup example uses og:image, twitter:card set to summary_large_image, and twitter:image. Confirm there is one authoritative image value rather than conflicting tags from your application, theme, or SEO plugin.

  1. Publish the page, then use View Source to confirm its final <head> contains the intended og:image and twitter:image.
  2. Open the HCTI image URL directly and confirm that it returns an image.
  3. Use HTML/CSS to Image’s Social Card Previewer to inspect metadata and platform-specific shapes.
  4. If the image is current at HCTI but stale in a social app, inspect that platform’s preview cache separately.

Protect credentials and public image URLs

Keep API credentials server-side

HTML/CSS to Image’s API documentation says, “Treat your API Key like a password.” Do not expose the API ID or key in client-side JavaScript or public source. The direct API flow uses HTTP Basic authentication, so make the request from trusted server-side code.

Use signed URLs only for suitable public inputs

A signed URL can be embedded publicly, but its HMAC SHA256 signature must be created on your server with the secret API key. Anyone holding that URL can request the image it authorizes, so only sign inputs and permissions appropriate for public access. An OG Image Config may be more suitable when public pages and their metadata fit the origin-and-path mapping; use direct API rendering or a signed URL when the application needs arbitrary values at request time. See the signed URL guide.

Why a social preview can still show an old image

There are three separate caches to consider: source-page metadata, the rendered HCTI image, and the social platform’s own preview. A fresh image at one layer does not force the next layer to refresh immediately.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Check the HCTI refresh cycle

The current OG Image documentation specifies a 24-hour default refresh interval for a config, with plan-dependent minimums. Source-page Cache-Control freshness headers or Expires can extend the next metadata check. On the first request after metadata has gone stale, HCTI may return the existing image while a background refresh runs; a subsequent request can reflect updated inputs. Consult the caching guide and dashboard guidance for the applicable refresh controls.

Change content at the same path

Adding a random query parameter to an OG Config image URL does not bust HCTI’s cache. If the pixels changed but the extracted metadata did not, the guide documents hcti:content_version as a monotonically increasing integer. Increment it when you need a new image identity for changed content at the same path.

Refresh the destination platform

Once the image URL serves the current image, use the destination platform’s rescrape or inspection tool if one is available. The platform may retain its own cached preview independently of HCTI.

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

Common problems and fixes

Symptom Likely cause What to check or do
The API request is unauthorized. The API ID or key is wrong, missing, or not sent as HTTP Basic credentials. Verify the credentials server-side and confirm the API ID is the username and API key the password.
The request renders unexpected input. Both html and url were sent; the URL takes precedence. Send exactly one input: custom HTML, or a fully qualified public URL.
The image URL works, but no preview appears. The page’s tags may be absent from server-rendered HTML, malformed, or overridden by another SEO source. Inspect View Source, confirm one absolute og:image and matching twitter:image, and open the image URL directly.
The image looks cropped or has unexpected dimensions. HTML snippet output is cropped to its outermost element and rendered at 2× by default. Check the outer element’s bounds and compare CSS dimensions with returned pixel dimensions.
The social app shows an earlier card. HCTI or the destination platform may still have cached metadata or pixels. Check source cache headers and the HCTI refresh interval, then use the platform’s rescrape tool if available. Do not rely on a query string to invalidate an OG Config image.

Performance, reliability, and cost considerations

  • Allow for multiple cache layers. Automatic configs can reuse rendered images while metadata refreshes; source cache headers can lengthen that interval, and social apps have independent caches.
  • Plan for the correct render shape. A single broadly sized card is simpler; adapting or separate platform renders can better fit different bounds, with the latter using multiple renders.
  • Protect availability of the source page. A URL-based render or path-mapped config depends on the relevant public page being accessible to the service when it requests it.
  • Keep cost claims in context. The cited documentation describes the workflows and caching behavior but does not establish a price for this article’s examples. Check HTML/CSS to Image’s current pricing and plan terms before estimating recurring usage.

Or skip the browser setup

If you only need a screenshot of an existing public page, ScreenshotNeo provides a one-call screenshot API. For the HTML-to-OG workflow above, HTML/CSS to Image accepts HTML templates directly; ScreenshotNeo’s API takes a URL. Use it when capturing a rendered page is the better fit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Its clean-shot steps accept cookie and consent banners like a visitor and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses include X-Page-Verdict and X-Billed headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

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 request options. Sign up free for 1,000 screenshots a month, with no card required.

Frequently asked questions

Can I render HTML without hosting it on a public site?

Yes. The direct API accepts HTML as input, so you can submit custom markup and optional CSS without first publishing that markup as a webpage.

Can I use one generated image for every social platform?

Yes. The OG Image Config guide supports using one image everywhere; its broad fallback recommendation is 1200 × 630 pixels. Platform-specific shapes are available if you need them.

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

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.