Getting a curl command from your browser
- Open the browser's developer tools (F12) and go to the Network tab.
- Perform the action on the page, then right-click the request.
- 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
| Option | Converted to |
|---|---|
-X, --request | The HTTP method |
-H, --header | Request headers |
-d, --data, --data-raw, --data-binary | The request body; JSON bodies become real objects in Python, JavaScript and axios |
--json | A JSON body with the right Content-Type and Accept headers |
--data-urlencode, -G | URL-encoded form data, or query parameters with -G |
-F, --form | Multipart form fields and file uploads |
-u, --user | Basic authentication |
-b, --cookie, -A, -e | Cookie, User-Agent and Referer headers |
-L, -m, --connect-timeout | Following redirects and timeouts |
-I, --head | A 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.