RunTheTests
/

cURL Command Parser

Read a curl command back in plain terms, and convert it to fetch or Python.

What you provide

How this calculation works

The command is tokenised the way a shell would, so quoted values and line continuations survive, and the flags are read into a request: method, headers, body, authentication. From there it is rendered as fetch or as Python requests. Flags that have no equivalent are listed rather than dropped, because a silently discarded flag is how a converted request stops behaving like the original — the certificate-verification flag in particular, which a browser cannot reproduce at all and which is usually hiding the very failure it was added to work around.

What the results mean

Untranslated flags
Options that affect output or transport rather than the request. Listed so the difference between the two versions is visible.
Method inference
A command with a body and no explicit method is a POST, which is what curl itself assumes.
Basic authentication
The -u flag becomes an Authorization header, which needs the credentials base64-encoded in the converted code.
Browser-controlled headers
Host, Origin, Referer, Cookie and User-Agent cannot be set from fetch. If the request depends on them, it will behave differently in a browser.

Common problems and fixes

The converted fetch call fails with a CORS error
A command-line client is not subject to the same-origin policy and a browser is. The endpoint has to send the right CORS headers, and no amount of adjusting the request will substitute for that.
The request works in curl and not in the browser
Check the headers the browser controls. Cookie, Origin, Referer and User-Agent are silently ignored in fetch, and an API that depends on them behaves differently.
The command uses --insecure
That disables certificate verification, which a browser cannot do. It is worth finding out what certificate problem was being worked around before relying on the request.

Frequently asked questions

How do I convert a curl command to fetch?

Paste it above. The method, headers and body are extracted and rendered as a fetch call. Watch the untranslated flags, and remember that a browser controls several headers itself — a request that depends on Cookie or Origin will not behave identically.

Why does the converted request behave differently?

Three usual reasons: the same-origin policy applies in a browser and not on the command line, several headers cannot be set from JavaScript, and flags like certificate-verification skipping have no browser equivalent. The untranslated list above shows which of these apply to your command.

Put this on your own site

Free to embed, no attribution required beyond the source link the frame carries itself. It runs entirely in your visitor's browser, sets no cookies and loads no third-party script.

Embed code
<iframe src="https://runthetests.com/embed/curl-parser/" width="100%" height="560" style="border:1px solid #e5e5e5;border-radius:8px" title="cURL Command Parser" loading="lazy"></iframe>

Preview it at https://runthetests.com/embed/curl-parser/. Embedded pages are marked noindex, so yours stays the canonical copy — not this one.

More in DevOps