cURL to Code Converter
Paste any cURL command and get the equivalent code in JavaScript fetch, Python requests, Node.js axios, Go, PHP, Ruby, Java, or C#. Headers, body, authentication, and query parameters all carry over correctly. The cURL stays the source of truth; the generated code is a transcription, not a reinterpretation.
Why cURL Stays the Lingua Franca of HTTP
Every API doc has a cURL example. Every browser's Network tab has Copy as cURL. Every shell prompt has cURL available. It became the default way humans describe an HTTP request to other humans, and that convention isn't going anywhere. The friction is that the moment you want to put the request into a real program, you have to translate the cURL flags into whatever your language's HTTP client wants — and the mapping isn't always obvious.
Some flags translate cleanly: -H is a header, -d is a body, -X POST is a method. Others have surprising mappings. --data-urlencode requires the body to be percent-encoded but the Content-Type to be application/x-www-form-urlencoded. -u user:pass is HTTP Basic auth, which in fetch becomes an Authorization header with the credentials base64-encoded. --cookie-jar is a session feature most fetch-style clients don't have at all. Getting these right by hand for every request gets old.
How It Works
The cURL command is tokenized using shell-aware parsing — quoted strings are kept whole, escapes are honoured, and line-continuation backslashes get folded. Each flag is mapped to its semantic meaning (header, body, auth, method, URL, etc.) and then re-emitted in the target language's idiom. JavaScript fetch goes through a fetch(url, options) call; Python requests becomes requests.request(method, url, **kwargs); Go becomes a net/http client with the request object built explicitly.
The generated code is intentionally beginner-friendly — it imports the standard HTTP library, builds the request explicitly with named variables, and adds error handling. Experienced developers can shorten it; the verbose version is easier to learn from and harder to misread.
Reverse direction (code to cURL) is the natural follow-up. Paste a generated fetch call back into the JSON formatter for inspection, or pipe a generated request body through the URL encoder to verify the encoding.
Common Use Cases
Promoting an API call from the browser DevTools Network tab into a script. Sharing a working request with a teammate whose language isn't yours. Generating starting code for a Postman-equivalent test. Translating an API doc's cURL example into the boilerplate your codebase uses. Verifying that your client library is sending the exact same bytes as the cURL you tested with — when the cURL works and the code doesn't, the diff is usually a header.
Worked example: the generated code against real curl
Parsing now follows shell quoting and curl's own data rules. On October 13, 2026 we ran nine commands with curl 8.5.0 against a local echo server, then ran the JavaScript (Node 22 fetch) and Python (requests 2.33) code this page generated for the same commands: method, path and query, Content-Type and body matched curl in 9 of 9 cases for both languages, including multipart uploads compared field by field.
| Command | Before (v218) | Now |
|---|---|---|
-d a=1 -d b=2 | only b=2 sent | a=1&b=2, with the form Content-Type curl adds |
-G -d q=x | sent as a POST body | GET with ?q=x in the URL |
--data-urlencode 'msg=a b&c' | sent unencoded | msg=a+b%26c |
--json '{"a":1}' | taken as the URL | POST with application/json body and Accept header |
-F f=@file -F name=Bo | skipped | FormData (JavaScript) or files=/data= (Python); other languages say multipart is not generated |
$'line1\nline2' (Chrome's "Copy as cURL") | the $ and escapes read literally | ANSI-C quoting decoded |
-d @body.json | the text "@body.json" sent as the body | a FILE_CONTENTS placeholder and a note |
| Response | always response.json() | json() only when the request expects JSON, otherwise text |
- Files are not read. The page cannot open files on your disk, so
-d @file,--data-urlencode name@fileand--json @fileproduce a placeholder and a note, and-F field=@filebecomes a file input (JavaScript) oropen()(Python). - Options without an equivalent are listed, not silently dropped:
-k(skip TLS checks), cookie files and other unsupported flags appear as notes at the top of the code. - PHP, Go, Ruby, C# and PowerShell use the same parsed request (joined data, query strings, content types), but multipart forms are only generated for JavaScript and Python.
Sources
Checked on .
Frequently Asked Questions
Built by Derek Giordano · Part of Ultimate Design Tools