Skip to content
Jellykit

cURL to Code Converter

Turn a curl command into JavaScript fetch, Axios, Python requests, Go or PHP code, with headers, body and auth carried over.

  • Runs on your device
Loading tool

About cURL to Code Converter

Paste a curl command, for example one copied from your browser's developer tools with "Copy as cURL (bash)", and get the same request written for fetch, Axios, Python requests, Go net/http or PHP's curl extension. The method, URL, headers, body, form fields and file uploads, basic auth, timeout, redirect and certificate settings all carry over.

The command is read the way bash reads it, with single, double and $'…' quotes and line continuations. Anything that cannot be carried over exactly, such as an option with no equivalent or data read from a file, is listed under the result instead of being dropped without a word. Nothing is sent anywhere: the command is only read.

How it works

  1. The command is split into words the way a POSIX shell such as bash splits it. Nothing is expanded: $HOME stays $HOME.
  2. curl options are read as curl reads them, including bundled short flags like -sSL, so -d implies POST and a form content type, -G moves data into the query string and --json adds JSON headers.
  3. The request is then written out for the language you choose, with every string escaped for that language and the body kept byte for byte.
  4. Options that cannot be expressed, and things the code would have to read from disk, are listed under the result.

Questions

Does this tool send my request or see my tokens?

No. The command is only read and rewritten in your browser. No request is made, and nothing you paste leaves the page.

Can it read a command copied for Windows?

It reads POSIX shell syntax (bash, zsh, sh). A command copied as "cURL (cmd)" uses ^ escapes and is refused with a message; in your browser's developer tools choose "Copy as cURL (bash)" instead.

Why does the JSON body appear as a string instead of an object?

Because curl sends the bytes you give it, and the generated code does the same. Turning the body into an object and back could change number precision, key order or spacing.

What happens to redirects and file uploads?

Python, Go and PHP follow redirects only if the command used -L, as curl does. fetch and Axios follow them by default. Files sent with -F are read from disk in the generated code (with openAsBlob in Node.js 20 or later for fetch and Axios), so check the paths.

How long can the command be?

Up to 1 MB of text. Longer bodies are better kept in a file and read by the code.

Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.