Skip to content

cURL to Code Converter

cURL to Code Converter

Paste any cURL command and get the equivalent code in JavaScript fetch, Python requests, Node.js axios, Go, PHP, Ruby, Java, or C#. Headers, body, authentication, and query parameters all carry over correctly. The cURL stays the source of truth; the generated code is a transcription, not a reinterpretation.

Why cURL Stays the Lingua Franca of HTTP

Every API doc has a cURL example. Every browser's Network tab has Copy as cURL. Every shell prompt has cURL available. It became the default way humans describe an HTTP request to other humans, and that convention isn't going anywhere. The friction is that the moment you want to put the request into a real program, you have to translate the cURL flags into whatever your language's HTTP client wants — and the mapping isn't always obvious.

Some flags translate cleanly: -H is a header, -d is a body, -X POST is a method. Others have surprising mappings. --data-urlencode requires the body to be percent-encoded but the Content-Type to be application/x-www-form-urlencoded. -u user:pass is HTTP Basic auth, which in fetch becomes an Authorization header with the credentials base64-encoded. --cookie-jar is a session feature most fetch-style clients don't have at all. Getting these right by hand for every request gets old.

How It Works

The cURL command is tokenized using shell-aware parsing — quoted strings are kept whole, escapes are honoured, and line-continuation backslashes get folded. Each flag is mapped to its semantic meaning (header, body, auth, method, URL, etc.) and then re-emitted in the target language's idiom. JavaScript fetch goes through a fetch(url, options) call; Python requests becomes requests.request(method, url, **kwargs); Go becomes a net/http client with the request object built explicitly.

The generated code is intentionally beginner-friendly — it imports the standard HTTP library, builds the request explicitly with named variables, and adds error handling. Experienced developers can shorten it; the verbose version is easier to learn from and harder to misread.

Reverse direction (code to cURL) is the natural follow-up. Paste a generated fetch call back into the JSON formatter for inspection, or pipe a generated request body through the URL encoder to verify the encoding.

Common Use Cases

Promoting an API call from the browser DevTools Network tab into a script. Sharing a working request with a teammate whose language isn't yours. Generating starting code for a Postman-equivalent test. Translating an API doc's cURL example into the boilerplate your codebase uses. Verifying that your client library is sending the exact same bytes as the cURL you tested with — when the cURL works and the code doesn't, the diff is usually a header.

Worked example: the generated code against real curl

Parsing now follows shell quoting and curl's own data rules. On October 13, 2026 we ran nine commands with curl 8.5.0 against a local echo server, then ran the JavaScript (Node 22 fetch) and Python (requests 2.33) code this page generated for the same commands: method, path and query, Content-Type and body matched curl in 9 of 9 cases for both languages, including multipart uploads compared field by field.

CommandBefore (v218)Now
-d a=1 -d b=2only b=2 senta=1&b=2, with the form Content-Type curl adds
-G -d q=xsent as a POST bodyGET with ?q=x in the URL
--data-urlencode 'msg=a b&c'sent unencodedmsg=a+b%26c
--json '{"a":1}'taken as the URLPOST with application/json body and Accept header
-F f=@file -F name=BoskippedFormData (JavaScript) or files=/data= (Python); other languages say multipart is not generated
$'line1\nline2' (Chrome's "Copy as cURL")the $ and escapes read literallyANSI-C quoting decoded
-d @body.jsonthe text "@body.json" sent as the bodya FILE_CONTENTS placeholder and a note
Responsealways response.json()json() only when the request expects JSON, otherwise text

Sources

Checked on .

Frequently Asked Questions

Which cURL flags are supported?+
-X, -H (including header removal with "Name:"), -d/--data, --data-raw, --data-binary, --data-urlencode, --json, -F/--form, -G, -u, -A, -b, -e, -I, --url and -k (reported). Repeated -d values are joined with & as curl does, and options that cannot be translated are listed as notes above the code.
Does it support multipart/form-data?+
Yes for JavaScript (FormData) and Python (requests files= and data=): every -F field is kept, and file fields become a file input or open(). PHP, Go, Ruby, C# and PowerShell output says multipart is not generated for them.
Will it work with cURL from DevTools 'Copy as cURL'?+
Yes. Shell quoting is parsed the way bash does it, including $'...' strings with \n and \t escapes that Chrome and Firefox use for bodies with special characters, and segments joined with '\''.
Is the command sent to any server?+
No. All parsing and code generation happens in your browser. Your cURL command, headers, and any auth tokens never leave your device.
Which target languages are supported?+
JavaScript (fetch, axios), Python (requests, httpx), Node.js, Go, Ruby, PHP, Java (OkHttp), C# (HttpClient), Swift (URLSession), and plain raw HTTP for debugging. Pick from the dropdown.
Does it handle complex curl flags?+
The data options follow curl's rules: -G turns data into a query string, --data-urlencode encodes, --json sets the JSON content type and Accept header. In our test against real curl 8.5, nine commands (forms, JSON, query strings, multipart, quoting) produced the same requests from the generated JavaScript and Python. Files referenced with @ cannot be read in the browser, so they become placeholders with a note.
What about authentication headers?+
Basic auth (--user) becomes the right language idiom (e.g., requests.auth in Python). Bearer tokens passed via --header survive intact. The tool flags possible secret values for review before pasting elsewhere.
Can I reverse-translate code back into curl?+
Not currently — the tool flows in one direction. For testing your generated code, the API Request Builder lets you experiment with the same request without writing code at all.
What about file uploads and multipart forms?+
-F name=@file becomes a FormData file field in JavaScript (choose the file with an <input type="file">) and a files= entry with open() in Python; plain -F name=value fields are sent as form fields. Other languages get a comment saying multipart is not generated.

Built by Derek Giordano · Part of Ultimate Design Tools

Privacy Policy · Terms of Service