Skip to content
MagicWebBox
Sign in

cURL to code

A cURL command as fetch, axios, Python…

cURL command

Generated code

Paste a cURL command to convert it.

About this tool

This tool translates a cURL command into code you can drop into your application. It is especially handy for reusing an example from API documentation, or a request grabbed from the browser’s Network tab with “Copy as cURL”, without rewriting every header by hand in the language your project uses.

It generates JavaScript with fetch or axios, Python with requests, and PHP with the cURL extension. It understands options such as -X, -H, -d, --data-raw, --data-urlencode, --json, -F, -u, -b, -G, -L, -k and --compressed, as well as shell quoting and backslash line continuations. A JSON body becomes a readable object, and unsupported options are flagged.

How to use it

  1. Paste your command into “cURL command”, or click “Example”.
  2. Check the detected method and URL, along with any warnings.
  3. Under “Generated code”, pick the JavaScript (fetch), axios, Python (requests) or PHP (cURL) tab.
  4. Click “Copy” or “Download” to get the code.

Frequently asked questions

How do I get the cURL command for a browser request?

Open the developer tools, go to the Network tab, right-click the request and choose “Copy as cURL” (the bash version). Paste it here: headers, cookies and body all carry over into the generated code.

Is the request executed or sent to a server?

No. The command is only parsed in your browser to produce code; no request is sent to the URL or to our servers. Any tokens or cookies in the command stay on your device.

What happens to files sent with @file?

They are listed in a warning, because the generated code cannot read them for you. With -F, the file field still appears in the code (FormData, open() in Python, CURLFile in PHP), and you only need to supply the file.

Are all curl options supported?

No. Common options for the method, headers, body, forms, authentication and cookies are handled. Others are ignored and listed in a warning, so you know exactly what is missing from the generated code.