How to Take Website Screenshots With C# (.NET)
Use Playwright for .NET to capture a webpage as an image in C#. Set up Chromium, save a viewport or full-page screenshot, and choose the right output options.

Use the Microsoft.Playwright package to open a page in Chromium and save a screenshot with Page.ScreenshotAsync. By default, it captures the visible viewport; set FullPage = true to capture the full scrollable page.
1. Create a Playwright .NET project
Create a console app, add the package, build the project, and install Playwright’s browser binaries:
dotnet new console -n PlaywrightDemo
cd PlaywrightDemo
dotnet add package Microsoft.Playwright
dotnet build
pwsh bin/Debug/netX/playwright.ps1 install
Replace netX with the target-framework directory produced by your build. Playwright’s setup guide recommends updating the global PowerShell tool if the install command fails because PowerShell is unavailable or out of date. See the official Playwright .NET guide.
2. Capture a webpage in C#
Put this in the project’s top-level Program.cs. It opens the page in a headless Chromium browser and saves the visible viewport as a PNG:

using Microsoft.Playwright;
using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
await page.GotoAsync("https://playwright.dev/dotnet");
await page.ScreenshotAsync(new() { Path = "screenshot.png" });
Playwright’s .NET methods are asynchronous, such as GotoAsync and ScreenshotAsync. The default launch is headless. To see the browser window while debugging, launch it with new() { Headless = false }.
3. Choose what to capture
Capture the full page
Set FullPage to true to capture the full scrollable page in one tall image:

await page.ScreenshotAsync(new()
{
Path = "full-page.png",
FullPage = true
});
A full-page image can be tall, so consider how your application will store, display, or process it.
Capture one element
Use a locator’s screenshot method to save just the matching element:
await page.Locator(".header").ScreenshotAsync(new()
{
Path = "header.png"
});
The element needs to be visible. If another element covers it, that can affect the output. For a scrollable container, the capture includes only the content currently scrolled into view.
Keep the image in memory
Call ScreenshotAsync without a path to get image bytes you can pass to storage or image-processing code:
byte[] imageBytes = await page.ScreenshotAsync();
4. Set format and capture options
When you provide a path, Playwright infers the image format from its extension. The Page API supports PNG, JPEG, and WebP. Quality settings apply to JPEG and WebP, not PNG.
| Option | When to use it |
|---|---|
FullPage |
Capture the full scrollable page instead of the visible viewport. |
Type and Quality |
Choose an output format and, for JPEG or WebP, a quality setting. |
Scale |
Choose device scale for high-DPI output or CSS scale for one image pixel per CSS pixel. |
Clip |
Limit the capture to a specified rectangle. |
Mask |
Cover selected page regions, such as dynamic or sensitive content. |
Animations |
Control animations when you need more repeatable captures. |
OmitBackground |
Capture with a transparent background where supported. |
For example, save a WebP image with a chosen quality:
await page.ScreenshotAsync(new()
{
Path = "page.webp",
Type = ScreenshotType.Webp,
Quality = 80
});
Check the Playwright .NET Page API for the available options and defaults. The documented screenshot timeout defaults to 30 seconds and can be overridden. Choose a page-ready condition that fits the site: a screenshot call alone does not establish that every application-specific resource has finished loading.
5. Choose a browser and runtime
Playwright .NET supports Chromium, Firefox, and WebKit. Install the browser binaries your workflow needs, and use the .NET API names in C# code. JavaScript examples for Playwright use different method names and should not be copied directly into a .NET project.
For hosted remote-browser workflows, Microsoft documents Playwright Workspaces with screenshot capture. Its documentation describes the remote MCP server as preview; check its current status and terms before relying on it.
Or skip the browser setup
ScreenshotNeo is a screenshot API and MCP server. Send one GET request with the target URL to receive an image or PDF. This example saves a WebP screenshot of the same Playwright documentation page:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://playwright.dev/dotnet -o shot.webp
See the ScreenshotNeo API docs for request options. Cookie banners are accepted like a visitor, and cookie banners, newsletter popups, and chat widgets are removed before capture; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents using Claude, Cursor, or another MCP client. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.


