About the cURL to Code Converter
This converter turns a curl command into equivalent code for JavaScript fetch, Python requests, Go net/http and PHP's curl extension. It parses the command the way a shell would: single and double quotes, backslash escapes, \ line continuations, bash $'...' strings, and the ^ escapes of Windows cmd. That means "Copy as cURL" from Chrome (bash or cmd) and Firefox pastes straight in.
It understands the URL, -X, -H, -d, --data-raw, --data-binary, --data-urlencode, --json, -F (including @file uploads), -u, -b, -A, -e, -G, -I, -L, -k and --compressed. Output-only flags such as -s, -v and -o are listed as ignored, and anything it can't convert, such as --proxy, appears as a warning instead of disappearing silently.
How to use it
- Paste a curl command, or load one of the examples.
- Pick a language tab and copy the code.
- Check the warnings and notes under the request summary.
- Use "Open in HTTP Request Builder" to send the request from this site (only the method and URL carry over).
Examples
- A GET with a header: one header, no body.
- A JSON POST:
--jsonsets the method, body and both JSON headers. - A query built with -G: the data moves into the URL as
q=red%20shoes.
Common questions
Why is the method POST when I didn't pass -X?
curl switches to POST as soon as there is a body (-d, --json, -F), unless -G moves the data into the query string. -I makes it HEAD.
Why does the fetch code mention dropped headers?
Browsers refuse to let scripts set headers such as Cookie, Origin, Referer and sec-*. The same code sends them from Node.js.
Does it send my command anywhere?
No. Parsing and code generation run entirely in your browser.
Related tools
- HTTP Request Builder: send the request and inspect the response.
- JSON Formatter & Validator: tidy a request or response body.
- Webhook Tester & Inspector: see exactly what the generated code sends.