cURL to Code Converter
Convert cURL command strings to JavaScript Fetch, Axios, Node.js, and Python requests.
Client-Side Execution & Privacy Guarantee
This utility executes 100% locally in your web browser. Your inputs, tokens, queries, and data payloads are never transmitted to any external server or backend.
Developers frequently copy cURL commands from browser DevTools, Postman, or API documentation. These commands capture the exact request but are not immediately usable in application code. This tool parses the command and rewrites it as idiomatic code for the language or library you actually ship.
Everything runs client-side. Tokens, cookies, and request bodies never leave your browser. The converter recognizes common flags including method, headers, data, basic auth, and cookies, then maps them to the conventions of each target.
What the parser extracts
A cURL command is a sequence of options and a URL. The tool tokenizes quoted arguments and handles backslash continuations so multi-line pastes work unchanged. It records the HTTP method (explicit -X or implied by -d), every -H header, the body supplied by -d, --data, or --data-raw, and credentials from -u.
Query parameters that already appear in the URL stay in the URL for fetch. For axios and requests they are optionally lifted into a params object for readability. Binary or multipart form data is noted when -F is present, though full file uploads require local paths the browser cannot open.
Language-specific idioms
Fetch receives a plain options object with method, headers, and body. When the Content-Type is application/json the body is passed through JSON.stringify. Axios uses its config object and prefers the json property for objects. Python requests uses the json= keyword for JSON bodies and the auth= tuple for basic authentication.
Node.js output uses the built-in https or undici style when requested, avoiding extra dependencies. Cookies become a Cookie header or the library's cookie jar equivalent. Insecure -k is mapped to rejectUnauthorized: false only in Node targets; browsers ignore it for security.
Limits and fidelity
Not every cURL flag has a perfect counterpart. Redirect following (-L) is left to the client library defaults. Timeouts (-m) become timeout options where supported. The tool does not execute the request; it only generates source text.
Forbidden browser headers such as Host or Cookie are still emitted for Node targets but noted as browser-restricted for fetch. Always review the generated code before committing it, especially when secrets are present.
When to use this tool
- You copied a request from Chrome DevTools Network panel and need it in your frontend or test suite.
- An API provider's docs show only a cURL example and you want Axios or requests.
- You are writing a quick script and prefer not to hand-translate headers and bodies.
- You need the same call in both JavaScript and Python for a polyglot service.
How to use the cURL to Code Converter
- Paste the full cURL command into the input area. Multi-line commands with backslashes are accepted.
- Choose the target language or library from the available options.
- Review the generated code. Adjust variable names or add error handling as needed.
- Copy the result into your editor or test file.
- If the command contains secrets, treat the output as sensitive and avoid sharing it.
Worked examples
POST JSON with bearer token
curl -X POST https://api.example.com/v1/users -H 'Content-Type: application/json' -H 'Authorization: Bearer eyJdemo' -d '{"name":"Ada","age":36}'
const response = await fetch('https://api.example.com/v1/users', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer eyJdemo'
},
body: JSON.stringify({"name":"Ada","age":36})
});
const data = await response.json();
Fetch version. The JSON body is stringified and the Authorization header is preserved exactly.
GET with basic auth
curl -u alice:s3cret https://api.example.com/me
import requests
response = requests.get('https://api.example.com/me', auth=('alice', 's3cret'))
response.raise_for_status()
data = response.json()
Python requests version. Basic auth is passed as a tuple rather than a manual header.
Common mistakes and tips
- Always check whether the generated fetch call will work under CORS; cURL does not enforce browser security rules.
- For large binary bodies prefer generating Node.js code so you can stream from disk.
- If the tool leaves a flag unmapped, look up the equivalent option in the target library documentation.
- Regenerate after editing the original cURL rather than hand-editing the output, to avoid drift.
Frequently asked questions
Does the converter upload my cURL command?
No. Parsing and code generation happen entirely in your browser. Secrets stay local.
Can it handle multipart form uploads?
It detects -F fields and emits the corresponding form structure, but cannot open local files. You must supply the file content or path yourself in the final code.
Why does fetch sometimes omit the Cookie header?
Browsers forbid setting the Cookie header from JavaScript. The converter still shows it for Node targets and warns for browser fetch.
Does it support custom HTTP methods?
Yes. Any method given with -X is passed through unchanged.
What if the command uses --compressed or other curl-specific flags?
Flags without a direct equivalent in the target library are ignored or noted in comments. The core request remains accurate.