curl to code: fetch and Python converter
Paste a curl command and instantly get equivalent JavaScript fetch and Python requests code. The parser reads the URL, method, headers and request body, then writes idiomatic snippets you can copy straight into your project.
How to convert a curl command
- Paste your curl command into the input box (or load the sample).
- Read the generated code in the JavaScript and Python tabs.
- Copy the snippet you need with the Copy button.
Examples
Simple GET
curl https://api.example.com
const res = await fetch("https://api.example.com", {
method: "GET",
});
const data = await res.json();
console.log(data);POST with JSON body
curl -X POST -H "Content-Type: application/json" -d '{"name":"Ada"}' https://api.example.com/usersresponse = requests.request("POST", "https://api.example.com/users", headers=headers, data=data)Frequently asked questions
What does this tool do?
It turns a curl command into runnable JavaScript fetch code and Python requests code. It reads the URL, HTTP method, headers and request body from the command and writes equivalent snippets for each language.
Which curl flags are supported?
The URL (with or without a scheme), the method via -X or --request, repeatable headers via -H or --header, and the request body via -d, --data, --data-raw, --data-binary or --data-ascii. Common boolean and auth flags such as -L, -s, -k, -A and -u are recognized and skipped so they do not get mistaken for the URL.
Is my curl command sent anywhere?
No. Parsing and code generation run entirely in your browser. Nothing you paste is uploaded or stored on a server.
How is the HTTP method decided?
If you pass -X or --request, that method is used. Otherwise the tool defaults to POST when a request body is present and GET when it is not, matching how curl itself behaves.
What is the difference between fetch and requests?
fetch is the built-in HTTP client in modern browsers and Node.js and returns promises, so the snippet uses await. requests is a popular Python library you install with pip; the snippet uses requests.request(method, url, headers=..., data=...).
Does it handle headers and JSON bodies with quotes?
Yes. The tokenizer respects single and double quotes and backslash escapes, so headers like Authorization: Bearer token and JSON bodies with quoted keys are parsed and re-escaped correctly in the generated code.
Related tools
JSON to TypeScript
Generate TypeScript interfaces from a JSON sample. Infers nested objects, arrays and union types, then copy or download the .ts file. Runs in your browser.
Regex Tester
Test a regular expression against text with live match highlighting, capture groups and flags. See every match and replace text. Runs in your browser.
.env to JSON
Convert a .env file to JSON, or JSON back to .env. Parses KEY=value lines, comments, quotes and export. Runs entirely in your browser.
Aspect Ratio Calculator
Calculate aspect ratios fast. Enter a ratio like 16:9 and one dimension to get the other, or enter width and height to simplify the ratio.
Base58 Encoder
Encode and decode Base58 online with the Bitcoin alphabet. Convert text to Base58 or back, UTF-8 safe, no confusing 0 O I l. Runs in your browser.
Base64 Decode
Decode Base64 to plain text online. Paste a Base64 or base64url string and get instant UTF-8 output. Free, fast and runs in your browser.