cURL to Code

Paste a curl command, for example from your browser's Copy as cURL or an API's documentation, and get the same request as code in your language. Headers, JSON bodies, form uploads, basic auth, cookies, timeouts and redirects are converted.

curl command

    

Getting a curl command from your browser

  1. Open the browser's developer tools (F12) and go to the Network tab.
  2. Perform the action on the page, then right-click the request.
  3. Choose Copy › Copy as cURL. Both the bash and the Windows (cmd) versions work here.

Browser copies include every header the browser sent, such as sec-ch-ua and accept-language. Most APIs only need Authorization, Content-Type and perhaps a cookie, so trim the rest from the generated code.

Supported curl options

OptionConverted to
-X, --requestThe HTTP method
-H, --headerRequest headers
-d, --data, --data-raw, --data-binaryThe request body; JSON bodies become real objects in Python, JavaScript and axios
--jsonA JSON body with the right Content-Type and Accept headers
--data-urlencode, -GURL-encoded form data, or query parameters with -G
-F, --formMultipart form fields and file uploads
-u, --userBasic authentication
-b, --cookie, -A, -eCookie, User-Agent and Referer headers
-L, -m, --connect-timeoutFollowing redirects and timeouts
-I, --headA HEAD request

Output-only options such as -s, -v, -o and -w are ignored because they don't change the request. Anything that can't be reproduced exactly, such as reading a body from a file or -k, is listed under the code.

Keep secrets out of shared code

Copied commands often include live tokens and session cookies. The conversion happens entirely in your browser, but check the generated code before you commit it or paste it into a chat. Move tokens into environment variables or a secrets manager.

Frequently asked questions

Is my curl command sent to a server?

No. It's parsed and converted in your browser, so tokens and cookies in the command stay on your computer.

Why does the code follow redirects when curl didn't, or the other way round?

curl only follows redirects with -L. The generated code matches that where the library allows it; the Spring RestClient tab notes where the default differs.

Does it handle multi-line commands?

Yes. Commands split over several lines with a backslash (bash), a caret (Windows cmd) or a backtick (PowerShell) are joined automatically.

Which Java version does the code need?

The java.net.http HttpClient code needs Java 11 or later, and the text blocks used for JSON bodies need Java 15 or later. The Spring code needs Spring Framework 6.1 or later (Spring Boot 3.2+) for RestClient.

Can it convert code back to curl?

Not yet. Browser developer tools can copy any request as curl, which you can then paste here.