Back to blog

Capture guides

How to Convert a Website to PNG (URL to PNG Image via API)

July 7, 2026 · 6 min read · Grabbit Team

How to Convert a Website to PNG (URL to PNG Image via API)

To convert a website to a PNG, send the page URL to a screenshot API with the format set to png, and it returns a hosted PNG image. One HTTP request in, one image URL out. The headless browser that does the rendering runs in the cloud, so there is no converter to install and no local Chrome to babysit.

That is the fast path. Below is the whole request, when PNG is actually the right format to pick, and how to get the full-page and dimension options right.

The quick answer

If you just want a URL turned into a PNG from your code, this is the whole thing:

curl https://api.grabbit.live/v1/grabs \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "width": 1280,
    "height": 720,
    "format": "png"
  }'

The response is JSON with a hosted image_url:

{
  "id": "grb_01jx...",
  "status": "done",
  "target_url": "https://example.com",
  "image_url": "https://cdn.grabbit.live/grabs/grb_01jx....png",
  "width": 1280,
  "height": 720,
  "format": "png",
  "bytes": 84210,
  "execution_ms": 940,
  "created_at": "2026-07-07T09:00:00.000Z"
}

Store that image_url, embed it, or hand it to another service. PNG is the default format, so if you leave format off entirely you still get a PNG back.

Manual versus programmatic

"Convert a website to PNG" splits into two different jobs, and the SERP for this term mixes them, so it is worth being clear about which one you have.

Manual, one-off. You are looking at a page and want to save it as a PNG. Your browser already does this. In Chrome or Edge, open the command menu with Ctrl+Shift+P (Cmd+Shift+P on Mac), type "screenshot," and choose "Capture full size screenshot." No tool required. Free online converters like CloudConvert or Web2PDF Convert do the same thing through a form: paste a URL, download the PNG.

Programmatic, repeatable. You need to turn websites into PNGs from code, on a schedule, or across many URLs. This is where the manual path falls apart: you cannot click a browser menu inside a cron job, a CI pipeline, or a webhook handler. You need an endpoint you can call.

This guide is about the second job. If you only need a one-off image, use the browser shortcut above and move on.

Converting a website to PNG with an API

For anything repeatable, a screenshot API is the shortest path. You already saw the curl call. Here is the same request in a couple of languages, since "how do I do this in my stack" is the real question.

Python, using requests:

import requests

resp = requests.post(
    "https://api.grabbit.live/v1/grabs",
    headers={"Authorization": "Bearer sk_live_..."},
    json={
        "url": "https://example.com",
        "width": 1280,
        "height": 720,
        "format": "png",
    },
)
data = resp.json()
print(data["image_url"])

Node.js, using the built-in fetch:

const resp = await fetch('https://api.grabbit.live/v1/grabs', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer sk_live_...',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    url: 'https://example.com',
    width: 1280,
    height: 720,
    format: 'png',
  }),
});
const data = await resp.json();
console.log(data.image_url);

Every one of these is a plain HTTP call. No chromedriver, no 300 MB Chromium download, no async browser session to tear down afterward. That is the whole reason to reach for an API over a local converter: the rendering machinery lives somewhere else.

When PNG is the right format (and when it is not)

The format field takes png, jpeg, or webp, and "website to png" is a deliberate choice, not just a default. PNG earns its place in three situations:

  • You need lossless output. PNG never introduces compression artifacts, so text stays crisp and flat color regions stay flat. WebP and JPEG both trade some fidelity for smaller files.
  • You need a stable baseline. For a visual regression test, the baseline image has to be byte-stable so a real UI change is the only thing that produces a diff. Lossy formats can shift a few pixels between renders and create false positives. PNG does not.
  • You need transparency. PNG supports an alpha channel. A full-page website capture is opaque, so this matters most when you capture a specific element with a transparent background using the selector option.

If none of those apply and you are storing thousands of renders, WebP is the smaller choice at the same visual quality. The webpage to image guide covers that format tradeoff in more depth. Switching is a one-word change in the request body, so you can measure the file-size difference on your own pages before committing.

Capturing the full page, not just the viewport

By default a capture stops at the viewport height you request. To convert the entire scrollable page into one tall PNG, set full_page to true:

curl https://api.grabbit.live/v1/grabs \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "width": 1280,
    "full_page": true,
    "format": "png"
  }'

With full_page on, height is ignored and the render extends to the bottom of the document. This is the option you want for archiving a whole article, a long landing page, or anything below the fold. The full-page screenshot guide covers the edge cases (lazy loading, sticky headers) in more depth.

width must be between 320 and 1920 pixels; height between 240 and 1080. If the page renders content client-side after load, add "delay_ms": 1500 to wait before the capture fires, or "selector": "#main" to wait for a specific element to appear.

When a local converter is the better call

An API is not always the answer. Render locally instead when:

  • You already have a full HTML string, not a URL. If the markup lives in your app and never gets served at an address, a local page.screenshot() in Puppeteer avoids a round trip. See HTML to image for that pattern, including the trick of hosting your template at a URL and then capturing it.
  • You are doing a single manual capture. Use the browser shortcut from earlier.
  • You cannot make outbound requests. In an air-gapped environment an API is off the table, so a bundled headless browser is the only option.

For everything else, especially anything that runs on a schedule or in CI, the API path keeps your deployment small and removes an entire class of "it works locally but not in the container" failures.

Next steps

The automated screenshots guide covers scheduling, async jobs, and webhooks for turning many URLs into PNGs in a pipeline. For a broader look at format choices, see webpage to image, and for capturing pages that extend past the viewport, full-page screenshots.

FAQ

How do I convert a website to a PNG?
Send the page URL to a screenshot API and it returns a hosted PNG. One POST request with the target URL and format set to png gives you back an image_url pointing at a lossless render of the page. The headless browser runs in the cloud, so there is nothing to install locally and nothing to keep alive.
How do I save a website as a PNG for free?
For a single manual capture, your browser already does it. In Chrome or Edge, open the command menu with Ctrl+Shift+P (Cmd+Shift+P on Mac), type screenshot, and choose Capture full size screenshot. For anything repeatable from code, a screenshot API is the shortest path, and a test-environment key renders free placeholder images so you can wire it up before adding a card.
Should I use PNG or WebP for a website screenshot?
Use PNG when you need lossless output, transparency, or a stable baseline for visual regression tests, because PNG never introduces compression artifacts. Use WebP when file size is the priority, since it produces a smaller file at the same visual quality. A screenshot API lets you pick per request with a format field, so switching is a one-word change.
Can I convert a full webpage, not just the visible part, to a PNG?
Yes. Set full_page to true and the capture extends to the full scrollable height of the page instead of stopping at the viewport. The result is one tall PNG that includes everything below the fold, exactly as it renders in a real browser.
How do I convert a URL to a PNG programmatically?
POST the URL to a screenshot API from any language that can make an HTTP request. Pass the URL and format png in the JSON body and your API key in the Authorization header. The response includes an image_url you can store or serve directly. No browser binary, no chromedriver, no local converter to maintain.

Capture any website with one API call

Get a free test key and capture your first screenshot in two minutes.

Written by

Grabbit Team

Screenshots as a service

The team behind Grabbit, the screenshot API for developers and AI agents. We write about web capture, rendering, and automating screenshots at scale.

Keep reading