Convert cURL to Fetch
Turn cURL commands into browser-ready fetch code for JavaScript apps.
Try it now
Try it now
Open cURL Converter with a ready-to-run example.
When you need this
- You need to port a cURL command into frontend code.
- You are sharing API examples with a JS team.
- You want to quickly test headers and payloads with fetch.
How to do it with Daily Developer Tools
- Paste the cURL command into the cURL Converter.
- Select fetch as the output target.
- Copy the generated snippet into your codebase.
Tips / common pitfalls
- Include all headers (-H) so auth and content types are preserved.
- Use -d for JSON bodies and verify the generated JSON.stringify call.
- Remove line breaks or "\" if your shell added them.
Examples & test data
POST with JSON body
Input example
curl -X POST https://api.example.com/v1/orders -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{"sku":"ABC-1","qty":2}'
Expected output
fetch("https://api.example.com/v1/orders", {
method: "POST",
headers: {
"Authorization": "Bearer $TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({ sku: "ABC-1", qty: 2 })
});
GET with query params
Input example
curl "https://api.example.com/v1/users?status=active&limit=50" -H "Accept: application/json"
Expected output
fetch("https://api.example.com/v1/users?status=active&limit=50", {
method: "GET",
headers: {
"Accept": "application/json"
}
});
FAQ
Does it handle auth headers?
Yes. Headers in the cURL command are translated into fetch headers.
Can I generate Axios instead?
Yes. The converter supports multiple output targets including Axios.
Is my cURL command stored?
No. The conversion happens locally in your browser.
What about multi-line cURL?
Paste it as-is; the converter handles typical line breaks.
Related tools
Privacy-first: everything runs locally in your browser. No uploads, no tracking of your inputs.