cURL to JavaScript fetch() Converter
Paste a curl command and get a JavaScript fetch() equivalent. Handles method, headers, JSON and form bodies, and HTTP Basic auth (-u). Great for copying API docs into code.
Runs 100% in your browser — nothing is uploaded.
POST2 headersbodyhttps://api.example.com/users
JavaScript (fetch)
const res = await fetch("https://api.example.com/users", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer sk_test_abc",
},
body: "{\"name\":\"Ada\",\"role\":\"admin\"}",
});
const data = await res.json();Frequently asked
Which curl flags are supported?
-X/--request, -H/--header, -d/--data/--data-raw/--data-binary/--data-urlencode, -u/--user (Basic auth), --url, and the positional URL. Flags that don't map to fetch (-k, -L, --compressed, -s, -v, -o) are silently ignored.
Does it work with multi-line curl?
Yes — line-continuation backslashes are handled, so you can paste directly from a `curl` example in docs.
What about Node vs browser fetch?
The output is standard `fetch()` compatible with modern browsers and Node 18+. `Authorization: Basic …` is generated for `-u user:pass`; other auth schemes need to be added by hand.
Related tools
- HTTP Headers ReferenceEvery common HTTP header explained, grouped by purpose. Searchable by name or ke
- HTTP Status CodesEvery HTTP status code you need to know, grouped by category, with plain-English
- JSON FormatterFormat, validate, and minify JSON in your browser. See parse errors with line/co
- .env File ParserParse a .env file and see it as a JSON object. Handles comments, quoted values,
- Base ConverterConvert numbers between binary, octal, decimal, and hexadecimal. Supports huge n
- Credit Card ValidatorValidate credit card numbers with the Luhn algorithm and detect the brand: Visa,