Skip to content

How cURL → fetch works

Paste a curl command and get equivalent JavaScript fetch() code. Toggle between a browser snippet and a Node 18+ version. Headers, methods, JSON bodies, and basic auth are all carried across.

A shell-aware tokenizer parses the command (respecting quotes and line continuations), then the flags are mapped to a fetch() options object. JSON bodies are pretty-printed. Runs entirely in your browser.

Questions

Which curl flags are understood?
Method (-X/--request), headers (-H/--header), data (-d/--data/--data-raw/--data-binary), basic auth (-u/--user), and the URL. Common no-op flags like --compressed and -s are ignored.
Does it pretty-print JSON bodies?
Yes. If the -d payload is valid JSON, the output wraps it in JSON.stringify with indentation. Non-JSON bodies are passed through as a string.
What is the difference between Browser and Node?
The Node variant adds a comment noting it targets Node 18+ where fetch is global. The fetch call itself is identical; both assume top-level await.
Is my command sent anywhere?
No. Parsing and code generation happen entirely in your browser.

More Text & Data tools

All the tools · How to check that nothing is sent

cURL to fetch() Converter | Only in the Tab