cURL to fetch() Converter
Turn a curl command into a JavaScript fetch call.
fetch()
fetch("https://api.example.com/users", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer abc123",
},
body: JSON.stringify({
"name": "Ada",
"role": "admin"
}),
})
.then((res) => res.json())
.then(console.log);Handles -X, -H, -d/--data, -F/--form, -u, line continuations, and quoted arguments. JSON bodies are pretty-printed with JSON.stringify.
About
Paste a curl command (the kind you copy from Chrome DevTools). Get an equivalent fetch() call. Headers, body, method, and credentials are translated.
How to use
- Paste your curl command.
- Copy the fetch() code.
FAQ
Does it handle multipart uploads?+
Yes for simple cases. Multipart with multiple files needs FormData; the conversion shows the structure but you may need to tweak.
Why does my converted fetch fail with CORS?+
Curl doesn't have CORS. Browsers do. Some APIs work in curl but block fetch from a browser. Not a converter bug.