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

To take a website screenshot from PHP with Browserless, send a server-side POST request with JSON to the Screenshot API, then save the image response. Keep your Browserless token on the server. The examples below use Browserless’s documented Cloud hostname as a sample; use the base URL for your own Browserless region or deployment if it differs.

What you need

  • A Browserless API token.
  • PHP with the cURL extension enabled, or Guzzle if your project already uses it.
  • The correct Browserless endpoint for your Cloud region or self-hosted deployment.

The documented Cloud example is https://production-sfo.browserless.io/screenshot. Browserless’s current Screenshot API uses POST /screenshot, JSON input, and a token query parameter; the sample host is not universal. See the Screenshot API reference and PHP integration documentation.

Take and save a screenshot with PHP cURL

This example requests a full-page PNG encoded as base64, checks the HTTP response and cURL errors, decodes the image, and writes it to a file. Set the token in the server environment rather than placing it in browser-delivered JavaScript or committing it to source control.

<?php
$token = getenv('BROWSERLESS_TOKEN');
if (!$token) {
    throw new RuntimeException('Set the BROWSERLESS_TOKEN environment variable.');
}

$endpoint = 'https://production-sfo.browserless.io/screenshot';
$url = 'https://example.com/';
$payload = [
    'url' => $url,
    'options' => [
        'fullPage' => true,
        'type' => 'png',
        'encoding' => 'base64',
    ],
];

$ch = curl_init($endpoint . '?token=' . rawurlencode($token));
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS => json_encode($payload, JSON_THROW_ON_ERROR),
    CURLOPT_TIMEOUT => 90,
]);

$response = curl_exec($ch);
if ($response === false) {
    $error = curl_error($ch);
    curl_close($ch);
    throw new RuntimeException('Browserless request failed: ' . $error);
}
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException('Browserless returned HTTP ' . $status . ': ' . $response);
}

$image = base64_decode($response, true);
if ($image === false) {
    throw new RuntimeException('Browserless response was not valid base64 image data.');
}
if (file_put_contents(__DIR__ . '/screenshot.png', $image) === false) {
    throw new RuntimeException('Could not write screenshot.png.');
}

Here, encoding: base64 is paired with PHP’s strict base64_decode(). If instead you request or receive raw image bytes, write those bytes directly; do not base64-decode them. Browserless documents image responses in PNG, JPEG, or WebP formats, so make the requested type, filename extension, and downstream handling agree.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Use Guzzle if it is already in your PHP project

Browserless also documents a Guzzle route. It posts JSON, supplies the token as a query parameter, reads the response body, and allows request exceptions to be handled through the HTTP client.

<?php
require __DIR__ . '/vendor/autoload.php';

use GuzzleHttpClient;
use GuzzleHttpExceptionGuzzleException;

$token = getenv('BROWSERLESS_TOKEN');
if (!$token) {
    throw new RuntimeException('Set the BROWSERLESS_TOKEN environment variable.');
}

$client = new Client(['timeout' => 90]);
try {
    $response = $client->post(
        'https://production-sfo.browserless.io/screenshot',
        [
            'query' => ['token' => $token],
            'json' => [
                'url' => 'https://example.com/',
                'options' => [
                    'fullPage' => true,
                    'type' => 'png',
                    'encoding' => 'base64',
                ],
            ],
        ]
    );
    $encoded = (string) $response->getBody();
    $image = base64_decode($encoded, true);
    if ($image === false) {
        throw new RuntimeException('Browserless response was not valid base64 image data.');
    }
    if (file_put_contents(__DIR__ . '/screenshot.png', $image) === false) {
        throw new RuntimeException('Could not write screenshot.png.');
    }
} catch (GuzzleException $e) {
    throw new RuntimeException('Browserless request failed: ' . $e->getMessage(), 0, $e);
}

Use cURL for a dependency-light integration. Guzzle is convenient when it is already part of the application and you want its response and exception handling. The exact endpoint should still match your Browserless deployment.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Choose screenshot options for the page you need

Full document, viewport, or one element

  • Set options.fullPage to true for the whole document; omit it or use a viewport capture when you only need the visible browser area.
  • Use selector capture when the output should contain one page element rather than the full page.
  • Use clip coordinates for a specific rectangular region, or configure the viewport size and device scale factor to control the capture dimensions and pixel density.

Format, quality, and loading

  • Choose PNG, JPEG, or WebP using the documented screenshot type options; quality settings are relevant where the format supports them.
  • Use wait conditions or navigation settings when the target needs time to render. For lazy-loaded content in full-page captures, Browserless notes that scrollPage: true can help trigger loading before the screenshot.
  • Request blocking and resource blocking can limit selected network requests or resource types when appropriate to the page.

Capture supplied HTML instead of a URL

For HTML you provide, send an html field instead of url; do not include both in the same request. The endpoint also supports injecting scripts or styles before capture. Use this mode when you want to render markup you already have rather than navigate to a live website.

Know when the Screenshot REST endpoint is the wrong fit

The Screenshot REST call is a stateless, single-action request: it launches a browser, performs one task, and closes the session. It does not retain a browser session for a sequence of clicks, form entry, branching decisions, or later requests. For those workflows, use a Browserless session-based option or BrowserQL rather than trying to chain independent screenshot calls. Browserless describes this distinction in its REST API overview.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

A screenshot endpoint request should not be treated as a guarantee that a target site will permit automated access or render successfully. A site can still present access checks or other obstacles; this API call alone does not establish that such behavior will be bypassed.

Troubleshoot common integration failures

  • cURL reports a connection or timeout error: verify that PHP’s cURL extension is enabled, the endpoint is reachable from the server, and the configured timeout suits the page’s load time.
  • The response is an HTTP error: inspect the status and response body before writing a file. Confirm the token, endpoint path, region or deployment host, JSON body, and that the request uses POST.
  • The saved file is corrupt or empty: ensure the response mode matches the save logic. Decode only a base64 response; save raw binary bytes without decoding. Check that the requested format and filename extension agree.
  • The image is only the top of the page: verify options.fullPage is true. If page content appears only after scrolling, try the documented scrollPage option.
  • The screenshot misses content that appears later: configure an appropriate wait condition or navigation setting for that page, then recheck the output.
  • PHP cannot save the image: check the destination path and the PHP process’s write permissions; file_put_contents() returns false on failure.
  • You need clicks or retained login/session state: the screenshot REST route does not retain state across requests; use a session-oriented Browserless product or BrowserQL.

Or skip the browser setup

If you want a one-request screenshot endpoint without managing a browser integration, ScreenshotNeo accepts a URL and returns an image or PDF. Its cleanup can accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents.

Example cURL request, with the API key kept server-side; see the ScreenshotNeo API documentation for request options:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/ -o shot.webp

ScreenshotNeo’s Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is on every plan. Sign up for ScreenshotNeo free.

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

Optional Laravel package

Browserless documents a Laravel package created and maintained by Christopher Miller, but identifies it as community-supported rather than officially supported by Browserless. If you choose it, account for that support status when deciding whether to make it a critical dependency. See the Browserless PHP integration page.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Frequently Asked Questions

Can I capture a full-page screenshot with Browserless from PHP?

Yes. Include "fullPage": true inside the JSON request’s options object.

Can the Browserless Screenshot API render HTML I provide?

Yes. Send html instead of url; the request should not contain both fields.

Can one Screenshot REST request click through a workflow and keep the browser session open?

No. The REST screenshot route performs one action and closes the browser session; use a session-based option or BrowserQL for interaction and retained state.

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.