cURL to Code Converter
Turn any curl command into working JavaScript, Python, PHP, Go, Ruby, Node or C# — with proper shell parsing and native literals for each language.
What was parsed
Before you paste this anywhere
Parsing and generation both happen in your browser. Your command, including any tokens in it, is never sent to a server — but do replace credentials with environment variables before sharing the generated code.
What It Does
API documentation gives you a curl command; your project is written in something else. This translates between the two. Paste the command — including the multi-line form with trailing backslashes that you get from documentation or from a browser's Copy as cURL — and get back working code in whichever of eight languages you need. The part that takes the work is the parsing. A curl command is a shell command, so its arguments follow shell quoting rules: a JSON body is full of spaces, a header contains a colon, and single and double quotes behave differently from each other. Splitting on whitespace produces nonsense. This tool implements the quoting properly, then generates code that reads the way a person in that language would have written it, with native literals rather than JSON text pasted into a foreign syntax.
When to Use It
- An API's documentation shows only curl examples and you need the equivalent in the language your service is actually written in.
- You captured a request from your browser's network tab as Copy as cURL and want to reproduce it in a script.
- A support ticket includes a curl command that reproduces a bug and you need it as a test case in your codebase.
- You are moving a shell script full of curl calls into a proper application and want a starting point for each request.
- You want to check how a request's headers and body will be structured before writing the client code by hand.
Worked Examples
curl -X POST 'https://api.example.com/v1/users' -H 'Content-Type: application/json' -H 'Authorization: Bearer tok_123' -d '{"name":"Jane","admin":true,"age":30}'
The standard shape of an API write. Watch the Python output in particular: the body becomes a real dictionary with True rather than the JSON spelling, so the code runs as pasted instead of raising a NameError.
curl 'https://api.example.com/search?q=hello+world&page=2' -H 'Accept: application/json'
A plain GET with query parameters. No -X flag and no body, so the method defaults to GET exactly as curl itself would, and the generated code correctly omits any body-writing step.
curl -u admin:s3cret -X DELETE https://api.example.com/v1/sessions/42 -L
Basic authentication and a redirect follow. Each language gets its own idiom for the credentials — SetBasicAuth in Go, auth= in Python, basic_auth in Ruby — rather than a hand-built Authorization header.
Features
How to Use
1. Paste your curl command — multi-line with backslashes is fine. 2. Pick the target language from the selector. 3. The generated code appears immediately, along with a breakdown of the method, URL, headers and body it parsed. 4. Check any warnings, particularly about credentials, before copying. 5. Click Copy to take the code.
Common Mistakes
- Splitting a curl command on spaces to parse it. A JSON body and almost every header contain spaces, so the arguments come apart in the wrong places and the result is silently wrong rather than obviously broken.
- Pasting JSON text into a Python dictionary. true, false and null are not Python literals, and code that looks right fails with a NameError the first time it runs.
- Leaving the token in the generated code. The credential from the curl command travels straight into whatever you paste next, which is how API keys end up in public repositories.
- Assuming a command with no -X flag is a GET. curl switches to POST as soon as there is a body, so copying the method from the flag alone gets it wrong exactly when a body is present.
- Expecting $(...) or a file reference like -d @body.json to be resolved. Those need a shell and a filesystem, so the generated code can only mark the spot where the real value belongs.