# Convert cURL to code

Paste a cURL command and get the same request as fetch, Axios, Python requests, Go or PHP. Nothing is run and nothing is sent.

https://codeknife.dev/en/curl-to-code/

## What it does

Turns a cURL command into code for fetch, Axios, Python requests, Go or PHP. The command is read as text: nothing is run and no request is sent.

## How to use it

1. Paste a cURL command, or drop a text file. Commands copied from a browser’s network panel work, line continuations and all.
2. Pick the language under **Convert to**.
3. Copy or download the code. Options that could not be converted are listed under it.

## Examples

`curl -u alice:s3cret https://api.example.com/private` becomes a fetch request with an `Authorization: Basic YWxpY2U6czNjcmV0` header, and in Python `auth=("alice", "s3cret")`.

## Good to know

- Handled: the method (`-X`), headers (`-H`), data (`-d`, `--data-raw`, `--data-binary`, `--data-urlencode`, `--json`), `-G`, basic auth (`-u`), cookies (`-b`), the user agent (`-A`) and the referer (`-e`).
- A header given twice keeps its last value. A body without a Content-Type gets the form type, as cURL sends it.
- Files (`-d @file`), uploads (`-F`), proxies and TLS options are not converted. They are listed so you can see what the code leaves out.
- Commands often hold tokens and passwords, so this tool shows no ads and keeps no history or share link of what you paste.

## What happens to the command I paste?

The command is split into words the way a shell would, without running it, and its options are read: method, headers, data, basic auth and the URL. The result is written as code you can paste into your project. Options that do not change the request, such as -s or --compressed, are listed as not converted.

## Frequently asked questions

### Does this run my command or send the request?

No. The command is only read as text and turned into code in your browser. Nothing is executed and no request is made.

### Is it safe to paste a command with a token or password?

The text stays in your browser and is never sent to our servers, and this page shows no ads. Still, replace real secrets with placeholders before you share the code, and rotate a token that has been pasted anywhere you do not trust.

### Which options are supported?

The method (-X), headers (-H), data (-d, --data-raw, --data-binary, --data-urlencode, --json), -G, basic auth (-u), cookies, the user agent and the referer. Files such as -d @body.json and form uploads (-F) cannot be read here and are listed as not converted.