Curl to Fetch
This free curl to fetch converter turns a cURL command — the one buried in API docs or copied from browser devtools — into ready-to-run JavaScript fetch code, entirely in your browser.
How to use
- Paste the curl command from docs, a README, or your terminal history.
- Read the generated fetch code: method, headers object and body are laid out with 2-space indentation.
- Check the comment block at the top — skipped flags such as -F and ignored ones like --compressed are listed there; unknown flags stop the conversion with an error instead of being guessed.
- Broken input (an unterminated quote, a missing URL) reports the exact position instead of generating wrong code.
Frequently asked questions
Which curl flags are supported?
Positional URLs plus --url, -X/--request, repeated -H/--header (same-name headers keep the last value), -d/--data/--data-raw/--data-binary (joined with &, implying POST when no method is given), and -u/--user converted to Authorization: Basic with UTF-8-safe base64. This covers the overwhelming majority of documented API examples.
What happens to -F / --form (multipart uploads)?
Multipart/form-data is not supported, and the tool says so: the flag is skipped, a warning is added as a comment at the top of the generated code, and the stats counter increments. Because the body cannot be reproduced, the request is not turned into an implied POST either — you will need to build the FormData yourself.
Does it generate axios or other HTTP clients?
No — output is plain JavaScript fetch only. fetch is built into every modern browser and Node 18+, so the snippet runs as-is; if you use another client you can still read the method, headers and body from the generated structure.
How are quotes and line continuations handled?
The parser understands single quotes (fully literal), double quotes with backslash escapes, bare escapes, attached values like -XPOST or -H"X: 1", and trailing backslash line continuations from multi-line terminal pastes. An unterminated quote fails fast with the position where it started, instead of silently mis-splitting the command.
Why does my -d request come out as POST with a specific Content-Type?
That is what curl does on the wire: any -d/--data flag sends POST when no method is set, and its default body type is application/x-www-form-urlencoded. The generated code mirrors that behavior, and if you already pass a Content-Type header it is kept untouched.
Is my command uploaded anywhere?
No. Parsing runs locally in your browser tab, so commands containing internal hostnames, tokens or session cookies never leave your device.
Related tools
About this tool
This free curl to fetch converter turns a cURL command — the one buried in API docs or copied from browser devtools — into ready-to-run JavaScript fetch code, entirely in your browser. It understands the flags you actually meet in the wild: the positional URL, -X/--request for the method, repeated -H/--header entries, -d/--data/--data-raw/--data-binary bodies (which imply POST and pick up the same default Content-Type curl sends), -u/--user translated into an Authorization: Basic header with proper UTF-8 base64, and --url. It is honest about what it does not do: -F/--form reports plainly that multipart is not supported and is skipped rather than silently dropped, --compressed is ignored with a count, unknown flags stop the conversion with an error and their position, -L gets an explanatory note since fetch follows redirects by default, and the output is fetch only — no axios. Quoted values (single, double, and attached forms like -XPOST) are parsed with position-reported errors for unterminated quotes, so a mangled paste fails loudly instead of producing subtly wrong code. Nothing is uploaded: the parsing happens locally, making it safe for internal APIs and authenticated endpoints.