ScreenshotNeo

BlogHow-to

How to install PhantomJS on Windows 11 for website screenshots

PhantomJS can capture webpages, but it is a suspended legacy project. Learn the documented Windows setup pattern, its limits, and a maintained screenshot alternative.

By the ScreenshotNeo team4 October 20268 min read

PhantomJS is a JavaScript-scriptable headless browser with a documented webpage screenshot feature. Its historical Windows workflow is to put the phantomjs executable on your PATH, write a JavaScript capture script, and run phantomjs screenshot.js from Command Prompt or PowerShell. However, PhantomJS development is suspended and its original repository is archived. The project documentation mentions Windows generally, not Windows 11 specifically, so treat installation on Windows 11 as legacy guidance rather than a supported or verified setup.

If you need repeatable screenshots for current websites, consider the maintenance and compatibility risks before adopting PhantomJS. The sections below explain the documented approach and its limits, then show an API alternative that does not require installing a browser locally.

1. Understand the Windows 11 compatibility limit

The PhantomJS project describes the software as a headless browser that can capture webpages. Its project page lists Windows as a platform, but does not confirm Windows 11 compatibility. Its quick-start guide assumes that the executable is already installed and available on PATH; it does not establish that a current, maintained Windows installer is available.

The project explicitly says development is suspended, and the original GitHub repository is archived. The phantomjs-prebuilt npm wrapper is deprecated. These are material constraints: old browser behavior may not match modern websites, and an installation that runs is not evidence that the project is maintained or compatible with every Windows 11 system.

Accordingly, this guide explains the documented historical invocation and screenshot pattern. It does not claim Windows 11 support, provide an unverified download location, or report a successful Windows 11 installation.

2. Prepare a legacy installation carefully

  1. Locate a trustworthy binary source. The dossier does not verify a current official download URL, a specific Windows release, checksum, or signing information. Do not download an executable from an unverified mirror. Before running a binary, independently confirm its provenance, version, and integrity.
  2. Extract the package. If you have verified a Windows binary package, extract it to a directory you control. The exact archive layout depends on the package; the research does not establish a particular current package.
  3. Make the executable available in your terminal. Add the directory containing phantomjs.exe to the Windows PATH, or invoke the executable using its full path. The historical quick-start assumes PhantomJS is already on PATH.
  4. Open a new terminal and check command discovery. Run phantomjs or check its version using the option supported by the binary you obtained. If Windows cannot find the command, confirm the executable location and open a new terminal after changing PATH.
  5. Keep the script and output in a writable directory. This avoids confusion about relative paths and permission errors when the script saves an image.

Windows PATH can be edited through the system environment-variable settings, or set for only the current PowerShell session. For a session-only setup, replace the example directory with the directory that contains phantomjs.exe:

$env:Path = "C:\path\to\phantomjs\bin;$env:Path"
Get-Command phantomjs

This changes only the current PowerShell process and terminals launched from it. It does not install PhantomJS or validate the binary.

3. Capture a webpage with a JavaScript script

The PhantomJS command-line form documented by the project is phantomjs [options] somescript.js [arg1 ...]. Its quick-start shows running a script from Command Prompt or PowerShell. The screenshot guide supplies the core operation: open the page and call page.render() to write an image.

Save this as screenshot.js. It accepts the target URL and optional output filename as script arguments, opens the page, and renders a PNG after the page reports that it has loaded:

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

var address = system.args[1];
var output = system.args[2] || 'screenshot.png';

if (!address) {
  console.log('Usage: phantomjs screenshot.js <url> [output.png]');
  phantom.exit(2);
}

page.viewportSize = { width: 1365, height: 900 };

page.open(address, function (status) {
  if (status !== 'success') {
    console.log('Could not load the page: ' + address);
    phantom.exit(1);
    return;
  }

  var saved = page.render(output);
  if (!saved) {
    console.log('Could not write screenshot: ' + output);
    phantom.exit(1);
    return;
  }

  console.log('Saved ' + output);
  phantom.exit(0);
});

Run it from the directory containing the script:

phantomjs screenshot.js https://example.com example.png

Or, if the executable is not on PATH, use its full path in PowerShell:

& 'C:\path\to\phantomjs\bin\phantomjs.exe' .\screenshot.js https://example.com .\example.png

The viewport setting controls the browser viewport dimensions. A viewport screenshot is not automatically a full-page capture. This basic script also does not wait for a site-specific selector, delayed content, or network activity beyond the page-open callback. Those differences matter for pages rendered by client-side JavaScript or populated after initial load.

4. Choose an image format and capture scope

The documented screenshot pattern uses page.render() to write an image. Choose an output extension and a format supported by the binary you have; PNG is a straightforward example. Do not assume a particular PhantomJS build supports every modern image format or browser feature.

  • Viewport: Set page.viewportSize before opening the page to control the visible browser area.
  • Page rendering: page.render(output) saves the rendered page to the destination file.
  • Full-page needs: The basic example captures the configured viewport. A full-page result may require legacy-version-specific scripting or page sizing; verify behavior against the exact binary rather than assuming viewport dimensions produce a full-page image.
  • Dynamic content: A successful page-open callback does not guarantee that animations, lazy-loaded images, or asynchronous application data have finished. Add a deliberate wait only if you control the script and have confirmed the necessary PhantomJS APIs for your version.

5. Troubleshoot common installation and capture errors

Symptom Likely cause What to do
phantomjs is not recognized or not found The executable directory is not on PATH, the terminal predates the PATH change, or the package layout differs. Confirm the location of phantomjs.exe, add its containing directory to the session or system PATH, then open a fresh terminal. Try a full-path invocation to distinguish PATH setup from a missing binary.
The executable will not start The binary may be wrong for the system, damaged, or from an untrusted or incompatible package. Recheck the source, version, and integrity information. The researched sources do not document a Windows 11-specific compatibility fix; do not treat an unknown executable as safe to run.
The script prints a usage message The URL argument was omitted or arguments were supplied in the wrong order. Use phantomjs screenshot.js https://example.com output.png. The URL and output path follow the script name.
The page fails to open The address is unreachable from the machine, redirects or TLS behavior are unsupported by the old browser, or the site blocks automated browsing. Check the URL in a regular browser and inspect the network and page status. The dossier does not establish a fix for modern TLS, bot checks, or site-specific blocking in PhantomJS.
The image is blank or missing late content The page may render content asynchronously, or the old browser may not support the page’s JavaScript and web APIs. Check whether the page relies on modern browser features. A page-open callback only indicates that the navigation completed; it is not a guarantee that all application content is ready. Use a maintained browser workflow if compatibility is required.
The output file is missing The relative path points somewhere unexpected, or the process cannot write to that directory. Use an absolute output path in a writable folder and check the script’s exit status and console output.
The phantomjs-prebuilt install fails or seems stale The npm wrapper is deprecated and should not be treated as a maintained installer. Do not rely on it as a current Windows 11 installation route. Assess a verified binary source or choose a maintained capture approach.

6. Reliability, performance, and maintenance considerations

PhantomJS is a legacy dependency. Its suspended development and archived repository mean that current website compatibility, security maintenance, and Windows 11 behavior are not established by the historical documentation. This matters most when screenshots are part of a production service, run against untrusted URLs, or need to match current browser rendering.

Capture time depends on navigation, page scripts, network access, and the point at which the script renders. The dossier supplies no performance benchmarks, so there is no defensible universal speed estimate. For repeat runs, use consistent viewport dimensions, define when a page is considered ready, handle navigation failures, and record the binary version alongside output.

Local PhantomJS has no per-shot API price in this workflow, but operating it still has costs: setup, maintenance, machine resources, debugging, and the time required to handle incompatible pages. Avoid exposing a screenshot script as an unrestricted public URL fetcher; arbitrary destinations can reach internal network resources. If you operate a capture service, restrict destinations and network access.

7. Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. Make one GET request with a URL to receive a PNG, JPEG, WebP, or PDF; see the ScreenshotNeo API documentation for parameters and options.

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

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)
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 Bun.write('shot.webp', res);

Use a secret API key from a server-side environment; do not expose it in browser code. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the shot. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server gives AI agents tools to take screenshots, get page information, and capture PDFs. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo free: 1,000 screenshots a month, no card required.

8. Frequently asked questions

Is PhantomJS officially supported on Windows 11?

The researched project documentation names Windows generally, but does not confirm Windows 11 compatibility. The project is suspended, so treat it as legacy software.

Can I install PhantomJS with npm?

The phantomjs-prebuilt wrapper is deprecated. The research does not support presenting it as a maintained installation method.

Does this script capture the entire page?

No. The example sets a viewport and renders the page; it does not promise full-page capture. Full-page behavior depends on the exact legacy version and script.

Where can I find a verified Windows installer?

The research dossier did not verify a current download URL, release, checksum, or Windows 11 installer. Verify provenance and integrity independently before running any binary.

What if a modern site renders incorrectly?

PhantomJS is suspended and may not support the browser features a current site expects. A maintained browser or hosted screenshot API is a better fit when current rendering compatibility is required.