Website screenshot API

Website Screenshot API for PNG, JPEG, and WebP

Capture public URLs or raw HTML as full-page images or selected elements with Chromium and a simple server-side request.

Updated

Key outcomes

Choose the right capture mode

Use fullpage when you need the entire scrollable document, such as an archive or design review. Use css_selector when you need a specific chart, product card, receipt, or social preview.

A selector capture should target one stable element. Prefer a dedicated data attribute over styling classes that may change during a redesign.

Choose PNG, JPEG, or WebP

PNG is lossless and suits UI captures with text. JPEG can reduce file size for photographic pages and supports the quality option. WebP is useful for modern image pipelines that prioritize compact output.

  • Use /convert/png for crisp interface text.
  • Use /convert/jpeg and quality for photographic content.
  • Use /convert/webp for compact delivery in modern applications.

Capture a specific page element

The example waits for network activity and captures only the element marked with a stable data attribute. The response contains binary PNG data.

capture-chart.jsJavaScript
const response = await fetch('https://api.pixeltopdf.com/convert/png', {
  method: 'POST',
  headers: {
    'X-API-Key': process.env.PIXELTOPDF_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    source: 'https://example.com/public-dashboard',
    css_selector: '[data-export-chart]',
    wait_for_network: true,
    delay: 500,
    timeout: 30,
    filename: 'weekly-chart.png',
  }),
});

if (!response.ok) throw new Error(`Screenshot failed: ${response.status}`);
const png = Buffer.from(await response.arrayBuffer());

Make automated screenshots deterministic

Disable animations in a conversion-only stylesheet, use stable viewport-aware layouts, and remove timestamps or random content when images are compared automatically. Wait only as long as the page genuinely needs.

For authenticated or personalized components, render their HTML on your server and send it directly. Do not embed session credentials in a screenshot URL.

The quality option applies to JPEG output. PNG is lossless, so its endpoint does not use JPEG quality settings.

Frequently asked questions

Can the API capture a full webpage?

Yes. Set fullpage to true on an image conversion request to include the entire scrollable page.

Can I screenshot only one element?

Yes. Set css_selector to a stable selector for the element you want to capture.

Which screenshot format should I choose?

Choose PNG for lossless UI captures, JPEG for photographic pages where adjustable quality matters, or WebP for compact modern delivery.

Continue building

Build your first conversion

Start with 75 free credits each month. No credit card required.