cURL to fetch Converter
Convert cURL commands to browser-compatible JavaScript fetch() calls. Preserves headers, methods, bodies, and query strings.
How it works
cURL is the universal HTTP client for terminals, and fetch is the universal HTTP client for browsers and modern Node. Copying a curl command from API docs or DevTools and translating it into fetch by hand is tedious — you have to re-quote the URL, rebuild a headers object, JSON-stringify the body, and remember to set the method.
This converter parses curl arguments the same way a POSIX shell would: backslash-newline continuations are stripped, quoted strings are respected, and `-H`, `-d`/`--data`, `--data-raw`, `--data-urlencode`, `-X`, `-u`, and `--cookie` flags are extracted. The URL is the last non-flag positional argument. If a body is present and no explicit method was set, POST is inferred.
JSON bodies are detected by looking at Content-Type or by trying `JSON.parse` on the raw body. When detected, the output uses `JSON.stringify` to keep the source readable. Form-encoded bodies become URLSearchParams. Basic-auth `-u user:pass` is converted into an `Authorization: Basic ...` header using `btoa`. Unknown flags are silently ignored so paste-from-Chrome-devtools works even when flags like `--compressed` are present.
Frequently asked questions
- Does this support --data-urlencode?
- Yes. Form-encoded bodies become URLSearchParams in the fetch output.
- What about cookies and --cookie flags?
- Cookies are emitted into the headers map as a single `Cookie` header. For cross-origin requests you may also need `credentials: "include"`.
- Are multi-line curl commands supported?
- Yes. Trailing backslashes in shell are stripped before parsing, so you can paste multi-line curl straight from a terminal.
Related tools
- cURL to Python requests ConverterConvert cURL commands to Python using the requests library. Generates idiomatic code with headers dict, json= or data= body, and timeout.
- JSON to YAML ConverterConvert JSON to clean, human-readable YAML instantly. Runs fully in your browser — no upload, no tracking.
- YAML to JSON ConverterConvert YAML to JSON (pretty-printed, 2-space indent) in your browser. Handles anchors, multi-doc files, and nested structures.
- JSON to CSV ConverterConvert a JSON array of objects to CSV online. Auto-detects columns, escapes quotes, supports nested fields via dot notation.