DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk6 min

How to Generate Website Screenshots from URLs in Node.js in India

Use Playwright or Puppeteer to open a URL in a browser and save a Node.js screenshot. This guide covers viewport, full-page and element captures, plus deployment notes for developers in India.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To turn a website URL into an image in Node.js, open the URL in a browser controlled by Playwright or Puppeteer, then call the browser page’s screenshot method. The examples below save a PNG and show how to capture the visible viewport, the full page, or one element. The same setup applies to developers in India; the cited library documentation does not specify a separate India-only API or setup.

Generate a website screenshot with Playwright

Playwright is a practical default when you want documented support for Chromium, WebKit, and Firefox. Its official installation guide covers npm setup and browser installation on Windows, Linux, and macOS: Playwright installation.

As an Amazon Associate I earn from qualifying purchases.

Install Playwright and its browser

  1. Create a Node.js project if you do not already have one, then install Playwright:

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    npm init -y
    npm install -D playwright
    npx playwright install chromium

    The final command installs Chromium for this example. To use another supported engine, install its browser and select it in the code.

    #1 Best Overall
    Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
    • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
    • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
    • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
    • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
    • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
  2. Save this as screenshot.js. Replace the example URL with the page you want to capture:

    const { chromium } = require('playwright');
    
    (async () => {
      const browser = await chromium.launch();
      try {
        const page = await browser.newPage({ viewport: { width: 1280, height: 800 } });
        await page.goto('https://example.com');
        await page.screenshot({ path: 'screenshot.png' });
      } finally {
        await browser.close();
      }
    })();
  3. Run it with node screenshot.js. On success, the current directory contains screenshot.png.

The screenshot call saves the currently visible viewport by default. Playwright’s Page API documents the sequence of opening a page, navigating to a URL, and saving a screenshot: Playwright Page API.

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 part of the page to capture

Full scrollable page

Set fullPage: true to capture beyond the visible viewport:

await page.screenshot({ path: 'full-page.png', fullPage: true });

This can produce a tall image, particularly for long pages. If the page loads content only as you scroll, give it time or scroll through the relevant sections before capturing; a screenshot taken too early may not include content that has not loaded.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

One element

Use a locator’s screenshot method to isolate a component. The locator must match an element on the page:

await page.locator('main article').screenshot({ path: 'article.png' });

Replace main article with a selector from the target site. If it matches no element, the capture cannot succeed; wait for the selector or check that the selector is correct.

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

Image bytes instead of a file

Omit path to receive the screenshot as a buffer. This is useful when passing image bytes to another library or comparing images without first writing a file:

const image = await page.screenshot();
console.log(`Captured ${image.length} bytes`);

Playwright documents viewport and full-page capture, element screenshots, and returned image data in its Page API and screenshot options.

Output type and pixel scale

For a file capture, Playwright uses the filename extension to determine the image type. Its screenshot options include quality for formats that support it and a choice between CSS-pixel and device-pixel scaling. Device scaling can make high-DPI output larger; choose it when the additional pixel density is useful, not by default for every capture.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Use Puppeteer instead

Puppeteer is another browser-automation option. Its screenshots guide demonstrates launching a browser, navigating, saving an image, and closing the browser. Install the package and its browser as described in the Puppeteer installation guide, then use this CommonJS example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage();
    await page.goto('https://example.com', { waitUntil: 'networkidle2' });
    await page.screenshot({ path: 'screenshot.png' });
  } finally {
    await browser.close();
  }
})();

Run it with node screenshot.js. Puppeteer’s guide uses networkidle2 as an example navigation wait, not as a guarantee that every site has finished rendering or is visually settled. Its element handle screenshot method can capture one element; the guide notes it attempts to scroll a hidden element into view by default: Puppeteer screenshots guide.

Wait for the page you actually need

A navigation promise resolving does not necessarily mean every image, animation, or client-rendered component is ready for capture. For a page with a known content selector, wait for that element before taking the screenshot:

await page.goto('https://example.com');
await page.locator('main').waitFor();
await page.screenshot({ path: 'ready.png' });

Use the selector that represents the content you need. For sites where the relevant content appears after a known delay or user interaction, handle that explicitly rather than assuming a single network-idle setting works for every website.

Which library should you choose?

Both libraries support the basic URL-to-image workflow. Choose based on the browser engines and project setup you need, along with how you will decide a page is ready and whether you need viewport, full-page, or element output. Playwright’s installation documentation lists Chromium, WebKit, and Firefox; the cited documentation does not establish a universal performance winner, so avoid choosing on an unsupported speed assumption.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Running the capture from India

The Node.js examples do not require a country-specific change. The official Playwright setup information lists operating systems and browser engines rather than India-specific hosting regions, pricing, or network requirements. If you deploy the script on a server, confirm that the environment can install and run the browser binary and can reach the target site. Access restrictions and the page’s behavior can vary by target site and deployment environment.

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

Troubleshooting common capture failures

  • Browser executable missing: install the browser binary for the engine you selected. For the Playwright Chromium example, run npx playwright install chromium.

  • Navigation times out or the page is incomplete: check that the URL is reachable from the machine running Node.js. Some pages keep network connections open or load important content after navigation; use an appropriate selector or readiness condition instead of treating a network-idle wait as universal.

  • Element screenshot fails: verify that the CSS selector matches an element and wait for it to appear before taking the screenshot.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Full-page image omits content: the page may load sections lazily as they enter view. Scroll through the page or wait for the needed content to load before capturing.

    Best Value
    Sale
    Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
    • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
    • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
    • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
  • Output is unexpectedly large: check whether device-pixel scaling or full-page capture is producing more pixels than your downstream workflow needs.

  • Browser stays open after an error: put browser.close() in a finally block, as in the examples, so the browser is closed even when navigation or screenshot capture throws an error.

Or skip the browser setup

For a hosted option, ScreenshotNeo takes a URL in one GET request and returns a screenshot. Its API can return PNG, JPEG, WebP, or PDF; the parameter names used by other screenshot APIs also work, which can ease a switch. See the ScreenshotNeo API documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await require('node:fs/promises').writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

Before capture, ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. It also has an MCP server with screenshot, page-info, and PDF-capture tools for AI agents. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000, with the same features on every plan.

Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card.

Frequently Asked Questions

Can I save a screenshot directly to memory in Node.js?

Yes. With Playwright, call page.screenshot() without a path; it returns the image bytes as a buffer.

Does running this tutorial from India require a different API?

No India-specific API or setup is established by the cited library documentation. The examples use the same Node.js browser-automation workflow.

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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.