cURL to Fetch Converter
Paste a curl command and see its equivalent JavaScript fetch() call, with headers and body mapped across — handy when porting an API example from docs into a script. Runs entirely in your browser.
🔒 This tool runs entirely in your browser. Your files are never uploaded to a server.
Example
cURL to Fetch Converter
curl -X POST https://api.example.com/v1/users \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"Jane Doe","role":"admin"}' Example shown — replace it with your own curl command.
Equivalent fetch() call
fetch("https://api.example.com/v1/users", {
method: "POST",
headers: {
"Authorization": "Bearer TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({ name: "Jane Doe", role: "admin" })
}); How it works
- Paste a curl command copied from API docs or a terminal history.
- The method, headers, and body are mapped onto a fetch() call.
- Copy the JavaScript straight into your script.
FAQ
What curl options does this handle?
The common ones you'll hit when copying an example from API docs: -X/--request for the method, -H/--header for headers, and -d/--data for a JSON body.
Does the output work in Node.js too?
The generated fetch() call works in any modern browser and in Node 18+, which ships fetch built in — for older Node versions you'd need a polyfill like node-fetch.
Is my curl command sent anywhere?
No — the conversion happens entirely in your browser. Nothing, including any tokens in your command, is uploaded to a server.
How we compare
| Feature | Online Tool Store | Rewriting the request by hand | Postman's "Generate code" panel |
|---|---|---|---|
| No account or app required | Yes | Yes | No |
| Fast for a single pasted command | Yes | Slow | Extra steps |
| Headers and body mapped automatically | Yes | Manual | Yes |
For a one-off curl example from docs, this is quicker than retyping the request by hand or opening a full API client.