curl to Code Converter Online
Convert a curl command into fetch, axios, Python requests, PHP, Go, Java, C#, Ruby, Node.js, wget or HTTPie code, with headers, body and query as JSON.
Result
Press “Run” to see the result.
Paste a curl command, for example from an API’s documentation or from the browser’s "Copy as cURL" (bash or Windows cmd), and get equivalent code for JavaScript fetch, axios, Python requests, PHP curl, Go net/http, Java HttpClient, C# HttpClient, Ruby Net::HTTP, Node.js http / https, wget and HTTPie. to selects targets (comma-separated, default all). The response also has the parsed request: method, URL, query parameters, headers, body (JSON, form, multipart parts or a file reference) and auth, handy to feed a no-code HTTP step.
The command line is parsed by our own POSIX shell-word parser: single and double quotes, backslash escapes, $'…' ANSI-C strings, line continuations with \, ^ (cmd) or backtick (PowerShell). Supported options: -X, -H, -d / --data / --data-raw / --data-binary / --data-urlencode, --json, -F / --form, -u, --oauth2-bearer, -b, -A, -e, -k, -L, -I, -G, --compressed, -x, --url, --url-query, -o, -m, combined short flags (-sSL) and --opt=value.
Harmless display options (-s, -v, -i, --retry…) are listed in ignored_options; options we do not translate are listed in unsupported_options, and warnings explain approximations (files read with @, cookies from a file, several URLs). Nothing is sent to the URL in the command.
Use this in your code
curl -X POST "https://apibox.io.vn/v1/curl-convert" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"curl":"curl -X POST https://api.example.com/v1/orders -H '\''Content-Type: application/json'\'' -u key:secret -d '\''{\"sku\":\"A1\",\"qty\":2}'\''","to":"python"}'const res = await fetch('https://apibox.io.vn/v1/curl-convert', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"curl": "curl -X POST https://api.example.com/v1/orders -H 'Content-Type: application/json' -u key:secret -d '{\"sku\":\"A1\",\"qty\":2}'",
"to": "python"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/curl-convert",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"curl": "curl -X POST https://api.example.com/v1/orders -H 'Content-Type: application/json' -u key:secret -d '{\"sku\":\"A1\",\"qty\":2}'", "to": "python"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/curl-convert');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"curl":"curl -X POST https://api.example.com/v1/orders -H \'Content-Type: application/json\' -u key:secret -d \'{\\"sku\\":\\"A1\\",\\"qty\\":2}\'","to":"python"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));API documentation → Get a free API key
FAQ
Does the API call the URL in my command?
No. It only parses the text and generates code; no request is made to the URL.
What happens with -d @file or -F file=@photo.jpg?
The generated code reads the named file (open(), fs.readFileSync, CURLFile, os.Open…) and a warning reminds you that the file must exist where the code runs.
Is the Windows "Copy as cURL (cmd)" format supported?
Yes. ^ escapes and ^ line continuations from cmd, and backtick continuations from PowerShell, are handled before parsing.