UtilDojo

Popular

Menu

cURL to Code Converter — fetch, axios, Python, Go, PHP

  • This tool runs entirely in your browser. Nothing you enter or upload is sent to a server.

cURL command

Code

Converted code appears here.

About this tool

Paste a curl command — for example one copied from the browser DevTools Network tab with Copy as cURL — and get equivalent code for JavaScript (fetch or axios), Python requests, Go net/http or PHP. The result updates as you edit the command.

The parser understands quoted arguments and line continuations, bundled flags like -sSL, -X, -H, -d and --data-raw, --data-urlencode, --json, -G, -u for basic auth, -b cookies and -F multipart uploads. JSON bodies are written as real object literals (a dict in Python) instead of an escaped string, and flags that do not change the request, such as -L, -k and --compressed, are ignored.

For example, a POST to /v1/orders with an Authorization header and the body {"item":"chai","qty":2} becomes a fetch call with body: JSON.stringify({ "item": "chai", "qty": 2 }), or in Python a requests.request('POST', url, headers=headers, json=payload) call, where the JSON content type is left to the library. A command with -u admin:secret and -F file=@photo.png becomes a requests call with files= and auth=('admin', 'secret').

The conversion runs entirely in your browser, so tokens and API keys in your command are never sent anywhere. Replace placeholders and file paths in the generated code before using it. Treat the output as a starting point: it makes a single request and prints the status and text, with no retries, error handling or timeouts. A command that does not start with curl is rejected, and anything the tool cannot express, such as a file body, is listed as a warning above the code.

Frequently asked questions

How do I get a curl command from my browser?

Open DevTools, go to the Network tab, right-click a request and choose Copy → Copy as cURL, then paste it here.

Is it safe to paste a command with a token in it?

Yes. Nothing leaves your browser, but treat the generated code like any other secret and do not commit tokens to source control.

What happens with -d @file.json or -F file=@photo.png?

Files on your disk cannot be read in the browser. The converter keeps the file name in a comment or open() call and shows a note, so you can swap in the real contents.

Why is a Content-Type header added?

When you use -d without a Content-Type, curl sends application/x-www-form-urlencoded. The converter reproduces that so the generated code behaves the same as your command.

Does it run the request?

No. It only converts text. Nothing is sent to the API, so you can inspect and change the code before running it yourself.

Related tools