Utilo

curl to fetch Converter – Free, Online, Private

Turn a curl command into a JavaScript fetch call, including method, headers and a JSON body.

Input
Output

How to convert curl to fetch

  1. Paste a curl command. It must start with curl. Line continuations with backslash are fine.
  2. Read the fetch call. Headers and method are copied from the flags you set.
  3. Copy it into a browser or a modern Node script. File uploads are noted, not invented.

What is translated

The parser reads the method from -X, headers from -H, the URL, and the body from -d, --data-raw or --json. Basic auth in -u becomes an Authorization header. A JSON content type causes the body to be passed through JSON.stringify of the parsed value so the snippet shows an object rather than one escaped string. The call uses fetch, then res.json() when the body or Accept header looks like JSON, otherwise res.text(). Redirect handling is set to manual only when curl was told not to follow redirects. The snippet is async and expects to run where fetch exists.

Flags that do not map cleanly

curl has hundreds of flags. Cookies, proxies, retry counts, and output files are not all reproduced. A multipart form built with -F becomes a FormData sketch. A file reference such as -d @body.json is kept as a literal warning rather than read from your disk, because the page cannot see your filesystem. TLS insecure mode does not become a Node option on the fetch path; fetch in browsers cannot disable certificate checks. The full curl converter on Utilo covers more targets, including axios, Go, Node's http module and PHP. This page is the fetch-shaped one.

Worked example

The sample POST to /v1/users carries a bearer token and a JSON name and role. The fetch call sets method POST, both headers, and a body built with JSON.stringify. The URL is a string. The token is the characters you pasted, so replace TOKEN before you run it, and do not commit the real secret that a copied command sometimes still contains. If the shell used single quotes around the command, the parser accepts them. Windows caret continuations are also joined.

Secrets

A curl copied from a terminal often includes an Authorization header. This page does not upload the command, which is necessary but not sufficient: the snippet you copy still contains the header. Rotate anything you pasted into a chat by mistake. The conversion itself stays in the tab.

Frequently asked questions

Does it support --json?

Yes. curl's --json flag sets the body and the JSON content type, and the fetch snippet stringifies that object.

What about -u user:pass?

It becomes an Authorization: Basic header. The password is still in the snippet, so treat it as a secret.

Can I convert fetch back to curl?

The main curl converter on Utilo can turn some fetch and requests snippets back into curl. This page is one direction.

Is the command uploaded?

No. The parser runs locally.