René's URL Explorer Experiment


Title: Take a website screenshot in Java — working code

Open Graph Title: Take a website screenshot in Java — working code

X Title: Take a website screenshot in Java — working code

Description: Screenshot any website in Java: a full-page PNG from real Chrome, the async variant with a webhook, and retries. Tested code.

Open Graph Description: Screenshot any website in Java: a full-page PNG from real Chrome, the async variant with a webhook, and retries. Tested code.

X Description: Screenshot any website in Java: a full-page PNG from real Chrome, the async variant with a webhook, and retries. Tested code.

Mail addresses
contact@urlpipe.dev

Opengraph URL: https://urlpipe.dev/code/java/screenshot

direct link

Domain: urlpipe.dev


Hey, it has json ld scripts:
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://urlpipe.dev/#organization","name":"URLpipe","url":"https://urlpipe.dev","logo":"https://urlpipe.dev/icon.png","sameAs":["https://github.com/URLpipe"],"founder":{"@type":"Person","name":"Roger Campos","url":"https://rogercampos.com"}},{"@type":"WebSite","@id":"https://urlpipe.dev/#website","url":"https://urlpipe.dev","name":"URLpipe","publisher":{"@id":"https://urlpipe.dev/#organization"}}]}
{"@context":"https://schema.org","@graph":[{"@type":"TechArticle","@id":"https://urlpipe.dev/code/java/screenshot#article","headline":"Take a website screenshot in Java — working code","description":"Screenshot any website in Java: a full-page PNG from real Chrome, the async variant with a webhook, and retries. Tested code.","url":"https://urlpipe.dev/code/java/screenshot","mainEntityOfPage":"https://urlpipe.dev/code/java/screenshot","datePublished":"2026-09-24","dateModified":"2026-09-24","author":{"@type":"Person","name":"Roger Campos","url":"https://rogercampos.com"},"publisher":{"@id":"https://urlpipe.dev/#organization"},"image":"https://urlpipe.dev/og-image.png"},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"Why is the screenshot response Base64 and not an image?","acceptedAnswer":{"@type":"Answer","text":"So the same body works in JSON, in a webhook payload and in an  data URI. Decode it with Base64.getDecoder(), or skip decoding and use the X-Result-Url header, a direct link to the image."}},{"@type":"Question","name":"How do I take a mobile screenshot?","acceptedAnswer":{"@type":"Answer","text":"Set screenshot_options.viewport_width to a phone width such as 390 and device_scale_factor to 2 or 3. The viewport can be anything from 320 to 1920 pixels wide."}},{"@type":"Question","name":"Can I screenshot one element instead of the whole page?","acceptedAnswer":{"@type":"Answer","text":"Yes: screenshot_options takes a CSS selector and captures just that element. A selector that matches nothing is a 422, and costs nothing."}},{"@type":"Question","name":"Do I need an SDK to call URLpipe from Java?","acceptedAnswer":{"@type":"Answer","text":"No SDK. HttpClient is in the JDK; the programs that read JSON add Gson, one jar, because the JDK has no parser."}}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://urlpipe.dev/"},{"@type":"ListItem","position":2,"name":"Code recipes","item":"https://urlpipe.dev/code"},{"@type":"ListItem","position":3,"name":"Java","item":"https://urlpipe.dev/code/java"},{"@type":"ListItem","position":4,"name":"Take a screenshot of a website in Java","item":"https://urlpipe.dev/code/java/screenshot"}]},{"@type":"HowTo","name":"Take a screenshot of a website in Java","description":"To take a screenshot of a website in Java, POST its URL to https://urlpipe.dev/screenshot with sync set to true, decode the Base64 body with Base64.getDecoder() and write the bytes to a .png file. It is a full-page capture from real Chrome for 1 credit; leave sync out and the result goes to your webhook instead.","url":"https://urlpipe.dev/code/java/screenshot","tool":[{"@type":"HowToTool","name":"Java 17+"}],"step":[{"@type":"HowToStep","name":"Before you start","text":"Java 17 or later: java.net.http is in the JDK. The async and error-handling programs read JSON, and the JDK has no parser, so those use Gson — one jar, no dependencies of its own. In a Maven or Gradle build add com.google.code.gson:gson:2.13.1; to try a file on its own, download the jar next to it.","url":"https://urlpipe.dev/code/java/screenshot#setup"},{"@type":"HowToStep","name":"Save a screenshot as a PNG file","text":""sync": true keeps the request open until the result is ready. BodyHandlers.ofString() reads the whole body as text, decoded with the charset the response names. HttpClient does not throw on a 4xx or 5xx, so check statusCode(). The body is Base64 text; Base64.getDecoder() gives the bytes back.","url":"https://urlpipe.dev/code/java/screenshot#sync"},{"@type":"HowToStep","name":"The async variant: a token, a webhook and a poll","text":"Leave out sync and the answer is a token, straight away. One HttpClient is shared by every call — it holds the connection pool, so build it once — and a switch expression covers the answers GET /result/:token can give.","url":"https://urlpipe.dev/code/java/screenshot#async"},{"@type":"HowToStep","name":"Handle errors and retries","text":"A checked URLpipeException makes the caller decide what a refusal means. firstValueAsLong reads Retry-After without a parse of your own, and a body that is not JSON (a proxy in front of the API can answer in HTML) falls back to an empty object.","url":"https://urlpipe.dev/code/java/screenshot#errors"}]}]}

view-transitionsame-origin
csrf-paramauthenticity_token
csrf-tokenwEdZga4cBWbpNW2HIGYF9dz9fwMIfVI_jkuk_K4nkmQfqeTqb3s-EiU69q1X4IFYO4dOYcQcYD0K0MlSASt9pA
csp-nonce702cb3c75fe81bf1d67f3e3875054fd9
og:typewebsite
og:site_nameURLpipe
og:localeen_US
og:imagehttps://urlpipe.dev/og-image.png
og:image:width1200
og:image:height630
og:image:altURLpipe — URL in. Clean data out.
twitter:cardsummary_large_image
twitter:imagehttps://urlpipe.dev/og-image.png
twitter:image:altURLpipe — URL in. Clean data out.
theme-color#3b82f6

Links:

Skip to main contenthttps://urlpipe.dev/code/java/screenshot#main
URLpipehttps://urlpipe.dev/
Web scraping APIhttps://urlpipe.dev/web-scraping-api
URL to Markdown APIhttps://urlpipe.dev/url-to-markdown-api
MCP serverhttps://urlpipe.dev/mcp-server
Screenshot APIhttps://urlpipe.dev/screenshot-api
Lighthouse APIhttps://urlpipe.dev/lighthouse-api
Metadata APIhttps://urlpipe.dev/metadata-api
Console APIhttps://urlpipe.dev/console-api
Rendered HTML APIhttps://urlpipe.dev/rendered-html-api
URL to PDF APIhttps://urlpipe.dev/url-to-pdf-api
Website technology lookup APIhttps://urlpipe.dev/website-technology-lookup-api
Structured data extraction APIhttps://urlpipe.dev/structured-data-extraction-api
Keyword extraction APIhttps://urlpipe.dev/keyword-extraction-api
URL summarization APIhttps://urlpipe.dev/url-summarization-api
Web access for AI agentshttps://urlpipe.dev/use-cases/ai-agents
Web pages into a RAG pipelinehttps://urlpipe.dev/use-cases/rag-ingestion
Link previews and unfurlshttps://urlpipe.dev/use-cases/link-previews
Monitoring client websiteshttps://urlpipe.dev/use-cases/client-site-monitoring
Monitoring pages for changeshttps://urlpipe.dev/use-cases/content-monitoring
Archiving pages as screenshotshttps://urlpipe.dev/use-cases/visual-archiving
URL features inside a multi-tenant apphttps://urlpipe.dev/use-cases/multi-tenant-apps
Free toolshttps://urlpipe.dev/tools
Docshttps://urlpipe.dev/docs
Pricinghttps://urlpipe.dev/pricing
Guideshttps://urlpipe.dev/guides
Code recipeshttps://urlpipe.dev/code
Glossaryhttps://urlpipe.dev/glossary
Researchhttps://urlpipe.dev/research
Comparehttps://urlpipe.dev/compare
Changeloghttps://urlpipe.dev/changelog
Engineering noteshttps://urlpipe.dev/notes
Sign inhttps://urlpipe.dev/auth/session/new
Start freehttps://urlpipe.dev/auth/sign-up/new
Web scraping APIhttps://urlpipe.dev/web-scraping-api
URL to Markdown APIhttps://urlpipe.dev/url-to-markdown-api
MCP serverhttps://urlpipe.dev/mcp-server
Screenshot APIhttps://urlpipe.dev/screenshot-api
Lighthouse APIhttps://urlpipe.dev/lighthouse-api
Metadata APIhttps://urlpipe.dev/metadata-api
Console APIhttps://urlpipe.dev/console-api
Rendered HTML APIhttps://urlpipe.dev/rendered-html-api
URL to PDF APIhttps://urlpipe.dev/url-to-pdf-api
Website technology lookup APIhttps://urlpipe.dev/website-technology-lookup-api
Structured data extraction APIhttps://urlpipe.dev/structured-data-extraction-api
Keyword extraction APIhttps://urlpipe.dev/keyword-extraction-api
URL summarization APIhttps://urlpipe.dev/url-summarization-api
Web access for AI agentshttps://urlpipe.dev/use-cases/ai-agents
Web pages into a RAG pipelinehttps://urlpipe.dev/use-cases/rag-ingestion
Link previews and unfurlshttps://urlpipe.dev/use-cases/link-previews
Monitoring client websiteshttps://urlpipe.dev/use-cases/client-site-monitoring
Monitoring pages for changeshttps://urlpipe.dev/use-cases/content-monitoring
Archiving pages as screenshotshttps://urlpipe.dev/use-cases/visual-archiving
URL features inside a multi-tenant apphttps://urlpipe.dev/use-cases/multi-tenant-apps
Free toolshttps://urlpipe.dev/tools
Docshttps://urlpipe.dev/docs
Pricinghttps://urlpipe.dev/pricing
Guideshttps://urlpipe.dev/guides
Code recipeshttps://urlpipe.dev/code
Glossaryhttps://urlpipe.dev/glossary
Researchhttps://urlpipe.dev/research
Comparehttps://urlpipe.dev/compare
Changeloghttps://urlpipe.dev/changelog
Engineering noteshttps://urlpipe.dev/notes
Start freehttps://urlpipe.dev/auth/sign-up/new
Sign inhttps://urlpipe.dev/auth/session/new
Roger Camposhttps://rogercampos.com
Start freehttps://urlpipe.dev/auth/sign-up/new
See the APIhttps://urlpipe.dev/#endpoints
/screenshothttps://urlpipe.dev/docs/screenshot
screenshot_optionshttps://urlpipe.dev/docs/screenshot#options
Screenshot any website from its URLPaste a link and get a sharp PNG of the page as it opens — JavaScript executed, exactly as a real browser would draw it. Great for previews, thumbnails and visual QA.Try it freehttps://urlpipe.dev/tools/website-screenshot
/screenshot API docshttps://urlpipe.dev/docs/screenshot
Pythonhttps://urlpipe.dev/code/python/screenshot
Node.jshttps://urlpipe.dev/code/node/screenshot
PHPhttps://urlpipe.dev/code/php/screenshot
Rubyhttps://urlpipe.dev/code/ruby/screenshot
Gohttps://urlpipe.dev/code/go/screenshot
C#https://urlpipe.dev/code/csharp/screenshot
cURLhttps://urlpipe.dev/code/curl/screenshot
every Java recipehttps://urlpipe.dev/code/java
Extracting page metadatahttps://urlpipe.dev/guides/extract-open-graph-metadata
Screenshot one element of a page by CSS selectorhttps://urlpipe.dev/tools/website-screenshot/element
Take a screenshot of a website in Node.jshttps://urlpipe.dev/code/node/screenshot
Screenshots capture the whole pagehttps://urlpipe.dev/changelog/full-page-screenshots
URLpipe vs Microlinkhttps://urlpipe.dev/compare/urlpipe-vs-microlink
Take a screenshot of a website in Rubyhttps://urlpipe.dev/code/ruby/screenshot
All of code recipeshttps://urlpipe.dev/code
Start freehttps://urlpipe.dev/auth/sign-up/new
URLpipehttps://urlpipe.dev/
Web scraping APIhttps://urlpipe.dev/web-scraping-api
URL to Markdown APIhttps://urlpipe.dev/url-to-markdown-api
MCP serverhttps://urlpipe.dev/mcp-server
Screenshot APIhttps://urlpipe.dev/screenshot-api
Lighthouse APIhttps://urlpipe.dev/lighthouse-api
Metadata APIhttps://urlpipe.dev/metadata-api
Console APIhttps://urlpipe.dev/console-api
Rendered HTML APIhttps://urlpipe.dev/rendered-html-api
URL to PDF APIhttps://urlpipe.dev/url-to-pdf-api
Website technology lookup APIhttps://urlpipe.dev/website-technology-lookup-api
Structured data extraction APIhttps://urlpipe.dev/structured-data-extraction-api
Keyword extraction APIhttps://urlpipe.dev/keyword-extraction-api
URL summarization APIhttps://urlpipe.dev/url-summarization-api
Free toolshttps://urlpipe.dev/tools
Pricinghttps://urlpipe.dev/pricing
Docshttps://urlpipe.dev/docs
Client librarieshttps://urlpipe.dev/docs/client-libraries
Guideshttps://urlpipe.dev/guides
Code recipeshttps://urlpipe.dev/code
Use caseshttps://urlpipe.dev/use-cases
Integrationshttps://urlpipe.dev/integrations
Glossaryhttps://urlpipe.dev/glossary
Researchhttps://urlpipe.dev/research
Engineering noteshttps://urlpipe.dev/notes
Changeloghttps://urlpipe.dev/changelog
llms.txthttps://urlpipe.dev/llms.txt
All comparisonshttps://urlpipe.dev/compare
URLpipe vs Firecrawlhttps://urlpipe.dev/compare/urlpipe-vs-firecrawl
URLpipe vs Jina Readerhttps://urlpipe.dev/compare/urlpipe-vs-jina-reader
Best HTML-to-Markdown APIshttps://urlpipe.dev/best-html-to-markdown-apis
Jina Reader alternativeshttps://urlpipe.dev/alternatives/jina-reader
Microlink alternativeshttps://urlpipe.dev/alternatives/microlink
ScreenshotOne alternativeshttps://urlpipe.dev/alternatives/screenshotone
Abouthttps://urlpipe.dev/about
Securityhttps://urlpipe.dev/security
Statushttps://urlpipe.dev/status
GitHubhttps://github.com/URLpipe
Privacyhttps://urlpipe.dev/privacy
Termshttps://urlpipe.dev/terms
Sign inhttps://urlpipe.dev/auth/session/new
Legal noticehttps://urlpipe.dev/terms#legal-notice
Roger Camposhttps://rogercampos.com

Viewport: width=device-width,initial-scale=1


URLs of crawlers that visited me.