Tech

cURL to code converter

Paste a cURL command and we return the equivalent code in JavaScript (fetch), Node.js or Python (requests). Method, headers, JSON body, auth and cookies included.

Instant🔒In your browserNo signup
Live
Generated code

Turn a cURL command into code in seconds

Almost every API documentation shows its examples as cURL commands: they are short, universal and run from any terminal. The friction shows up when you want to bring that request into your real application and have to translate the method, every header, the body and the authentication by hand. This tool does that work for you: you paste the curl exactly as you copied it from the docs, from Postman or from the "Copy as cURL" option in Chrome DevTools, pick the target language and get a snippet ready to paste. It supports the most common flags (-X, -H, -d, -u, -b, --compressed, -F, -L), detects when the body is JSON and formats it, and builds basic authentication when it finds -u. Everything runs in your browser, so you can convert requests with tokens without anything leaving your machine. Ideal for quickly testing an endpoint, migrating a docs example to your backend or understanding what a command someone handed you actually does.

How it reads your command

The converter tokenizes the command respecting single and double quotes, just like a terminal would, and it also understands line continuation with a backslash. That means a command written across several lines like this is interpreted as a single one:

curl https://api.example.com/login \\
  -H "Content-Type: application/json" \\
  -d '{"user":"ana","pass":"1234"}'

From the tokens, the parser separates the URL, the method (if there is no -X, it uses GET, or POST when there is a body), the headers and the body. If the body starts with or [ and is valid JSON, it formats it with indentation so it looks clean in the generated code.

What it generates for each language

  • JavaScript (fetch): browser style, with fetch(url, options) and chained .then() / .catch(). Basic auth uses btoa().
  • Node.js: the native fetch from Node 18 or newer, inside an async function with await. Basic auth uses Buffer.from(...).
  • Python (requests): uses the requests library, with json= when the body is JSON, data= when it is plain text, auth=(user, pass) for -u and files= for -F.

Reference table: cURL flags and their equivalent

FlagWhat it doesEquivalent in fetch / requests
-X, --requestSets the HTTP method (GET, POST, PUT...).method: "POST" / requests.post()
-H, --headerAdds a Key: Value header.key in headers / headers dict
-d, --dataRequest body (implies POST).body / data= or json=
-u, --userBasic authentication user:pass.Authorization: Basic / auth=(u, p)
-b, --cookieSends cookies with the request.Cookie header / cookies=
--compressedRequests a compressed response (gzip).Accept-Encoding (fetch handles it)
-F, --formmultipart/form-data upload.FormData / files=
-L, --locationFollows redirects (3xx).redirect: "follow" / allow_redirects=True

What it is for day to day

  • Migrating an API documentation example to your backend or frontend.
  • Reproducing in code a request you captured with "Copy as cURL" in DevTools.
  • Moving a request from Postman or Insomnia into a Python script.
  • Understanding what a long curl command someone shared actually does.
  • Quickly testing an endpoint without writing the fetch or requests boilerplate by hand.

FAQ

How do I get the cURL command from Chrome DevTools?

Open DevTools (F12) > Network tab, reload and reproduce the action. Right-click the request > "Copy" > "Copy as cURL". Paste that command here.

Is my cURL command uploaded to any server?

No. All the parsing happens in your browser with JavaScript. The command never leaves your machine, so you can convert requests with tokens without risk.

Does it support file uploads with -F (multipart)?

Yes. The -F / --form flags become FormData in JavaScript and Node, and files= in Python. Fields with @ generate a placeholder for your file.

What happens with cookies and authentication?

-u user:pass becomes an Authorization Basic header (or auth=() in Python) and -b / --cookie becomes a Cookie header. Headers from -H are copied as-is.

Why does my command with special characters fail?

The parser respects quotes and line continuation, but if you mix quotes without escaping or paste a fragment without the URL, the result is incomplete. Check that quotes are balanced.

Which languages can I generate?

Three: JavaScript with fetch (browser), Node.js with native fetch (async/await) and Python with requests. Switch with the tabs and it regenerates instantly.

Can I paste a cURL from Postman or Insomnia?

Yes. Those tools export the request as cURL; that command works just like a hand-written one.

Which HTTP method is used when there is no -X?

GET by default, just like cURL. But if there is a body (-d) or a form (-F), it assumes POST. You can force any method with -X.

Was this generator useful?