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 capture a mobile-style screenshot with PhantomJS, set page.viewportSize before opening the page, optionally set a mobile user-agent string, check the page.open() status, and call page.render() after the page is ready. For an exact fixed-size image, set page.clipRect as well. This emulates a browser viewport; it is not a capture from a physical phone.

PhantomJS uses WebKit to render pages, but its official project page says development is suspended until further notice. Treat it as a legacy option, particularly when capturing modern sites. PhantomJS project page.

Capture a mobile viewport with PhantomJS

The essential order matters: configure the viewport and any user agent before navigation, then render from the successful page-open callback. Save this as mobile-screenshot.js:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
var page = require('webpage').create();

page.viewportSize = { width: 375, height: 667 };
page.settings.userAgent =
  'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2 like Mac OS X) ' +
  'AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 ' +
  'Mobile/15E148 Safari/604.1';

page.open('https://example.com/', function (status) {
  if (status !== 'success') {
    console.log('Unable to access network');
    phantom.exit();
    return;
  }

  page.render('mobile-375x667.png');
  phantom.exit();
});

Run it with:

phantomjs mobile-screenshot.js

On success, PhantomJS writes mobile-375x667.png in the current working directory. The basic sequence follows the official screen-capture examples: create a webpage, open a URL, render the page, and exit. PhantomJS screen capture guide.

#1 Best Overall
Sale
Motorola Moto g - 2026 | Unlocked | Made for US 4/128GB | 50MP Camera | Pantone Slipstream, Cellular_Phone
  • Universal unlocked. Compatible with all major U.S. carriers, including Verizon, AT&T, T-Mobile and other prepaid carriers.
  • Super-bright, super-smooth 6.7" display. See your screen clearly even outdoors in sunlight, and enjoy seamless views with a fast-refreshing 120Hz display.*
  • AI-powered camera system. Take stunning photos in any light with the 50MP camera**, look your best with a 32MP selfie cam*****, and capture extreme close-ups.
  • Superfast 5G performance. Unleash your entertainment at 5G speed*** with the MediaTek Dimensity 6300 chipset and up to 12GB of RAM with RAM Boost****.
  • Long-lasting battery + TurboPower charging. Power through day after day with a 5200mAh battery, then get hours of power in just minutes.****

Choose the viewport before opening the URL

page.viewportSize sets the emulated browser window in CSS pixels and influences responsive layout. A viewport of 375 by 667 pixels is one narrow-phone example; 390 by 844 is another larger-phone example. These are viewport dimensions, not guarantees of a match to a specific physical device. The site may respond to other signals, and the screenshot does not reproduce the device’s hardware, operating system, browser chrome, or pixel density.

Set a user agent only if the site needs one

The mobile user-agent string in the script is optional. It can influence server-side responses or page scripts that branch on browser identity, but changing it does not turn PhantomJS into a real iPhone browser. Set page.settings.userAgent before page.open(); the setting API describes these settings as applying during the initial open call. PhantomJS WebPage settings API.

Check the open status before rendering

The callback’s status should be success before the script writes an image. The failure message in the example is deliberately broad: a failed open can indicate a network or page-load problem, and the callback alone does not provide a full diagnosis. Do not treat the existence of an output file as proof that the intended page loaded correctly.

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.
Rank #2
Samsung Galaxy A17 5G Smart Phone 128GB US 1 Yr Manufacturer Warranty Black
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Crop to an exact screenshot rectangle

page.viewportSize controls the browser window used for layout; page.clipRect chooses the rectangle included in the screenshot. For a fixed 375-by-667 output area, add this before page.open():

page.clipRect = { top: 0, left: 0, width: 375, height: 667 };

Set the clip dimensions to the target rectangle you need. A clip can make the image output a fixed size, but it does not change the page’s responsive breakpoint: that is determined by the viewport. The official automation reference defines clipRect as the part of the screen taken in the screenshot. PhantomJS clipRect reference.

If you omit clipRect, page.render() captures the rendered page area according to PhantomJS’s normal behavior. Use a clip when a fixed screenshot canvas is important; omit it when you want the page-area capture rather than an explicitly bounded rectangle.

Rank #3
Samsung Galaxy A16 5G 128GB Cell Phone, Unlocked Android Smartphone, Large AMOLED Display, Durable Design, Super Fast Charging, Expandable Storage, US Version, 2025, Blue Black (Renewed)
  • Charger NOT Included, 6.7" Super AMOLED FHD+, 90Hz Refresh Rate, 385 ppi, 800 nits (HBM), 1080x2340px, 5000mAh Battery
  • 128GB, 4GB RAM, microSDXC, Exynos 1330 (5nm), Octa-Core, Mali-G68 MP2 or Mali-G57 MC2 GPU
  • Rear Camera: 50MP, f/1.8 (wide) + 5MP, f/2.2 (ultrawide) + 2MP, f/2.4 (macro), LED flash, panorama, HDR; Front Camera: 13MP, f/2.0, Android 14, up to 6 major Android upgrades, One UI 6.1
  • 3G: HSDPA 850/900/1700(AWS)/1900/2100; 4G LTE: 1/2/3/4/5/7/12/13/14/20/25/26/28/29/30/38/39/40/41/48/66/71, 5G: 2/5/25/41/66/71/77/78 SA/NSA/Sub6/mmWave - Nano-SIM + eSIM
  • US Model – Global Connectivity – Compatible with Most GSM Carriers like T-Mobile, AT&T, MetroPCS, etc. Will Also work with CDMA Carriers Such as Verizon, Straight Talk.

Wait for content that loads after navigation

A successful page.open() callback does not establish that every application-specific asynchronous task has finished. A page may render its shell first and fetch images, results, or other content afterward. If the screenshot is taken too early, the file can be valid while visible content is missing.

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

Use a deliberate delay when the page has a known settling time

For a page whose content appears shortly after navigation, delay the render in the successful callback. For example, replace the render-and-exit lines with:

  window.setTimeout(function () {
    page.render('mobile-375x667.png');
    phantom.exit();
  }, 1500);

The 1,500-millisecond delay is an example, not a universal readiness guarantee. Choose a delay based on the page’s behavior, and avoid long waits when a specific readiness condition can be checked instead.

Rank #4
Samsung Galaxy A17 5G Smart Phone 128GB, US 1 Yr Manufacturer Warranty Blue
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Prefer a page-specific readiness check when possible

If the page exposes a stable element or JavaScript state that appears only when the needed content is ready, poll for that condition from the page context and render once it is true. The correct condition depends on the site; PhantomJS’s basic capture example does not promise that an arbitrary page’s own asynchronous work has completed. Set a finite timeout in any polling logic and exit without pretending the capture is complete if the condition never arrives.

Choose the output format and quality

page.render(filename) infers its format from the filename extension. PhantomJS documentation lists PNG, JPEG, BMP, PPM, GIF (depending on the build), and PDF. PhantomJS render method.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Format or setting When it fits Documented behavior
PNG When you want lossless visual detail, including sharp text and interface edges. The quality parameter controls compression size while remaining visually lossless, according to the API reference.
JPEG When a smaller photographic-style image is more important than lossless edges. JPEG quality is an integer from 0 to 100; higher or lower values change the quality/size trade-off.
BMP, PPM, GIF When a downstream workflow specifically accepts one of these formats. The guide lists these formats; GIF availability depends on the build.
PDF When the output should be a document rather than a raster image. PDF is among the formats listed by the render documentation.

For the common screenshot case, use a .png filename for detail, or a .jpg filename when you need JPEG output. Do not assume every PhantomJS build supports every listed format, especially build-dependent GIF support.

Best Value
Tracfone Motorola Moto G 2025, 64GB, Saphire Blue (Locked to
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
  • DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
  • CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
  • PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
  • BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Understand the limits of mobile emulation

PhantomJS’s viewport and user-agent settings let you test responsive layout and pages that vary by browser identity. They do not establish that the page behaves as it would on a real device. A physical phone can differ in browser engine, operating-system behavior, touch interaction, font rendering, device pixel ratio, and available APIs. PhantomJS’s renderer is WebKit, and the project status makes it a legacy capture choice rather than a maintained path for new browser coverage. The official project page says development is suspended until further notice. PhantomJS project page.

For repeatable legacy capture jobs, pin the PhantomJS runtime used by your build and keep the script and expected output format together. Modern web features or TLS behavior may differ from current browsers; if the target requires current browser compatibility, use a maintained browser automation tool instead. This is an engineering recommendation based on PhantomJS’s stated project status, not a promise about any particular replacement.

Troubleshoot common capture problems

  • The script reports “Unable to access network.” The open callback did not report success. Check the URL, network access, and whether the target is reachable from the machine running PhantomJS; render only after a successful open.
  • The image has a desktop layout. Confirm that page.viewportSize is assigned before page.open(). If the site serves different markup based on browser identity, set the user agent before navigation too.
  • The image is the wrong size. Separate the two controls: set viewportSize for responsive layout and clipRect for the screenshot rectangle. Check both width and height, and ensure the clip begins at the intended top and left coordinates.
  • Content is missing or still loading. The page may perform asynchronous work after the open callback. Add a page-appropriate delay or wait for a specific readiness condition before calling page.render().
  • The result differs from an iPhone screenshot. The script emulates a viewport and can send a mobile user agent, but it does not capture a physical iPhone or reproduce every device-specific rendering behavior.
  • The chosen extension produces an unexpected result. Confirm the filename extension and the formats supported by the installed build. GIF support is build-dependent; the render API documentation lists the supported output types and quality behavior.
  • A modern site fails despite a correct script. PhantomJS development is suspended, so its engine and TLS behavior may not match current browsers. Test whether the same page requires newer browser capabilities, and use maintained browser automation for new compatibility work.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF. For example, save this as a cURL command, replacing the example URL with the page to capture:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 API documentation for request options. The corresponding Python example is:

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)

And in Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and whether the request was billed. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up free for 1,000 screenshots a month, with no card required.

Frequently Asked Questions

Does changing the user agent make PhantomJS a real mobile browser?

No. It changes the browser identity string sent with the request; the capture still uses PhantomJS and its WebKit renderer.

Can PhantomJS capture a page as a PDF?

Yes. The render documentation lists PDF among the supported output formats; use a PDF filename extension and confirm support in the installed build.

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.