cURL to Code Converter

Convert curl commands to fetch, axios, Python requests and Go code.

The curl to Code converter reads a curl command and writes equivalent code for fetch, axios, Python requests or Go net/http. It understands headers, request bodies, basic auth, form fields and common flags. Use it to turn an example from API docs or browser DevTools into code you can start from.

What does converting curl to code involve?

curl describes an HTTP request in a compact command: a URL, a method with -X, headers with -H, a body with -d, and options such as -u for basic authentication or -F for multipart form fields. To convert it, the command text is first split into arguments the way a shell does, honouring single quotes, double quotes and line continuations. Then each flag is mapped to a request property: method, URL, headers, body, credentials and form fields. If a body is present and no method is given, curl uses POST, and a body without a Content-Type is sent as application/x-www-form-urlencoded. The converter follows these rules and prints code for the chosen target. Flags that only affect curl's own behaviour, such as -s or -k, have no code equivalent and are ignored.

How to use cURL to Code Converter

  1. Paste the curl command Put your command into the curl command box. Multi-line commands with backslashes are fine.
  2. Pick a target Press fetch, axios, Python requests or Go. The Code box updates for the chosen language.
  3. Check the result Look over method, URL, headers and body in the generated code.
  4. Copy the Code Use the copy button on the Code box and paste it into your project. Clear empties both boxes.

Frequently asked questions

Which curl flags are supported?

Method (-X), headers (-H), data options (-d, --data-raw, --data-binary, --data-urlencode), --json, -u, -F, --url, -A, -b, -e, -I, -G and the long forms of these. Others such as -s, -k or -L are ignored.

Does it send the request?

No. It only converts text to code, and nothing is sent anywhere.

Why is my method POST when I did not set one?

curl uses POST by default when a body or form is present, and the converter follows that. With -I or --head the method is HEAD.

Does --data-urlencode encode the value?

No. The data is used as typed and the code does not apply curl's encoding step, so encode the value yourself if needed.

Are multiple -d options joined?

Yes, with & between them, which matches how curl combines them.

Is it safe to paste a command with a token?

The text is processed in the page and not sent anywhere. Even so, replace real secrets with placeholders before sharing the generated code.