UTILS.
100% in-browser
🌀

cURL to Code Converter

Paste a curl command and get an equivalent JavaScript fetch() snippet — method, headers, body and auth.

output

About this tool

cURL to Code Converter is a free, in-browser tool that turns a curl command into equivalent JavaScript fetch() code. Paste the command you copied from a terminal, an API doc or browser dev tools, and it emits a ready-to-run snippet with the URL, HTTP method, headers, request body and authentication filled in. The command is parsed as text only — it is never executed — and everything happens locally in your browser.

A quote-aware tokenizer splits the command the way a shell would, respecting single and double quotes, backslash escapes and \ line continuations, so multi-line commands and quoted JSON bodies parse correctly. It then maps the common flags: -X or --request sets the method, -H or --header builds the headers object, -d and its --data variants become the request body (which implies POST), -u or --user is encoded into a Basic Authorization header, -F or --form assembles a FormData body, and cookies, user-agent and referer flags map to their headers. Boolean flags like -L, -k and -s are ignored.

Use it to move a working curl call into a Node or browser script, to learn how a documented request maps onto the Fetch API, or to prototype against an API quickly. Because nothing is run and nothing is uploaded, you can paste commands containing tokens safely — though you should still rotate any secret you paste into a shared machine.

Frequently asked questions

Does the tool run the curl command?
No. It only parses the command as a string with a hand-written tokenizer and generates code — it never makes a network request or executes anything. That means it is safe to paste a command locally, but treat any credentials in it with the usual care.
Which curl flags are supported?
The common ones: -X/--request for the method, -H/--header for headers, -d and the --data-* family for the body, -F/--form for multipart FormData, -u/--user for Basic auth, plus -b (cookie), -A (user-agent) and -e (referer). Boolean flags such as -L, -k, -s and --compressed are recognised and skipped.
How is -u user:password handled?
It is turned into an Authorization: Basic header with the user:password string Base64-encoded, matching what curl sends. The encoded value is written straight into the generated headers object so the snippet works as-is.
Why does my request default to POST?
curl uses POST automatically when you send data with -d or -F, so the converter does the same unless you set an explicit method with -X. GET is used when there is no body and no method is given. All parsing runs privately in your browser with no external libraries.

More tools