What does this tool do?
The cURL to Fetch tool converts cURL commands written for the terminal into ready-to-run JavaScript fetch() code. It automatically parses the URL, HTTP method, headers and body to produce a block with async/await and error handling. It is ideal for developers who want to quickly turn API documentation examples into working code.
How to use it
- Enter your configuration details.
- Review the generated output.
- Copy the ready-to-use code or file.
Which cURL options are supported
The tool recognizes the URL, the method via -X, headers via -H, and the body via -d / --data / --data-raw. It also detects the --json flag introduced in curl 7.82+ and automatically sets the Content-Type and Accept headers to application/json. When you pass -u user:pass, the credentials are Base64-encoded and added as an Authorization: Basic header. If the body is valid JSON it is reformatted cleanly; otherwise it is preserved as-is.
Practical tips
Use the example buttons to try GET, POST with JSON, Basic Auth and PUT scenarios in one click. Even if you split multi-line commands with a backslash (\), the tool joins them onto a single line and parses correctly. If you only pass -d without specifying a method, the request is automatically upgraded to POST. The generated code includes a response.ok check and a response.json() call, so you can paste it straight into your project.
Frequently asked questions
What happens if I pass -d but no -X?
Just like cURL, sending a body changes the request from the default GET to POST. The tool detects this automatically and uses method: 'POST' in the fetch output.
Are Basic Auth credentials encoded safely?
With -u user:pass, the credentials are Base64-encoded using the browser's btoa function and written into an Authorization: Basic header. Everything runs on your device; your credentials are never sent to any server.
Is cURL to Fetch free?
Yes. cURL to Fetch and all 300+ tools on MagmaNex are completely free with no signup or account required.
Is my data safe?
Yes. Everything runs locally in your browser. The data you enter is never sent to a server, stored, or shared.
Does it work on mobile?
Yes. cURL to Fetch works on phones, tablets and desktops — no app download needed.
🔒 Privacy: everything runs in your browser, your data is never sent to a server.
