curl Converter
DevConvert a curl command into JavaScript fetch, axios, Python, Go, Java and HTTPie — live, with multi-language tabs.
Remote URLs are not fetched; paste your JSON directly.
On this page
What is a curl converter?#
curl is the closest thing HTTP has to a universal language. Every browser DevTools panel, every API docs site, and every support ticket ends up handing you a curl command — “copy as cURL” is how a request travels from a browser into a bug report. The problem is that a pasted curl command is rarely what you can actually run in your codebase. Your service is written in Python, or Go, or browser-side fetch; you do not want to shell out to curl, you want the equivalent call in the HTTP client you already use.
This page bridges that gap. Paste a curl command on the left, and it parses the shell syntax — flags, quotes, line continuations, headers, body, auth — into a structured request, then emits the equivalent code for six targets at once: browser fetch, axios, Python requests, Go net/http, Java HttpURLConnection, and httpie. You read across the tabs, copy the one that matches your stack, and move on.
Parsing runs entirely in your browser. The command you paste never touches a server, which matters because real curl commands frequently contain bearer tokens, basic-auth credentials, or signed cookies.
How to use it#
- Paste your curl command into the Input pane on the left. You can paste the leading
curlword or omit it; both work. Multi-line commands joined with a trailing\are understood, as are commands copied straight from a terminal where each flag sits on its own line. - Click Sample to load a realistic example if you want to see the shape first, or Clear to wipe the pane.
- Pick a target language from the tab bar above the output: fetch, axios, python, go, java, or httpie. All six are generated from the same parse, so switching tabs is instant — there is no re-run.
- Read the generated code in the panel. Use Copy in the tab bar to grab it.
- Watch the status bar below the panes. If the parser hit a flag it does not model (an output-file redirect, a proxy setting), it says so explicitly instead of silently dropping it.
Key features#
- A real shell tokenizer, not a regex scrape. Single quotes, double quotes, ANSI-C
$'...'quoting (with\n,\t,\x41,éescapes), backslash-newline line continuation, and the difference between"a\b"and'a\b'are all handled the waybashwould. Naive converters that split on whitespace break the moment a header value contains a space. - Six targets from one parse. You see
fetch,axios, Python, Go, Java, andhttpieside by side. If you are unsure whether to reach forfetchoraxios, you can compare their handling of the same auth header in two clicks. - Body intelligence. When the request carries
Content-Type: application/json, the Python emitter passes it as thejson=keyword so a dict-shaped body is sent correctly; otherwise it falls back todata=. - Basic auth decoded once. A
-u user:passflag becomesbtoa("user:pass")in fetch, theauthblock in axios, theauth=tuple in requests, andSetBasicAuthin Go — each idiom the way that language expects. - Unknown flags are reported, not swallowed.
-o output.txtor--proxyare surfaced in the status bar asunknown args, so you are never silently misled into thinking a conversion captured a redirect or proxy that it actually dropped. - No backend, no leakage. The command is tokenized in-memory by the page’s own script. There is no network call carrying your pasted token anywhere.
Worked example#
Load Sample (or paste the equivalent of what browser DevTools produce when you “Copy as cURL” for a JSON POST):
curl -X POST https://example.com/api/v1/users \
-H 'Authorization: Bearer tok' \
-H 'Content-Type: application/json' \
-d '{"name":"Alice","role":"admin"}'
Switch to the fetch tab and you get:
const response = await fetch("https://example.com/api/v1/users", {
method: "POST",
headers: {
"Authorization": "Bearer tok",
"Content-Type": "application/json",
},
body: "{\"name\":\"Alice\",\"role\":\"admin\"}",
});
Switch to the python tab. Because Content-Type is JSON, the body goes through the json= keyword:
import requests
url = 'https://example.com/api/v1/users'
headers = {
'Authorization': 'Bearer tok',
'Content-Type': 'application/json',
}
payload = '{"name":"Alice","role":"admin"}'
response = requests.request('POST', url, headers=headers, json=payload)
print(response.status_code)
The same command is also immediately available under the go, java, axios, and httpie tabs — six conversions for the price of one paste.
FAQ#
It says “unknown args” for my command. What did it skip?#
The parser models the curl flags you use to describe a request — method, URL, headers, body, basic auth, --compressed, -k, -L. Flags that describe curl’s own behaviour (such as -o to write the body to a file, --proxy, --connect-timeout, --cert) are not translated, because they have no equivalent in a fetch call. They are collected and shown in the status bar so you know they were dropped deliberately, not lost.
Can I convert a command that uses $'...' ANSI-C quoting?#
Yes. Headers and bodies copied from terminals sometimes arrive wrapped in $'...' so that escape sequences like \n or \t are interpreted by the shell. The tokenizer understands ANSI-C quoting and decodes \n, \t, \xHH, \uHHHH, \UHHHHHHHH and the simple escapes, so the bytes the converter sees match the bytes curl would have sent.
Why does my Python output use json= sometimes and data= other times?#
The emitter looks at your headers. When Content-Type: application/json is present it passes the body through the json= keyword, which lets requests set the header and encode the payload correctly. For any other content type (form-encoded, plain text, multipart) it falls back to data=, because forcing json= there would be wrong.
Does it send the request for me?#
No, and that is deliberate. This tool only translates the command into code; it never executes it. The generated snippet runs in your own program, under your own credentials, where you can inspect it before it does anything live.