cURL to Fetch Converter (Convert Bash Commands to JavaScript Online)
If you are copying API examples from documentation (like Stripe or GitHub), they are almost always written in raw bash cURL. This tool instantly translates those complex cURL commands—including nested JSON data, Authorization headers, and POST methods—into modern, production-ready JavaScript `fetch()` code.
100% Private & Secure
This tool runs completely inside your browser using client-side WebAssembly and JS. Zero data is ever sent to our servers.
How to use this tool
- Copy a raw valid cURL command from your terminal or API documentation.
- Ensure the command begins with the word 'curl'.
- Paste the entire snippet into the dark Bash input box on the left.
- The tool will instantly parse the bash structure and generate equivalent JavaScript code in the right box.
Example Usage
curl -X POST "https://api.test.com" \
-H "Content-Type: application/json" \
-d '{"user":1}'fetch('https://api.test.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
'user': 1
})
});When to use this tool
- Quickly translating Stripe or Twilio API documentation examples into React/Node.js code.
- Debugging an intercepted network request by copying it 'as cURL' from Chrome DevTools and pasting it here.
- Learning how specific cURL flags (like -H, -d, -u) translate into JavaScript Request Init dictionary objects.
Frequently Asked Questions
How does this parse complex bash escaping logic?
Our engine executes a true bash lexer within the browser. It splits the input string identically to a Linux shell, perfectly resolving single quote strings, escaped inner quotes (\"), and multi-line backslash (\) continuations.
Does this support importing binary files via the -F flag?
Yes, when parsing a cURL command that uploads a file (using -F or --form), the tool translates it into standard JavaScript FormData syntax to ensure file blobs are transmitted natively.
Can I convert Chrome DevTools 'Copy as cURL' strings?
Absolutely. Using the Network tab inside Chrome, you can right-click any blocked request, select 'Copy as cURL', and instantly translate those massive payloads into reusable fetch definitions here.
Are my API keys submitted to a server?
Never. The bash tokenization and Abstract Syntax derivation occurs 100% inside your local V8 JavaScript engine. Your pasted Authorization Bearer tokens cannot be read by any external network.
Why does it output node-fetch instead of XMLHttpRequest?
The XMLHttpRequest (XHR) framework is largely deprecated for modern syntax. This converter strictly outputs modern ES6 `fetch()` configurations, making it instantly compatible with React, Next.js, and modern Node.js environments.