Cryonel

cURL to Fetch Converter

Paste a common cURL request and generate readable browser Fetch API JavaScript. The converter runs locally, never executes the request, and keeps tokens and request bodies in your current tab.

How to use it

  1. Paste a cURL command copied from API documentation, DevTools, Postman, or a terminal.
  2. Select Convert to Fetch or press Ctrl/ + Enter.
  3. Review the generated URL, method, headers, and body before running the JavaScript in your application.
  4. Copy or download the result. Test it only against an API you are authorized to access.

cURL to Fetch example

A typical JSON request uses an explicit method, a content type, an authorization header, and a request body:

curl -X POST https://api.example.com/v1/users \
  -H 'Authorization: Bearer test-token' \
  -H 'Content-Type: application/json' \
  -d '{"name":"Ada","active":true}'

The result calls fetch() with method: "POST", a JavaScript headers object, and a JSON-stringified body. It then checks response.ok because Fetch resolves its promise even when an HTTP response has a 404 or 500 status. The generated code reads the response as text so it remains correct for JSON, HTML, empty responses, and other payload types. Change response.text() to response.json() only when the API contract guarantees JSON.

Supported cURL options

The converter handles the most common request-building options: -X or --request for the method, -H or --header for headers, -d, --data, --data-raw, and literal --data-binary values for bodies, -u or --user for Basic authentication, -I for a HEAD request, and -L for redirect following. Silent and compressed-output flags are safely ignored because they control cURL output rather than the browser request.

When body data is present without an explicit method, cURL behaves like a POST request, so the generated Fetch request does the same. A body without a content type receives application/x-www-form-urlencoded, matching cURL’s default for --data. Multiple data values are joined with an ampersand. JSON is formatted inside JSON.stringify() only when the command declares an application/json content type and the body is valid JSON.

Browser differences and limitations

A command that works in a terminal may still fail in a browser. Browsers enforce Cross-Origin Resource Sharing, so the target API must allow the site origin, HTTP method, and requested headers. cURL has no equivalent browser-origin restriction. The converter cannot bypass CORS and does not add a proxy.

Browsers also control headers such as Cookie, Host, and Content-Length. Cookie files, client certificates, insecure TLS mode, multipart forms, file-backed bodies such as @payload.json, and --data-urlencode do not have a safe one-to-one translation in this first version. Cryonel reports those options instead of silently generating code with different behavior. For cookie-authenticated APIs, configure the server’s CORS and cookie policy, then deliberately add credentials: "include" after reviewing the security impact.

Security and privacy

cURL commands often contain bearer tokens, API keys, Basic authentication credentials, and private payloads. This tool parses the text entirely in the current browser tab and does not execute the URL. Generated code can still contain those secrets in plain text. Remove or replace credentials before sharing, committing, logging, or pasting the result into an issue. Prefer short-lived development credentials and environment-based secret injection in real applications.

Common conversion errors

Frequently Asked Questions

Does this converter send or run my cURL command?

No. Cryonel parses the command and generates JavaScript inside your browser. It does not execute the request or upload the command.

Why can a converted Fetch request fail because of CORS?

cURL is not restricted by browser cross-origin rules. Browser Fetch requests require the target server to allow the page origin through CORS.

Can Fetch set Cookie or Host headers from cURL?

No. Browsers control forbidden request headers such as Cookie, Host, and Content-Length. The converter reports these differences instead of producing misleading code.

Related Tools