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

Use PhantomJS’s webpage module, open the URL, and call page.render(). Save the following as screenshot.js, then run phantomjs screenshot.js from a terminal where the PhantomJS executable is on your PATH:

var page = require('webpage').create();

page.open('https://example.com/', function (status) {
  if (status === 'success') {
    page.render('screenshot.png');
  } else {
    console.log('Could not load the page');
  }
  phantom.exit();
});

The callback receives success or fail. Testing that value before rendering prevents a failed navigation from producing a misleading image. PhantomJS’s command-line documentation is written for PhantomJS 2.1.1; that identifies the documentation target, not a current release. The project’s official homepage now warns: “Important: PhantomJS development is suspended until further notice (more details).”

Prerequisites and the smallest working script

Install and verify PhantomJS

Install PhantomJS using the package or binary appropriate for your operating system, then verify that the executable is discoverable:

phantomjs --version

If the shell reports that the command cannot be found, add the PhantomJS directory to PATH or invoke the executable with its full path. The script itself uses PhantomJS’s built-in CommonJS-style require('webpage'); it is not a Node.js script and should not be run with node.

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.
#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • 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

Run the capture

phantomjs screenshot.js

A successful run writes screenshot.png in the process’s current directory. Use an absolute output path when an automated job runs from an unexpected working directory.

Set the browser viewport

viewportSize controls the virtual browser window used to lay out the page. Set it before page.open() so responsive breakpoints are selected during navigation:

var page = require('webpage').create();
page.viewportSize = { width: 1366, height: 768 };

page.open('https://example.com/', function (status) {
  if (status === 'success') {
    page.render('desktop.png');
  } else {
    console.log('Could not load the page');
  }
  phantom.exit();
});

Changing the viewport is different from cropping. A 375-pixel viewport can cause a site to render its mobile layout; a 375-pixel crop of a 1366-pixel viewport merely cuts away pixels from the desktop layout.

Capture only part of a page

Use page.clipRect to define the rectangle PhantomJS renders. Coordinates are measured from the page’s top-left corner. This example captures a 1024 by 768 region:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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
var page = require('webpage').create();
page.viewportSize = { width: 1366, height: 900 };
page.clipRect = { top: 0, left: 0, width: 1024, height: 768 };

page.open('https://example.com/', function (status) {
  if (status === 'success') {
    page.render('cropped.png');
  } else {
    console.log('Could not load the page');
  }
  phantom.exit();
});

To capture a lower section, increase top; to capture a right-hand section, increase left. The rectangle must fit the rendered content you intend to include. For a component whose position changes between pages, calculate its bounds inside the page and assign them to clipRect before rendering:

page.open('https://example.com/', function (status) {
  if (status !== 'success') {
    console.log('Could not load the page');
    phantom.exit();
    return;
  }

  var box = page.evaluate(function () {
    var element = document.querySelector('.pricing-card');
    if (!element) return null;
    var r = element.getBoundingClientRect();
    return { top: r.top, left: r.left, width: r.width, height: r.height };
  });

  if (!box) {
    console.log('Element not found');
    phantom.exit();
    return;
  }

  page.clipRect = box;
  page.render('pricing-card.png');
  phantom.exit();
});

That approach is sensitive to scroll position and to pages that move after loading. If the element is below the initial viewport, scroll it into view in page.evaluate() first, then measure it.

Choose PNG, JPEG, PDF, or another output

page.render() selects the output format from the filename extension. The render API lists PDF, PNG, JPEG, BMP, PPM, and (where the Qt build supports it) GIF; the screen-capture guide specifically documents PNG, JPEG, GIF, and PDF.

PNG for lossless screenshots

page.render('page.png');

PNG quality settings affect lossless compression, not visible image quality. PNG is usually the safest choice for text, diagrams, and UI screenshots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
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.

JPEG for smaller photographic files

page.render('page.jpg', { quality: 85 });

JPEG quality ranges from 0 to 100, with a default of 75. Lower values reduce file size but introduce compression artifacts around text and sharp edges.

PDF output

page.render('page.pdf');

PDF pagination and layout depend on the PhantomJS/Qt build and the page’s print styles. If you need a controlled paper size, margins, landscape mode, or page ranges, a maintained browser or a screenshot service is generally easier to configure.

Wait for content before rendering

page.open()‘s success status means navigation completed according to PhantomJS; it does not guarantee that every application-rendered image or data request has finished. For a known element, poll until it exists, then render:

var page = require('webpage').create();
page.viewportSize = { width: 1280, height: 800 };

page.open('https://example.com/dashboard', function (status) {
  if (status !== 'success') {
    console.log('Could not load the page');
    phantom.exit();
    return;
  }

  var waited = 0;
  var timer = setInterval(function () {
    var ready = page.evaluate(function () {
      return !!document.querySelector('#dashboard-ready');
    });

    if (ready) {
      clearInterval(timer);
      page.render('dashboard.png');
      phantom.exit();
    } else if ((waited += 250) >= 10000) {
      clearInterval(timer);
      console.log('Timed out waiting for #dashboard-ready');
      phantom.exit();
    }
  }, 250);
});

A fixed delay can be useful for a simple page, but a selector-based condition is less wasteful and makes failures diagnosable. Avoid rendering before fonts, images, or client-side data have arrived when those assets determine the screenshot.

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
  • 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

Full-page captures and their limits

Increasing viewportSize.height captures more of the initial viewport, not automatically the entire document. PhantomJS’s official screen-capture material points to the rasterize.js example for more complete rasterization and PDF examples. Do not assume that a remote copy of that example exists in every installation; obtain the example from the version you actually installed and adapt it to your page.

Long pages can contain lazy-loaded images that appear only after scrolling. A script can scroll in increments and wait between movements, but this is site-specific and can still miss content that depends on intersection observers or user interaction. Test the resulting image rather than treating a successful process exit as proof of completeness.

Reliable error handling and diagnostics

Navigation failed

  • Symptom: the callback status is fail.
  • Cause: DNS, TLS, connection, redirect, or page-load problems.
  • Fix: log the URL, verify it from the same machine, check proxy and certificate settings, and do not call render() until status is success.

The image is blank or incomplete

  • Symptom: a white page, missing charts, or unloaded images.
  • Cause: asynchronous rendering, blocked resources, or a script error in the legacy browser engine.
  • Fix: wait for a readiness selector, add page-level logging, and inspect the page in a compatible maintained browser. A modern site may require APIs or JavaScript features PhantomJS does not implement.

The crop is misplaced

  • Symptom: the desired element is clipped or shifted.
  • Cause: confusing viewport dimensions with clip coordinates, or measuring before layout settles.
  • Fix: set viewportSize first, wait for layout, measure with getBoundingClientRect(), and then assign clipRect.

The command works locally but not in automation

  • Symptom: a scheduled job cannot find PhantomJS or writes files elsewhere.
  • Cause: a different PATH and working directory.
  • Fix: use an absolute executable and output path, record phantomjs --version, and preserve the process exit status in the job.

Security, compatibility, and maintenance considerations

PhantomJS is a legacy headless browser. Its official homepage says development is suspended, so modern TLS behavior, JavaScript syntax, CSS, web components, bot defenses, and authentication flows may not match current browsers. Treat it as a compatibility-dependent component of an existing system, not a new default for greenfield automation. Avoid placing secrets directly in scripts that may be committed, and be careful when loading untrusted URLs because a screenshot worker is still a networked browser process.

Puppeteer’s official Page API exposes page.screenshot() with a path-based example. It is a reasonable alternative to investigate when maintaining a new workflow, but available evidence does not establish a universal performance or visual-quality improvement over PhantomJS. Compare the browser versions, deployment footprint, authentication needs, and maintenance burden for your project.

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

Or skip the browser setup

ScreenshotNeo provides a hosted screenshot API and MCP server. One GET request returns PNG, JPEG, WebP, or PDF, while the service handles browser setup:

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

See the ScreenshotNeo documentation for parameters and response details. Before capture, it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result.

It also supports full-page captures with lazy images loaded, CSS-selector element captures, dark mode, device presets and custom viewports, retina scale, PDF paper settings and page ranges, HTML/CSS rendering, custom JavaScript, clicks, selector waits, delays, network-idle waits, request and resource blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs are accepted to ease migration.

An MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients, so an AI agent can request captures without you wiring a PhantomJS process. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. All features are available on every plan. Create a free ScreenshotNeo account.

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.

PhantomJS versus a hosted capture service

Concern PhantomJS script ScreenshotNeo
Where it runs Your machine or CI worker Hosted API, plus MCP tools
Modern-site maintenance You maintain a suspended legacy browser Browser setup is managed by the service
Consent and overlays You must script page-specific handling Known consent platforms, newsletter popups, and chat widgets are removed before capture
Failed pages Your infrastructure absorbs the attempt Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed
Starting allowance Depends on your infrastructure 1,000 free shots per month, no card

Practical checklist

  • Confirm PhantomJS is installed and on PATH.
  • Set viewportSize before opening the URL.
  • Check status === 'success' before rendering.
  • Wait for application content that is not present at navigation completion.
  • Use clipRect only when you need a crop; it does not change responsive layout.
  • Choose the filename extension and JPEG quality deliberately.
  • Use absolute paths and record the PhantomJS version in CI.
  • Test representative modern pages before committing to this suspended project.

Frequently Asked Questions

Can I run the PhantomJS screenshot script with Node.js?

No. The script uses PhantomJS’s webpage module and must be launched with the phantomjs executable.

What does a PhantomJS screenshot cost?

The software workflow has no per-shot service charge; your costs are the machine, storage, and maintenance needed to run it. A hosted option such as ScreenshotNeo has a free allowance and paid plans beginning at $5 for 3,000 shots.

Why does a successful status still produce a missing chart?

Navigation completion and application readiness are different. Wait for a page-specific selector or other readiness signal before calling render().

Is PhantomJS 2.1.1 current?

2.1.1 is the version named by the command-line documentation. The project homepage says development is suspended, so do not interpret that documentation as evidence of a current release.

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.