cURL to fetch
Convert a copied cURL API request into browser fetch code.
- 1Add input
- 2Review and run
- 3Get your result
Tool input and files are processed in this browser without being uploaded.
Before you start
Paste an HTTP(S) cURL request to generate browser fetch code. Check the method, headers and body before copying; the converter never runs the request.
How to use this tool
- Paste one cURL command copied from API documentation or a terminal.
- Review the parsed method, host, headers and body size. Fix any unsupported option shown below the input.
- Generate, inspect and copy the JavaScript. Check secrets and browser CORS behavior before using it.
Supported inputs and limits
Supports one HTTP(S) URL, -X/--request, -H/--header, repeated -d/--data or --data-raw, --data-binary, --json, --url, -G/--get, -I/--head, -L/--location, --compressed and -v/--verbose. Verbose diagnostics are omitted. Local file bodies, shell expansion and other options are rejected.
Browser fetch cannot set Cookie, Host, Content-Length and other forbidden headers. Such requests are rejected. CORS, credentials and redirects can still differ from cURL. Generated code cannot verify or fix server-side API behavior.
Conversion runs in this browser. No network request is sent and no account is needed.
Worked example
Example input
curl -L -H 'Accept: application/json' --data-raw 'name=Mori&role=dev' https://example.com/api
Example options
{}Example output
const response = await fetch("https://example.com/api", {
"method": "POST",
"headers": [
[
"Accept",
"application/json"
],
[
"Content-Type",
"application/x-www-form-urlencoded"
]
],
"body": "name=Mori&role=dev",
"redirect": "follow",
"credentials": "omit"
});
When something does not work
Remove unsupported flags, shell expansion, file bodies and browser-forbidden headers. Paste one complete HTTP(S) request and review generated code.
Frequently asked questions
Does this run the cURL request?
No. The command is parsed locally into text. The site never sends the request or reads local files named by the command.
Why does a copied browser cURL command fail?
Browser fetch cannot set headers such as Cookie, Host or Content-Length. Remove those headers and decide how your application will authenticate. Unsupported shell features and file bodies are also rejected.
Will fetch behave exactly like cURL?
No. Browser CORS and credential rules apply. Generated code omits credentials and follows redirects only when -L/--location is present. Manual cross-origin redirects may yield an opaque response. Review response handling and any embedded tokens before sharing code.
Documentation & further reading
Related tools
JSON formatting workspace
Format or minify strict JSON, sort object keys, and encode or decode strings while preserving raw number tokens.
Regex tester
Try a pattern and see what it matches in your text.
Compare text
See what changed, side by side.
HTML formatter
Format HTML indentation so its structure is easier to read.