Curl Converter

Paste a curl command and get working code for fetch, Python requests or Node axios - headers, body, method and auth all carried across. Everything runs in your browser.

From curl to real code

curl is the lingua franca for sharing an HTTP request - API docs, bug reports and Stack Overflow answers are full of curl one-liners. But when you actually need that request inside a JavaScript app, a Python script or a Node service, translating it by hand is fiddly and easy to get wrong. This converter parses the command properly, the way a shell does, and rebuilds it in the language you pick.

What gets carried over

The method comes from -X, or is inferred as POST when a body is present. Every -H header is preserved, and repeated -d flags are joined with an ampersand just like curl does. Basic auth from -u user:pass turns into an Authorization: Basic header, cookies become a Cookie header, and -A and -e map to User-Agent and Referer. When the body is JSON, the output uses a native object and the idiomatic serialiser for each language rather than an ugly escaped string.

Flags with no equivalent

Some curl flags describe transport behaviour that fetch, requests and axios handle automatically or differently. --compressed is a no-op because all three decode gzip for you, and -L is noted because each library follows redirects by its own default. Anything the converter cannot map is listed in a note under the code so you are never left wondering what was dropped.

Working with API payloads? The JSON formatter tidies a response body, the Base64 encoder handles token and credential encoding, the JWT decoder inspects bearer tokens, and the URL encoder escapes query strings.

Frequently asked questions

How does the curl converter work?
It reads your curl command exactly like a shell would - respecting single quotes, double quotes, escaped characters and backslash line continuations - then maps each flag to the equivalent in your chosen language. The whole thing runs in your browser, so the command and any tokens in it never leave your device.
Which curl flags are supported?
The common ones: -X/--request for the method, -H/--header for headers, -d/--data and its variants for the body, --json for JSON payloads, -u/--user for basic auth, -F/--form for multipart uploads, -b/--cookie, -A/--user-agent and -e/--referer. Flags that have no code equivalent, like --compressed or -L, are ignored and listed in a note under the output.
How is a JSON body converted?
When the content type is application/json, or the body is valid JSON, the tool emits a native object rather than a raw string: JSON.stringify(obj) for fetch, the json= parameter for Python requests, and a data object for axios. That keeps the generated code idiomatic instead of pasting an escaped string.
What does -u do in the output?
It becomes an Authorization header. curl -u alice:secret sends HTTP basic auth, which is the base64 of "alice:secret" (YWxpY2U6c2VjcmV0) prefixed with "Basic". The converter adds that header for you so the request behaves the same way.