Skip to content
Webmaster Tools
Inspect & debugcURL Converter

cURL to Code Converter

curl to fetch, Python, Go and PHP.

Examples:
bash, zsh or Windows cmd

      
Parsed Can't parse Runs in your browser

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

  1. Paste a curl command, or load one of the examples.
  2. Pick a language tab and copy the code.
  3. Check the warnings and notes under the request summary.
  4. Use "Open in HTTP Request Builder" to send the request from this site (only the method and URL carry over).

Examples

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.