cURL to Code Converter
Convert a curl command to code for 30 targets, including seven separate Node.js HTTP clients.
Generated code
The code lands here.
Press Convert once — the shell grammar downloads on that first press.
That command could not be parsed
This request carries an Authorization header
Start here
- Right-click the request in your dev tools Network tab and choose Copy as cURL, then paste it over the sample already sitting in the box.
- Choose a Target language, then a Client if that second menu appeared. Go and Rust have one client apiece, so it stays out of the way for them.
- Press Convert and read the code in the Generated code pane, then press Copy the code. From then on, editing the curl or switching language redraws the code without another press.
About this tool
Copy as cURL is the quickest way to capture a request that already works, and the slowest way to reuse it. Paste that curl command into the box here, choose a target, press Convert, and the same request comes back as code you can run. Python, Go, Rust, PHP, Java, Swift, C#, whatever the project you're pasting into happens to be written in. There are 30 entries in the Target language menu, and five of them aren't programming languages at all: HTTPie, Wget, raw HTTP text, a HAR file and a plain JSON description of the request are each their own target.
A second menu turns up whenever the language has more than one HTTP client that people actually reach for. Node.js has the deepest bench at seven, covering fetch, axios, got, ky, request, superagent and the built-in http module. Java offers OkHttp, java.net.http, HttpURLConnection and Jsoup. Python is requests or http.client. Go and Rust have one obvious answer each, so the menu stays hidden for those and you never have to think about it.
The command goes through a real bash grammar rather than a pile of regular expressions, which is why single quotes, double quotes, escaped characters and backslash line continuations all behave the way your shell would treat them. That grammar is tree-sitter's bash parser compiled to WebAssembly, roughly a megabyte and a half across two files, and it downloads the first time you press Convert. Convert reads Converting… while it arrives, once, and after that it works offline too. It shows up on the /storage page afterwards, filed under this tool and named Command parser, with a Delete button if you want the space back.
Nothing converts until you press the button that first time; the Generated code pane sits beside the command from the start, waiting. After that the page keeps up on its own: edit the curl, switch language, switch client, and the code redraws a moment later, coloured in the same inks the rest of the site uses. Your two choices are pushed into the address bar as lang and variant, so a link carrying ?lang=go reopens on Go for whoever you send it to, and ?lang=node&variant=axios drops them straight onto axios.
One thing worth saying plainly, because it catches people out. A curl copied from the Network tab carries your live session cookie and your Authorization header word for word, and both come out the other side sitting in clear text inside the generated snippet. The conversion runs locally, so the paste itself is fine. What you do with the output is the risk. When a command carries one, a caution says so under the code and the secret is lit on both sides. Swap the token for an environment variable before that file goes anywhere near a repository.
Good to know
- Only the request itself converts. Flags like --retry, --max-time and -v describe how curl behaves rather than what it asks for, and most target clients have no single line that means the same thing. Where one is dropped or only approximated, the converter says so in a warning under Generated rather than in the code.
- What comes back is the happy path and nothing else. No error handling, no timeout, no retry, no connection reuse. That's the right default for a snippet going into a scratch script and the wrong one for anything that has to stay up.
- Credentials are reproduced literally. The Bearer string, the cookie header and the -u pair all land in the snippet exactly as you pasted them, and they want replacing before the file gets committed.
Frequently asked questions
Which languages does it actually cover?
Thirty entries in the Target menu. Python, JavaScript, Node.js, Go, Rust, PHP, Ruby, Java, C#, Swift, Kotlin, Dart, C, Clojure, Elixir, Julia, Lua, MATLAB, OCaml, Objective-C, Perl, PowerShell, R, ColdFusion and Ansible, plus HTTPie, Wget, raw HTTP text, a HAR file and a JSON description of the request. Those last few earn their place when you aren't writing code at all and just want the request in a shape you can hand to something else.
Why is there a second dropdown next to the language?
Because plenty of languages have more than one HTTP client in common use, and picking for you would be presumptuous. Node.js carries seven options, Java four, JavaScript and PHP three apiece, and Python, Ruby, PowerShell and R two each. Languages with a single obvious choice skip the menu entirely.
What does “There is no curl in that” mean if I already pasted one?
The check hunts for curl as its own word anywhere in what you pasted, and a shell prompt in front of it is fine, since a leading $ or # followed by a space gets stripped before anything else runs, and curl.exe or CURL count as curl. What usually trips it is pasting the flags without the curl at the front, or pasting a fetch() call in the hope of going the other direction. Only curl goes in.
Do curl's retry and timeout flags come across?
Sometimes, and the page tells you which. Those flags say how curl should behave rather than what the request is, so a client either has a near match, like a Python timeout for --max-time, or none at all; whatever does not come across is listed as a warning under Generated. The request parts convert well: method, URL and query string, headers, cookies, basic auth, and every body shape from -d through --data-raw and --data-binary to a multipart -F.
Why is the first conversion slower than the rest?
Only that one is slow, and only because something has to download. Reading a shell command properly means having a shell grammar, so a tree-sitter build of bash comes down as two WebAssembly files on your first press of Convert. Every conversion after that is served from cache, including the ones where you change language.
Can I bookmark it on a particular language?
The language and client you pick are written into the address bar as lang and variant using replaceState, so your back button doesn't fill up with every switch. Bookmark or send that URL and it reopens on the same pair. The curl command itself is deliberately left out of the link, which matters given what tends to be sitting inside one.
Missing something in cURL to Code Converter? Suggest a feature →
Tell someone who needs this.