cURL to Code Converter
Paste a curl command — including devtools "Copy as cURL" output — and get working code.
const response = await fetch("https://api.example.com/v1/users", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer TOKEN123",
},
body: "{\"name\":\"Ada\",\"role\":\"admin\"}",
});
const data = await response.json();
console.log(data);How to Use
- 1. Paste your curl command — devtools "Copy as cURL" output works directly.
- 2. Choose a target language.
- 3. Review the generated code in the output panel.
- 4. Copy it into your project.
From Terminal to Codebase
API documentation is written in curl, but applications are not. Translating by hand is tedious and easy to get subtly wrong — a missed header or a body sent as a string when the server expects JSON produces failures that look like server bugs.
The parser here tokenises the command the way a shell would, respecting single and double quotes so header values and JSON bodies containing spaces survive intact. Backslash line continuations are joined first, which is what makes "Copy as cURL" output from browser devtools work without editing.
Flags that only affect curl's own behaviour — -v, -s, -L, --compressed — are deliberately ignored, because they describe how curl runs rather than what the request contains. When a body is present without an explicit -X, the method becomes POST, matching curl's own rule.
One caution: commands copied from devtools often contain session cookies and bearer tokens. Those stay on your screen and in your clipboard, so clear the field when you are finished on a shared machine.
Related: JSON Formatter, HTTP Status Codes, and JWT Decoder.
Frequently Asked Questions
Which curl flags are supported?
The ones that carry request semantics: -X/--request, -H/--header, -d/--data/--data-raw/--data-binary, -u/--user for basic auth, and --url. Display-only flags such as -v, -s, -L, -k and --compressed are ignored because they do not change the request being described.
Does it handle multi-line commands?
Yes. Backslash line continuations — the format you get from browser devtools "Copy as cURL" — are joined automatically before parsing.
What happens to basic auth?
A -u user:pass flag becomes the language's native auth mechanism: an Authorization header for fetch, the auth option in axios, the auth tuple in Python requests, and SetBasicAuth in Go.
Is the method inferred?
Yes. If you supply a body without an explicit -X, the method becomes POST, which matches curl's own behaviour. An explicit -X always wins.
Is my command sent anywhere?
No. Parsing and code generation happen entirely in your browser. Be aware that tokens in your command stay visible on screen — clear the field when you are done on a shared machine.
Was this tool helpful?
More Tools
Related Developer Tools
JS & CSS Minifier
JSON Formatter
Regex Tester
SQL Formatter
You Might Also Like