FREE TOOL

curl to Java Converter

Paste a curl command, get working Java code using the built-in java.net.http.HttpClient — headers, bodies, auth, and redirects translated. Runs in your browser, no signup.

Conversion runs entirely in your browser — the command (and any tokens or cookies in it) is never sent to a server. Tip: DevTools Network tab → right-click a request → Copy as cURL.

Scraping a real site? Skip the blocks

Hand-copied curl headers go stale, and sites still block datacenter IPs. The same request through the WebScraping.AI API gets rotating proxies, headless Chrome rendering, and unblocking in one call — your custom headers and cookies are forwarded via the headers parameter:

2,000 free API credits · No credit card required

What the generated Java code does

The output targets java.net.http.HttpClient, standard since Java 11 — no Maven dependency needed: the builder pattern with .uri(URI.create(…)), a .header(…) call per -H, bodies via HttpRequest.BodyPublishers.ofString, -u as a precomputed Basic Authorization header, and -L as .followRedirects(HttpClient.Redirect.NORMAL) on the client builder — unlike curl, HttpClient does not follow redirects by default.

Multipart uploads are the one real gap: java.net.http has no built-in multipart body, so the converter marks the spot and suggests OkHttp rather than generating fragile boundary boilerplate.

Frequently asked questions

How do I convert a curl command to Java?

Paste the command into the converter above — it outputs java.net.http.HttpClient code instantly, in your browser. Headers, cookies, request bodies, basic auth, and redirect handling are translated. Nothing you paste is sent to a server.

HttpClient, OkHttp, or HttpURLConnection?

java.net.http.HttpClient (Java 11+) is the modern standard-library choice and needs no dependency — that's what the converter generates. OkHttp adds multipart bodies, interceptors, and HTTP/2 niceties. HttpURLConnection is legacy; avoid it in new code.

Which Java version does the generated code need?

Java 11 or newer — java.net.http shipped in 11, and every LTS since (17, 21) includes it. On Java 8 you'd need OkHttp or Apache HttpClient instead; the request structure translates one-to-one.

The Java code gets a 403 but curl works — why?

The JVM's TLS fingerprint differs from curl's and from real browsers, and anti-bot systems also weigh IP reputation and JavaScript challenges. Copied session cookies expire too. The WebScraping.AI API runs the same request through rotating proxies and real headless Chrome — one call from Java.

Related

Java code ready? Make it unblockable.

Same request, plus rotating proxies, headless Chrome, and JS rendering — one API call from Java.

Icon