Curl to Code Converter
Paste a curl command, get equivalent code in JavaScript (fetch/axios), Python (requests), or Go (net/http). Handles headers, JSON bodies, basic auth, and form data.
const response = await fetch("https://api.example.com/v1/users", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer eyJhbGc...",
},
body: JSON.stringify({"name":"Alice","email":"alice@example.com"}),
});
const data = await response.json();Parsed details (for debugging)
{
"method": "POST",
"url": "https://api.example.com/v1/users",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer eyJhbGc..."
},
"data": "{\"name\":\"Alice\",\"email\":\"alice@example.com\"}",
"isForm": false,
"isUrlEncoded": false,
"basicAuth": null,
"followRedirects": false,
"insecure": false
}How to use the curl to code converter
Paste a curl command on the left. The right side shows the equivalent code in your chosen language. Edit the curl freely — the output updates live. Supports common flags: -X, -H, -d, --data-raw, --data-binary, -u, -F, -L, -k, -A, -b, -G, -I.
Formula & explanation
Parser tokenizes the curl with shell-quoting rules, extracts method/URL/headers/body/auth, then a per-language generator emits idiomatic code. Method is implicit POST when -d is used without -X.
Examples
A curl with -H "Content-Type: application/json" and -d '{"x":1}' becomes fetch with a headers object and JSON.stringify body. Basic auth (-u user:pass) maps to native auth helpers in each language.
Frequently asked questions
- What curl flags are supported?
- The common ones: -X / --request, -H / --header, -d / --data / --data-raw / --data-binary / --data-urlencode, -F / --form, -u / --user, -L / --location, -k / --insecure, -A / --user-agent, -e / --referer, -b / --cookie, -G / --get, -I / --head. Unknown flags are silently skipped to avoid garbling the rest of the parse.
- Does it handle multipart form (-F) uploads?
- It detects -F and marks the body as form-data in the generated code, but you'll need to construct the FormData / files dict yourself — file paths and content streams don't translate directly. The output includes a comment showing where to plug them in.
- Why does my JSON body have escaped quotes?
- Curl bodies are strings; we detect when the body parses as JSON (or Content-Type is application/json) and emit it as a native object literal in JS/Python. If your input has unusual escaping, the heuristic may miss it — paste through the JSON Formatter first to normalize.
- Does the generated code actually run?
- Yes for the common cases (JSON POST, GET with query strings, basic auth, custom headers). Edge cases that need manual attention: multipart uploads, file streaming, cookies-from-file, certificate pinning, --http2/--http3 protocol forcing. These are flagged in comments where relevant.
- Why no Ruby / PHP / Rust / Java?
- Started with the four highest-demand targets. If you'd find another language useful, let us know — the parser is language-agnostic, only the generator needs to be written.
Related developer tools tools
- JS MinifierMinify JavaScript using Terser — removes whitespace, shortens variable names, and removes dead code. Paste your JS and get a production-ready compressed bundle.
- JSON to XML ConverterConvert JSON objects and arrays to well-formed XML. Maps object keys to elements, array items to repeated elements, with optional root wrapper.
- JSON to YAML ConverterConvert JSON to clean indented YAML for Kubernetes manifests, Docker Compose, CI configs, and Helm charts. Preserves nested structures.
- JSON to CSV ConverterConvert JSON arrays to CSV with automatic header detection from object keys. Handles nested values and arbitrary delimiters.
- YAML to JSON ConverterConvert YAML to JSON for APIs, config files, and pipelines. Supports indented mappings, sequences, scalars, and nested objects.
- YAML to XML ConverterConvert YAML to well-formed XML for legacy integrations. Preserves nested mappings and sequences as nested elements with text values.