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.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To convert HTML into a PNG or another image from Bash, launch a browser or HTML renderer from a shell command. For modern pages and repeatable captures, Playwright is the most flexible option: Bash runs a small Node.js script, and Playwright renders the page and saves the screenshot. For a one-off URL, Chrome Headless can do it with one command; for a local HTML file, wkhtmltoimage offers a direct input-to-output command.

What Bash does—and what renders the page

Bash does not interpret HTML or draw pixels. It orchestrates a rendering program, which loads a URL or local file, lays out the page, and writes an image. The output can vary with the renderer and its version, installed fonts, browser binaries, network access, and the page’s own JavaScript and loading behavior.

Choose the method based on the job: Playwright when you need repeatable browser automation or control over full-page capture; Chrome Headless for a short URL screenshot command; and wkhtmltoimage for a simple local-file conversion, after checking that its rendering suits your page.

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

Use Playwright for a repeatable capture

Playwright’s browser API can navigate to a page and save a screenshot. Its screenshot options include full-page capture, image format, quality, and scale. The script below is illustrative and has not been independently tested; adapt its wait condition and error handling for your page and environment.

Install the project dependency and browser

In a project with Node.js available, install Playwright and the browser appropriate to the environment. Playwright documents browser installation commands, including installing Chromium and its operating-system dependencies. Follow its installation guide for the exact commands and requirements for your platform: Playwright browser installation.

Install the package in the project using your package manager, for example:

npm install playwright

Then install Chromium using the command documented for your Playwright version and operating system. A browser installation is required before the script can launch Chromium.

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

Create the capture script

Save this as capture.cjs:

const { chromium } = require('playwright');

(async () => {
  const url = process.argv[2];
  const output = process.argv[3] || 'page.png';

  if (!url) {
    console.error('Usage: node capture.cjs <url> [output-file]');
    process.exitCode = 2;
    return;
  }

  const browser = await chromium.launch();
  try {
    const page = await browser.newPage({
      viewport: { width: 1280, height: 900 }
    });
    await page.goto(url, { waitUntil: 'networkidle' });
    await page.screenshot({ path: output, fullPage: true });
    console.log(`Saved ${output}`);
  } finally {
    await browser.close();
  }
})().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

The finally block closes the browser even if navigation or screenshot capture fails. The explicit argument check prevents an empty URL from being passed to the browser.

Run it from Bash

node capture.cjs 'https://example.com' 'page.png'

Replace the URL and output filename with your own. The example requests a full-page PNG, rather than only the visible viewport. Playwright’s documented API describes the path and fullPage screenshot options, along with image settings: Playwright screenshots.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Adjust the wait and image settings

networkidle waits for network activity to settle, but it can be unsuitable for pages that keep requests open, such as live dashboards or sites with persistent connections. In those cases, use a page-specific readiness signal—for example, wait for a known element—or a deliberate delay when you know how long the page needs. A fixed delay is simple but can be too short on slow runs and unnecessarily long on fast ones.

For a viewport-only screenshot, omit fullPage: true. If you need a different format or image quality, use the documented screenshot options; quality applies to supported lossy formats. The requested output path’s extension and screenshot type should agree. For very tall pages, consider whether a full-page image is useful: it can be much larger than a viewport capture.

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

Use Playwright’s CLI for a command-oriented workflow

If you prefer a CLI over maintaining a custom script, Playwright documents screenshot commands with an output path, image type, full-page capture, and high-resolution capture. See the current command syntax and options in the Playwright CLI documentation. This route still depends on Playwright and a suitable browser installation, but can be convenient for interactive or command-driven use.

Use Chrome Headless for a one-off URL

When Chrome is already installed and you only need a quick URL screenshot, its headless command-line mode is shorter than a browser-automation script:

chrome --headless --screenshot --window-size=1280,900 https://example.com

Chrome documents that --screenshot saves screenshot.png in the current working directory. The --window-size flag sets the capture window size in the documented usage. Check the Chrome Headless documentation for the current reference and command context. The command captures a URL; it is not the same as a configurable full-page Playwright script.

Chrome’s --dump-dom is not a way to retrieve the original response source: Chrome parses the HTML, runs scripts that can modify the DOM, then serializes that DOM. This distinction can help when investigating why the rendered result differs from the original markup.

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

Convert a local HTML file with wkhtmltoimage

For a direct local-file-to-image command, the documented input/output form is:

wkhtmltoimage input.html output.png

The tool describes itself as converting an HTML page into an image; see the wkhtmltoimage manual. The documentation available here does not establish how well a particular installed version handles current JavaScript-heavy layouts, so inspect the result on the actual page before relying on it for production captures. Local pages that depend on remote assets also need the relevant files and network access to be available to the renderer.

Choose a method by capture requirements

Method Best fit What to account for
Playwright API Repeated browser captures, full-page screenshots, and script-level control Node.js, Playwright, and a browser installation appropriate to the environment
Playwright CLI Command-oriented or interactive screenshot workflows Playwright and browser setup; consult its CLI docs for current flags
Chrome Headless A concise screenshot of a URL Chrome availability; the documented screenshot command writes screenshot.png in the current directory
wkhtmltoimage A direct local HTML input to image output command Verify rendering against the target page and installed version; current compatibility for a given site is not established here

Before choosing, decide whether the input is a URL or local file, whether you need the viewport or the full page, how much JavaScript the page requires, which image format and dimensions you need, and whether your machine or build environment can install browser binaries and operating-system dependencies.

Or skip the browser setup

For an API-based capture, ScreenshotNeo returns an image or PDF from one GET request. This cURL example saves a WebP capture of the target URL:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Replace YOUR_API_KEY with your key and change the URL as needed. See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and the Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month with no card.

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

Troubleshoot common capture problems

The Playwright script cannot find a browser

The Playwright package and browser binaries are separate setup requirements. Install the browser that matches the Playwright setup in your environment, following the browser installation instructions, including operating-system dependencies where required.

The page hangs while waiting for network idle

A page that maintains network activity may never satisfy networkidle. Replace that wait with a known selector or another page-specific readiness condition. If you use a delay, choose it based on the page’s behavior rather than assuming one duration works everywhere.

The image is blank or missing content

Check whether navigation completed, whether the page needs time or user interaction to render, and whether its assets can be reached from the capture environment. For a local file, verify paths to images, fonts, and stylesheets. For an automated browser, confirm the page has reached a meaningful readiness condition before capturing.

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

The output has the wrong size or captures only part of the page

The Playwright example sets a 1280 by 900 viewport and requests fullPage: true. Change the viewport dimensions for a different layout, or remove the full-page option to capture only the viewport. With Chrome Headless, the documented --window-size flag sets the window dimensions.

The output differs from the HTML source

A screenshot shows rendered output, not raw source text. Scripts can change the document before capture; Chrome’s --dump-dom likewise serializes the DOM after parsing and script execution rather than returning the original HTML response. Compare the rendered DOM and the original file or response separately when diagnosing a mismatch.

Performance, reliability, and safe use

Each self-hosted capture depends on launching or reusing a renderer, loading the page and its resources, waiting for the chosen readiness condition, and writing the output. Repeated jobs benefit from a controlled environment with the required browser binaries and fonts installed, and from choosing a wait condition that does not stall on persistent network activity. The available documentation does not establish comparative speed or fidelity among these methods, so validate the chosen renderer on the pages and environment that matter to your job.

Captures can contain account details or other sensitive page content. Avoid writing authenticated screenshots to shared build artifacts or publicly accessible storage unless you have considered access controls and retention. Treat pages and URLs supplied by untrusted users cautiously; the documentation cited here does not provide a security deployment recipe for untrusted-page capture.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Frequently Asked Questions

Does Bash itself convert HTML to PNG?

No. Bash launches a browser or converter that renders the HTML and writes the image.

Can I use Playwright for a full-page screenshot?

Yes. Its screenshot API documents a full-page option; the example in this article uses it.

Does Chrome Headless save the screenshot in the current directory?

Chrome’s documented –screenshot behavior saves screenshot.png in the current working directory.

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.

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