Convert a webpage to an image or pdf using headless Chrome

Fund package maintenance!

Installs: 15 834 615

Dependents: 73

Suggesters: 5

Security: 4

Stars: 4 739

Watchers: 65

Forks: 477

4.1.1 2024-07-03 08:45 UTC


Social Card of Spatie's Browsershot

Convert a webpage to an image or pdf using headless Chrome

Latest Version MIT Licensed run-tests Total Downloads

The package can convert a webpage to an image or pdf. The conversion is done behind the scenes by Puppeteer which controls a headless version of Google Chrome.

Here's a quick example:

use Spatie\Browsershot\Browsershot;

// an image will be saved

It will save a pdf if the path passed to the save method has a pdf extension.

// a pdf will be saved

You can also use an arbitrary html input, simply replace the url method with html:

Browsershot::html('<h1>Hello world!!</h1>')->save('example.pdf');

If your HTML input is already in a file locally use the :


Browsershot also can get the body of an html page after JavaScript has been executed:

Browsershot::url('')->bodyHtml(); // returns the html of the body

If you wish to retrieve an array list with all of the requests that the page triggered you can do so:

$requests = Browsershot::url('')

foreach ($requests as $request) {
    $url = $request['url']; //

To use Chrome's new headless mode pass the newHeadless method:


Support us

Learn how to create a package like this one, by watching our premium video course:

Laravel Package training

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.


All documentation is available on our documentation site.


Please see CONTRIBUTING for details.


If you've found a bug regarding security please mail instead of using the issue tracker.


If you're not able to install Node and Puppeteer, take a look at v2 of browsershot, which uses Chrome headless CLI to take a screenshot. v2 is not maintained anymore, but should work pretty well.

If using headless Chrome does not work for you take a look at at v1 of this package which uses the abandoned PhantomJS binary.


And a special thanks to Caneco for the logo ✨


The MIT License (MIT). Please see License File for more information.