cURL to Java Converter
Convert a curl command to Java HttpClient or OkHttp code that compiles. Gzip, file uploads and headers Java refuses are handled, and every change is listed.
Loading tool…
How it works
Copy the request as cURL
In Chrome, Edge or Firefox DevTools, right-click a request in the Network panel and choose Copy as cURL. Bash and Windows cmd copies both work.
Pick HttpClient or OkHttp
HttpClient ships with Java 11. OkHttp is a separate library. JSON bodies become text blocks (Java 15+); untick that for Java 11.
Run it
Save it as Main.java. HttpClient code runs with java Main.java. OkHttp code needs its jars on the classpath, or Maven or Gradle.
Which headers does HttpClient refuse?
Connection, Content-Length, Expect, Host and Upgrade: setting one throws IllegalArgumentException, so the code leaves them out and says so.
Is a gzip response decompressed?
HttpClient does not do it, so with --compressed the code asks for gzip and unzips it. OkHttp unzips gzip itself.
What happens to redirects?
With -L, HttpClient code follows up to 50 like curl (or your --max-redirs); OkHttp stops at 20. Without -L, neither follows.
What about files and -k?
-d @file and -F file=@path are read when the code runs. -k is flagged, never turned into code that trusts every certificate. Anything not converted is listed.
Is my command sent anywhere?
No. Conversion runs in this tab. Copied commands often carry cookies and tokens, so treat the code like a password.
Request blocked?
Browser Use cloud browsers run a maintained Chromium fork with residential proxies.