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

Use Puppeteer’s Page.screenshot() method after navigating to the URL, and set type: 'jpeg'. Provide a .jpg path to save the image. The example below captures the full page; remove fullPage: true to capture only the viewport.

Convert a URL to JPEG with Puppeteer

Install Puppeteer in your project, then run this ES module. Puppeteer’s screenshot guide demonstrates this browser, navigation, and capture workflow: Puppeteer Screenshots guide.

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();
}

Replace https://example.com with the URL you want to capture. The script writes page.jpg in the current working directory. The quality value of 85 is an example setting, not a universal recommendation.

Choose the screenshot size and quality

Viewport or full page

Puppeteer captures the visible viewport by default. Set fullPage: true to capture the full page instead. You can also use a clip to capture a defined region; captureBeyondViewport controls capture beyond the viewport. See the ScreenshotOptions API for the available options.

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

JPEG quality

The quality option accepts values from 0 to 100. It applies to JPEG, not PNG. A higher value generally retains more image detail at the cost of a larger file; choose a value appropriate to your use case rather than treating 85 as a benchmark.

Save to a file or use the image data

When you pass path, Puppeteer saves the image to that location. Without a path, page.screenshot() returns a Uint8Array by default, which you can pass to another function or write using your runtime’s file APIs. It can also return a base64 string when base64 encoding is requested. Details are in the Page.screenshot() API.

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

Wait for the page content you need

The example uses waitUntil: 'networkidle2', a navigation condition shown in Puppeteer’s guide. It does not guarantee that every site’s application content is ready. A page may load additional content after navigation, such as data-driven sections or images activated by scrolling. For those pages, wait for the relevant selector or use an appropriate page-specific wait before taking the screenshot.

For example, if a page renders the main content only after a particular element appears, wait for that selector after navigation:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
await page.waitForSelector('main article');
await page.screenshot({ path: 'article.jpg', type: 'jpeg', quality: 85 });

Choose a selector that actually represents readiness for the page you are capturing; a selector appearing does not necessarily mean every image or asynchronous component has finished loading.

Capture one element instead of the whole page

If you only need a chart, card, or other element, locate it and call its screenshot() method. Puppeteer scrolls the element into view if needed. See ElementHandle.screenshot().

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
const element = await page.waitForSelector('.report-card');
if (!element) throw new Error('Report card was not found');
await element.screenshot({ path: 'report-card.jpg', type: 'jpeg', quality: 85 });

Common problems and fixes

  • The output is PNG instead of JPEG: Set type: 'jpeg'. When saving with a path, Puppeteer can infer the format from a .jpg or .jpeg extension if you omit type, but setting it explicitly avoids ambiguity. The supported image formats include PNG, JPEG, and WebP; see the ImageFormat type.
  • The screenshot is cut off at the viewport: Add fullPage: true for the full page, or define a clip if you need a specific region.
  • The capture is blank or missing dynamic content: Navigation completion and application readiness are not the same. Wait for a page-specific selector or content condition before capturing.
  • The script exits before the browser closes: Keep browser.close() in a finally block so the browser is closed even if navigation or capture throws an error.
  • You need bytes rather than a file: Omit path and use the returned screenshot data; by default it is a Uint8Array.

Or skip the browser setup

ScreenshotNeo converts a URL to an image or PDF with a GET request. It removes cookie banners, newsletter popups, and chat widgets before capture; 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 per month with no card; paid plans start at $5 for 3,000 shots. See the ScreenshotNeo documentation.

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

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Can Puppeteer save a screenshot as a .jpg file?

Yes. Set type: 'jpeg' and use a .jpg or .jpeg path.

What is the default screenshot format in Puppeteer?

When saving to a path, Puppeteer can infer the image format from the extension. Set type explicitly when you want to specify JPEG directly.

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.