cURL to Code Converter – Turn Any curl Command Into Working Code
API documentation, Postman and the browser's DevTools all speak one common language: curl. Right-click a request in the Network panel, choose Copy as cURL, and you have a complete, reproducible HTTP request. The hard part is turning that one-liner into code your application can run. This cURL to code converter reads the command the way a shell and curl itself would, then writes the same request as browser fetch, Node.js fetch, Axios, Python requests, Go net/http, PHP cURL, Java HttpClient, Ruby Net::HTTP or a raw HTTP/1.1 message.
How the conversion works
Conversion happens in three steps. First the pasted text is split into words using the rules of the shell it came from. Bash quoting, $'…' ANSI-C strings and backslash line continuations are handled, and so is the caret escaping that Chrome's Copy as cURL (cmd) produces for Windows. Next, every curl option is applied to a request model: the method, URL, headers, cookies, Basic or bearer auth, body and connection settings such as timeouts, redirects, proxies and TLS verification. Finally a generator for each language writes idiomatic code from that model.
Next to the code, the request breakdown shows what the command actually does. The command map lists every option in the order you pasted it, colour-coded by role, with options that only affect curl's own output struck through. The request card splits the URL into scheme, host, port and path, decodes the query string, lists every header with the flag that produced it, and pretty-prints the body. Hover a row on either side to see how they connect.
curl behaviour the tool reproduces
Many small curl rules change the request, and they are easy to miss when converting by hand:
| Command | What curl actually sends |
|---|---|
-d a=1 -d b=2 | A POST with body a=1&b=2 and application/x-www-form-urlencoded |
-G --data-urlencode 'q=a b' | A GET with ?q=a+b in the URL and no body |
--json '{…}' | Content-Type and Accept set to application/json |
-H 'Accept:' | Removes curl's own header, but never one you set with another -H |
-T notes.txt https://host/files/ | A PUT to /files/notes.txt: the file name is appended to a URL ending in a slash |
When something can't be expressed in a target language, the tool says so in the notes panel instead of dropping it silently. Each target tab shows how many warnings it has, so you can see at a glance which language converts your request cleanly.
Differences between languages
HTTP libraries don't behave alike, and the generated code accounts for that. Browsers refuse to let scripts set forbidden headers such as Cookie, Origin and Host, so those are written as comments. Accept-Encoding is removed because each library negotiates compression and decompresses the reply itself. Repeated headers are combined for libraries that store headers in a map, and Basic auth with non-ASCII credentials becomes a ready-made Authorization header, because library helpers disagree on how to encode it. JSON bodies can be written as native objects for easy editing or kept as exact text, which matters when a server checks a signature over the raw bytes.
Tips for clean results
- Turn on Remove browser-only headers to drop
sec-fetch-*,sec-ch-ua*and similar noise from DevTools copies. - If the shell is detected wrongly, pick Bash/POSIX or Windows cmd yourself: backslashes and quotes mean different things in each.
- Replace placeholders such as
$TOKENwith real values. Shell variables are kept as written, never expanded. - Use
--data-binary @filerather than-d @filewhen the exact bytes matter, because curl strips line breaks from-dfiles.