Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Use a browser renderer when your HTML depends on modern CSS or JavaScript; use an in-process renderer when you need a self-contained .NET component. In practice, C# HTML-to-image conversion has three deployment models: a hosted Chrome-style API (such as HtmlCssToImage or PDFCrowd), local headless Chromium (CoreHtmlToImage), and an in-process .NET engine (Aspose.HTML). The examples below show how to render HTML strings and URLs to PNG, JPEG, or WebP, and how to choose among them without relying on an unverified speed or fidelity ranking.
Choose the rendering model first
| Option | How it renders | Inputs and outputs | Best fit | Trade-off |
|---|---|---|---|---|
| ScreenshotNeo | Hosted browser screenshot API | URLs; PNG, JPEG, WebP or PDF | Clean production captures without operating a browser | External service and API key |
| HtmlCssToImage (HCTI) | Hosted Chrome-like renderer | HTML/CSS, URLs and templates; PNG, JPG, WebP (and documented PDF path) | Chrome fidelity without local Chromium administration | Credentials and service dependency |
| CoreHtmlToImage | Local headless Chromium through PuppeteerSharp | HTML strings or URLs; JPG, PNG, WebP | Self-hosted, cross-platform services | First use downloads about 200 MB of Chromium; browser resources are yours to manage |
| Aspose.HTML for .NET | In-process renderer with ImageDevice/Converter | Local HTML; JPG, PNG, BMP, GIF and TIFF | Explicit DPI, background and antialiasing controls | Commercial licensing and engine behavior require evaluation |
| PDFCrowd | Hosted .NET API/client | URLs, local files or raw HTML; image conversion | Managed conversion with a .NET client | External service and credentials |
No neutral source establishes a cross-product speed or pixel-fidelity winner. Render your own representative pages before committing, especially pages using web fonts, asynchronous JavaScript, lazy images, transparency or very tall layouts.
Hosted Chrome-style conversion with HCTI
HCTI documents Chrome-like rendering and accepts HTML/CSS or a URL. Its .NET flow is to install the HtmlCssToImage NuGet package, create an HtmlCssToImageClient with your user ID and API key, then submit either an HTML/CSS request or a URL request. URL capture supports full-scroll pages.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Render an HTML string
using HtmlCssToImage;
var client = new HtmlCssToImageClient(
userId: Environment.GetEnvironmentVariable("HCTI_USER_ID")!,
apiKey: Environment.GetEnvironmentVariable("HCTI_API_KEY")!);
var html = """
<!doctype html>
<html><head>
<style>body{font-family:Arial;background:#f4f6f8;padding:32px}h1{color:#17324d}</style>
</head><body><h1>Invoice preview</h1><p>Rendered by C#.</p></body></html>
""";
var request = new CreateHtmlCssImageRequest
{
Html = html,
Css = "",
ImageFormat = "png"
};
var result = await client.CreateHtmlCssImageAsync(request);
await File.WriteAllBytesAsync("invoice.png", result.ImageBytes);
Capture a webpage
var request = new CreateUrlImageRequest
{
Url = "https://example.com",
ImageFormat = "webp",
FullPage = true
};
var result = await client.CreateUrlImageAsync(request);
await File.WriteAllBytesAsync("page.webp", result.ImageBytes);
The exact request-property names can vary by package release, so check the installed package’s IntelliSense and current vendor documentation when upgrading. HCTI also lists dependency-injection, Blazor, and Razor/MVC TagHelper packages.
#1 Best Overall
Self-hosted Chromium with CoreHtmlToImage
CoreHtmlToImage is a cross-platform .NET library that converts HTML strings or URLs to image bytes using PuppeteerSharp. Version 2.0.0 was listed as updated April 1, 2026. On first use, PuppeteerSharp downloads a compatible Chromium binary of about 200 MB. In containers, give the process writable browser-cache storage and enough shared memory.
dotnet add package CoreHtmlToImage
using CoreHtmlToImage;
var converter = new HtmlConverter();
byte[] fromHtml = await converter.FromHtmlStringAsync(
"<html><body><h1>Hello</h1></body></html>",
new HtmlToImageOptions { Width = 1200, Height = 630, Format = ImageFormat.Png });
await File.WriteAllBytesAsync("card.png", fromHtml);
byte[] fromUrl = await converter.FromUrlAsync(
"https://example.com",
new HtmlToImageOptions { Width = 1440, Format = ImageFormat.WebP });
await File.WriteAllBytesAsync("site.webp", fromUrl);
Keep a converter/browser lifecycle strategy instead of launching an unrestricted browser per request. Limit concurrent jobs, set request timeouts, and validate untrusted URLs to prevent your service from becoming an SSRF proxy. External fonts, scripts and images must be reachable from the rendering environment.
Rank #2
In-process rendering with Aspose.HTML for .NET
Aspose exposes HTMLDocument, ImageRenderingOptions/ImageSaveOptions, ImageDevice, and Converter.ConvertHTML. The API includes output format, horizontal and vertical resolution, background color and antialiasing controls.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
using Aspose.Html;
using Aspose.Html.Rendering;
using Aspose.Html.Rendering.Image;
using Aspose.Html.Saving;
using var document = new HTMLDocument("<html><body><h1>Report</h1></body></html>");
var options = new ImageRenderingOptions
{
Format = ImageFormat.Png,
BackgroundColor = System.Drawing.Color.White,
HorizontalResolution = 144,
VerticalResolution = 144,
UseAntialiasing = true
};
using var device = new ImageDevice(options, "report.png");
Aspose.Html.Converters.Converter.ConvertHTML(document, device);
Use this model when avoiding a browser process and controlling raster settings matters. Confirm the license terms and test CSS/JavaScript features your pages actually use; “in-process” does not guarantee browser-equivalent behavior.
PDFCrowd’s hosted .NET client
PDFCrowd provides a downloadable or NuGet .NET client. Its documented image API accepts a URL, local HTML file, or raw HTML string and sends the conversion to the hosted service. This is useful when you want a managed renderer but do not want to maintain Chromium. Store credentials outside source control and treat network failure, authentication errors and service limits as retryable or user-visible states according to your application.
Build a reliable conversion pipeline
Prepare deterministic HTML
- Use absolute URLs for images, stylesheets and fonts, or inline critical assets.
- Set an explicit viewport width and a deliberate output format. PNG preserves sharp text and transparency; JPEG is smaller for photographs but loses alpha; WebP often provides a smaller modern image.
- Wait for data and fonts before capture. A page that is visually complete in a human browser may still be blank when captured immediately.
- For long pages, define whether “full page” means the document’s full scroll height or a fixed social-card size.
Control security and resource use
- Do not pass arbitrary user URLs to a server-side browser without an allowlist, private-network blocking and response-size limits.
- Cap image dimensions and concurrent renders. Very tall pages can exhaust memory even when the HTML is small.
- Cache identical inputs when acceptable, and include HTML, CSS, viewport, fonts and option values in the cache key.
- Log renderer, format, viewport, elapsed time, output bytes and failure reason; never log API secrets or sensitive HTML.
Compare before selecting
Create a fixture set containing web fonts, SVG, CSS grid, animations, lazy-loaded images, right-to-left text, transparent backgrounds and a multi-screen page. Compare exact dimensions, font substitution, image loading, JavaScript timing, full-page height and compression at your target deployment OS. There is no published neutral benchmark that can replace this test.
Rank #4
Common failures and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Blank or partially rendered image | Capture occurred before scripts, fonts or images completed | Add an explicit readiness condition or delay; inline critical assets and wait for network idle where supported. |
| Missing images or fonts | Relative URLs, blocked egress or authentication | Use absolute URLs, permit the renderer’s outbound access, or provide required headers/cookies. |
| Chromium launch error | CoreHtmlToImage binary was not downloaded, cache is unwritable, or container libraries are missing | Warm the browser during deployment, persist its cache, install required OS dependencies and verify the runtime user can execute Chromium. |
| Wrong dimensions | Viewport and device scale were left implicit | Set width/height explicitly and test device-pixel scaling separately from CSS pixels. |
| Text differs between machines | Font unavailable or substituted | Install/package the exact font, wait for document.fonts.ready, and compare on the production image. |
| Timeouts or memory spikes | Unbounded page height, heavy assets or too much concurrency | Set navigation and total-job timeouts, cap dimensions, block unnecessary resources and limit parallel jobs. |
| Authentication or quota error | Invalid hosted-service credentials or exhausted allowance | Check environment variables, response status and account quota; retry only transient failures. |
Or skip the browser setup
ScreenshotNeo is a hosted screenshot API and MCP server. It accepts a URL and returns PNG, JPEG, WebP or PDF. Before capture it accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be disabled. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteIt also supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets or custom viewports, retina scale, PDF paper/margins/landscape/page ranges, custom CSS and JavaScript, clicks, selector or network-idle waits, request/resource blocking, headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, chosen-TTL caching, signed image links, asynchronous signed webhooks, bulk capture of 100 URLs per call, a usage API and an OpenAPI specification. Existing parameter names used by other screenshot APIs also work.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
require('fs').writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));
See the ScreenshotNeo API documentation for options and headers. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. An MCP server lets Claude, Cursor and other MCP clients call take_screenshot, get_page_info and capture_pdf. Create a free ScreenshotNeo account to try it.
Best Value
Frequently Asked Questions
Can I convert an HTML string without hosting it first?
Yes. HCTI, CoreHtmlToImage and PDFCrowd document raw HTML-string input; Aspose loads an HTML document directly.
Which format should a generated image use?
Choose PNG for lossless text or transparency, JPEG for photographic content without alpha, and WebP when your consumers support it and smaller files are useful.
Does a .NET HTML renderer behave exactly like Chrome?
Only browser-backed options target Chrome-style behavior. In-process engines can differ in CSS, JavaScript, fonts and layout, so test your own pages.
Quick Recap
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.

