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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Use Puppeteer’s page.screenshot() method with type: 'jpeg' to capture an HTML page as a JPEG. Set path to a .jpg filename to save it, and add quality (0–100) if you want to control compression. For a full-page image, set fullPage: true.

Generate a JPEG screenshot with Puppeteer

Install Puppeteer in your Node.js project, then launch a browser, navigate to the page, and call page.screenshot(). The following is an illustrative combination of the documented options; the official guide’s example uses PNG rather than JPEG. See the Puppeteer screenshots guide and the ScreenshotOptions reference.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'networkidle2' });
  await page.screenshot({
    path: 'page.jpg',
    type: 'jpeg',
    quality: 85,
    fullPage: true,
  });
} finally {
  await browser.close();
}

Run the script in a Node.js project where Puppeteer is installed. The browser is closed in a finally block so it also shuts down if navigation or capture fails. Choose a real target URL and an output path your process can write to.

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.

Choose the capture area and JPEG options

JPEG format and quality

type: 'jpeg' selects JPEG. Puppeteer also documents png and webp as screenshot formats. The format can be inferred from the path extension, but specifying the type makes the intended output explicit. The options are documented in the ScreenshotOptions reference and ImageFormat type.

The quality value is a number from 0 to 100 and applies to JPEG, not PNG. Puppeteer does not specify one universally best value. Select a value for your use case and inspect the resulting image; a particular value such as 85 is an example, not a documented recommendation.

Viewport, full page, and clipped region

  • fullPage: true captures the full page rather than only the current viewport. Its default is false.
  • Use clip to capture a defined rectangle. The screenshot options reference documents captureBeyondViewport as defaulting to false when there is no clip and true otherwise.
  • For an ordinary viewport screenshot, omit fullPage or set it to false.

These settings control capture scope, not whether the page has finished rendering. Make sure the page has reached the state you intend to capture before calling the screenshot method.

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

Capture one HTML element

Use an element handle’s screenshot() method when you need an image of a single element rather than the entire page. The guide notes that Puppeteer scrolls the element into view if it is hidden. A detached element causes an error, so obtain the handle after the relevant page content has loaded and avoid removing it before capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const element = await page.$('.product-card');
if (!element) {
  throw new Error('Could not find .product-card');
}
await element.screenshot({ path: 'element.jpg', type: 'jpeg' });

See the screenshots guide for the element-capture flow.

Save the screenshot or use the returned image data

When you provide path, Puppeteer writes the image to that location. If you omit path, Page.screenshot() returns image data instead. It returns a Uint8Array by default and can return a base64 string when base64 encoding is requested; see the Page.screenshot() reference.

This is useful when another part of your application needs the bytes directly—for example, to send them to storage or an image-processing step—rather than first writing a file. If you need a file, providing path is the simplest option.

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

Wait for the page state you need

The example uses waitUntil: 'networkidle2', which is also shown in the official navigation example. Treat it as a wait condition, not a guarantee that every site’s meaningful content is ready: an application may render content after navigation or continue background requests. If a screenshot is blank or incomplete, wait for the specific content you need before capture rather than assuming navigation alone means the page is ready. The guide’s launch, navigation, capture, and browser-close sequence is documented at Puppeteer’s screenshots guide.

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

Troubleshoot common capture problems

  • The file is not JPEG: Use type: 'jpeg' and a JPEG extension such as .jpg. The format can be inferred from the extension, but an explicit type removes ambiguity.
  • The image contains only the visible viewport: Set fullPage: true for a full-page capture. Use clip instead when you need a specific region.
  • The image is blank or missing content: Confirm the target URL loads, then wait for the specific content or page state required before calling screenshot(). The sample’s networkidle2 condition may not correspond to an application’s final rendered state.
  • The element screenshot fails: Check that the selector matched an element and that the element remains attached to the page at capture time. Puppeteer scrolls a hidden target into view, but a detached element produces an error.
  • You cannot find the output file: Check whether path was supplied and whether the process can write to that location. Without a path, the method returns image data instead of saving a file.
  • JPEG quality has no effect: The documented quality option is for JPEG and does not apply to PNG. Verify the selected screenshot type.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a screenshot without managing Puppeteer or a browser, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns an image or PDF. Its clean-shot options accept cookie banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, with the page verdict and billing status reported in response headers. AI agents can use its MCP server tools: take_screenshot, get_page_info, and capture_pdf.

For JPEG output, request it with the API’s documented parameters. Check the ScreenshotNeo documentation for current API options and supported formats. This cURL example uses the supplied API pattern with the target URL adapted:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.jpg

ScreenshotNeo’s Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

Frequently Asked Questions

Can Puppeteer return a JPEG without saving a file?

Yes. Omit the path option; Page.screenshot() returns image data, a Uint8Array by default.

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

Does Puppeteer recommend a specific JPEG quality value?

No. Its options reference defines the 0–100 range but does not recommend a universal value.

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.