Skip to content

Browsershot

Laravel/PHP package that takes screenshots and PDFs of web pages via Puppeteer.

Self-hostedNot yet verified
Report issueDemo online
MIT★ 4000

Open the official app on spatie.be

This tool is hosted by its maintainers. Click below to open spatie.be in a new tab — it's their official demo.

Browse developer tools →

What's next with Browsershot?

Choose how you want to get started.

Use it free

Open the official tool or demo — no account needed.

Free

Self-host it

Run the open-source version on your own infrastructure.

Open

What is Browsershot?

Browsershot is an open-source PHP library designed to render web pages into static images or PDF documents. It leverages Puppeteer, a Node.js library that controls headless Chrome, to execute JavaScript and capture dynamic content. Developers use Browsershot to automate tasks like generating screenshots for documentation, creating printable reports, or validating UI elements in web applications. The tool solves the challenge of capturing fully rendered pages, including elements loaded by JavaScript, which traditional screenshot tools often miss. Its MIT license and active community (over 5,200 stars) make it a popular choice for developers needing reliable, server-side rendering capabilities without manual intervention.

How it works

Browsershot is a PHP package that converts URLs or HTML content into images or PDFs by executing JavaScript via Puppeteer. It abstracts the complexity of managing headless browsers, allowing developers to focus on generating output. The tool is ideal for scenarios requiring automated page captures, such as testing, documentation, or analytics. It ensures dynamic elements like animations or API-driven content are rendered accurately. Browsershot supports saving outputs as PNG, JPEG, or PDF, with file type determined by the extension in the save path. It can capture pages from URLs, inline HTML strings, or even the body HTML after JavaScript execution. Features like retrieving triggered network requests or extracting raw HTML provide additional flexibility for debugging and analysis.

How to use it

  1. 1Install the package via Composer: `composer require spatie/browsershot`.
  2. 2Use the Browsershot facade to specify the URL or HTML content.
  3. 3Call the save method with the desired output path and format.
  4. 4Optionally configure dimensions, timeouts, or other Puppeteer settings before saving. Practical tips: Use `->waitUntil('networkidle0')` to ensure all assets load, or `->dimensions(['width' => 1920, 'height' => 1080])` for custom resolutions. Always handle exceptions for failed renderings.

What it can do

  • PHP screenshot tool

Use cases

Assumptions and limitations

Assumptions

  • source: https://github.com/spatie/browsershot
  • license: MIT — free to use
  • privacy: Self-hosted — you control your data

Limitations

  • Depends on Puppeteer and Chrome, requiring system-level dependencies
  • Performance may degrade with complex or resource-heavy pages
  • Limited advanced image manipulation beyond basic saving options
  • Custom CSS styling for generated outputs is not supported
  • Compatibility issues may arise with certain web APIs or browser features

Understanding the result

Laravel/PHP package that takes screenshots and PDFs of web pages via Puppeteer.

Tool details

  • Clearly flagged when a network request is needed.
  • No account, no sign-up, and no tracking of your content.
  • Powered by (MIT).
Built with
(spatie/browsershot)
License
MIT
Runs locally
No — requires a network request
Verification
Not yet verified
Input
Query
Output
Text
Open-source source & license

Built with spatie/browsershot. OpenToolVault provides the discovery and browser interface while crediting the original project maintainers.

Built with
License
MIT
View source on GitHub

Open-source project

OpenToolVault is an independent directory. We are not affiliated with or endorsed by this project.

References

Frequently asked

What is Browsershot and what does it do?

Browsershot is a PHP library that converts web pages into images or PDFs by executing JavaScript through Puppeteer. It captures fully rendered content, including dynamic elements, and saves them as files. Developers use it for tasks like generating screenshots, creating reports, or validating UI states without manual intervention.

How does Browsershot work technically?

Browsershot uses Puppeteer to launch a headless Chrome instance, which renders the target URL or HTML. It executes JavaScript to load all assets and then captures the final DOM state. The output is generated by Puppeteer's screenshot or PDF generation capabilities, with Browsershot handling the PHP integration and configuration.

How do I generate a PDF from a URL?

Use the Browsershot facade with the `save` method and a PDF file path: `Browsershot::url('https://example.com')->save('output.pdf')`. Ensure the path ends with `.pdf` to trigger PDF generation. You can also customize margins or print styles via Puppeteer options.

How does Browsershot compare to Puppeteer or Selenium?

Browsershot is a PHP wrapper for Puppeteer, simplifying its use in PHP projects. Unlike Selenium, which requires a separate WebDriver, Puppeteer (and thus Browsershot) uses Chrome directly. Browsershot focuses on rendering and saving outputs, while Puppeteer offers broader control over browser automation. Selenium is more suited for complex interaction testing, whereas Browsershot excels at static output generation.

How do I troubleshoot a 'failed to launch Chrome' error?

Ensure Chrome is installed and accessible via the system PATH. Verify Puppeteer's Chrome binary path via `CHROME_BIN` environment variables. Check for missing dependencies like ChromeDriver or incompatible Chrome versions. Use `->debugOutput(true)` to log detailed error messages from Puppeteer.

Spotted something wrong with Browsershot, or want to maintain it? See how to help.