cURL ↔ Code Converter

Paste a cURL command to get equivalent JavaScript, Python, Node.js, PHP, and Go — or paste code to get the cURL command back. Runs entirely in your browser.

Last updated

cURL command

Convert a cURL command above to see JavaScript fetch code here.
Copied
Convert a cURL command above to see Node.js code here.
Copied
Convert a cURL command above to see Python requests code here.
Copied
Convert a cURL command above to see PHP code here.
Copied
Convert a cURL command above to see Go code here.
Copied

Reverse: code → cURL

The equivalent cURL command will appear here.
Copied
Limitation: this direction is a best-effort pattern match, not a JavaScript or Python interpreter. It recognises a single literal fetch(url, options) call or a single literal requests.get/post/put/patch/delete(url, ...) call, with the URL, method, headers, and body/json/data written as plain string, number, or object literals directly in the call. It cannot resolve variables, template-literal interpolation, imported helper functions, chained builders (e.g. axios instances), or multi-statement setup code — paste just the call itself for best results.

How to convert a cURL command to code

  1. Paste a cURL command, for example copied from your browser’s developer tools.
  2. Click Convert and choose JavaScript fetch, Node.js, Python, PHP or Go.
  3. Click Copy code. To go the other way, paste a fetch or requests call and click Convert to cURL.

About this tool

The forward direction parses your cURL command the way a shell would: it respects single and double quotes, backslash line continuations, and escaped characters, then reads the flags cURL itself understands — -X/--request, -H/--header, -d/--data (and its --data-raw/--data-binary/--data-urlencode variants), -F/--form for multipart uploads, -u/--user for basic auth, -b/--cookie, -A/--user-agent, and -e/--referer. From that it builds one normalised request model — method, URL, headers, and body — and renders it into each language's idiomatic client: fetch for the browser, Node's built-in fetch (Node 18+) wrapped in an async function, Python's requests library, PHP's curl_* functions, and Go's net/http. A body is treated as JSON when a Content-Type: application/json header is present or the payload parses as JSON on its own; otherwise it's sent as form-urlencoded or raw, matching what cURL itself would actually put on the wire.

Basic auth (-u user:pass) is converted into an explicit Authorization: Basic … header using the browser's own base64 encoder, so the generated code doesn't depend on each language's auth helper behaving identically. Multipart form fields (-F) become a FormData/multipart/form-data body in each target language, including a marked distinction between plain fields and file uploads (-F "file=@path").

Nothing you paste is sent anywhere — parsing, code generation, and syntax highlighting all run as JavaScript in your browser tab.

Questions about cURL

How do I copy a request as cURL?

In Chrome, Edge or Firefox developer tools, open the Network tab, right-click a request and choose Copy as cURL.

Which cURL options are supported?

Method (-X), headers (-H), data (-d and its variants), form uploads (-F), basic auth (-u), cookies (-b), user agent (-A) and referer (-e).

Is it safe to paste commands with API keys?

It’s converted in your browser and never sent anywhere. Still, remove real keys before sharing the result.

Which Python library does it use?

requests, the most widely used HTTP library for Python.

☕ Support toolcrate