cURL to Code Converter
Convert any cURL command into JavaScript fetch, axios, Python requests, PHP cURL, Node.js, Go, Ruby, Java, C#, Rust or Swift code instantly. 100% client-side.
About the cURL to Code Converter
Paste a cURL command and instantly get equivalent code in JavaScript (fetch / axios / XHR), Python (requests), PHP (cURL), Node.js (https), Go (net/http), Ruby (Net::HTTP), Java (HttpClient), C# (HttpClient), Rust (reqwest) or Swift (URLSession). The tool parses cURL flags faithfully — -X, -H, -d, --data-urlencode, -F, -u, -b, --cookie, -A, --compressed, -L, -k, -G — so the generated code matches the exact request your terminal would send.
How does the cURL to code converter work?
It tokenizes your cURL command exactly like a shell would (respecting quotes, escapes and line continuations), parses the flags into a request object (URL, method, headers, body, auth, cookies), then renders that object as idiomatic code for the target language. The whole process happens client-side in your browser — no server roundtrip and no data leaves your machine.
Which cURL flags are supported?
-X / --request, -H / --header, -d / --data / --data-ascii / --data-raw / --data-binary, --data-urlencode, -F / --form, -u / --user, -b / --cookie, -A / --user-agent, -e / --referer, -L / --location, -k / --insecure, -G / --get, --compressed, --url. Flags that don't affect the generated code (-s, -v, -i, -I, -o, --http2) are recognized and safely ignored.
Can I paste a cURL with line breaks (\ continuations)?
Yes. The parser collapses backslash-newline pairs before tokenizing, so you can paste a multi-line cURL command copied from Chrome DevTools, Postman or your terminal history directly into the input box.
Does it detect JSON bodies?
When the body looks like a JSON object or array and parses successfully, the converter adds the Content-Type: application/json header in the generated code automatically (unless you already set one explicitly via -H). In Python it uses json= instead of data= so requests serializes the body for you.
How are multipart form uploads (-F) handled?
The converter emits FormData (JS), a {data, files} pair (Python), CURLFile entries (PHP), or the equivalent multipart construct for each language. Fields starting with @ are recognized as file paths and the generated code includes a placeholder line for attaching the file.
What about -u for HTTP basic auth?
-u user:pass is translated to the idiomatic auth API of each language: Basic + base64 in fetch/XHR/Node, auth=(user,pass) in Python, CURLOPT_USERPWD in PHP, SetBasicAuth in Go, basic_auth() in Ruby/Rust, AuthenticationHeaderValue in C#, and a base64 Authorization header in Java/Swift.
Why is the output for -G different?
When cURL sees -G (or --get), it moves the -d data into the URL as a query string instead of sending it as a body. The converter does the same: data from -d is appended to the URL with ? or & and the request becomes a GET with no body — matching cURL's actual behavior.
Can I copy a cURL command from Chrome DevTools and convert it?
Yes — that is the most common use case. Open DevTools → Network tab → right-click a request → Copy → Copy as cURL (bash). Paste it into the input box. The tool handles all the shell quoting, headers, cookies and bodies Chrome generates, then produces clean code in the language of your choice.
Features
- 12 target languages and libraries — fetch, axios, XHR, Python requests, PHP cURL, Node.js, Go, Ruby, Java, C#, Rust, Swift
- Handles shell quoting: single quotes, double quotes, escapes, line continuations (\), $'...' ANSI strings
- Recognizes 25+ cURL flags including -X, -H, -d, --data-raw, --data-urlencode, --data-binary, -F, --form, -u, --user, -b, --cookie, -A, -e, -L, -k, -G, --compressed
- Auto-detects JSON bodies and emits the right Content-Type
- Multipart form-data (-F) generates FormData / files = {} / CURLFile boilerplate
- Basic auth (-u user:pass) is mapped to language-idiomatic auth APIs
- Cookie header consolidation from multiple -b flags
- -G + -d moves data into the query string as cURL does
- Real-time conversion — switch target tabs and the code updates instantly
- Copy + download the generated snippet with one click
- 100% client-side: your cURL command and headers never leave the browser
- Available in English, Spanish, Vietnamese, Portuguese and French
