cURL to Code Converter
Paste a cURL command and convert it to JavaScript (fetch, Axios, Node), Python, Go, PHP or Java code. Parsed in your browser, never uploaded.
curl command
Stays in your browserGenerated code
Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)
Next steps
Done here? Use the Send to… menu on the result to carry it on to REST API Tester.
Free Online cURL to Code Converter
Paste a raw curl command — like the one your browser's DevTools copies from the Network tab — to instantly generate the equivalent JavaScript, Python, Go, PHP or Java code. It is useful when an API request works in curl but needs to become browser fetch, Axios, or Python code for an application.
Why convert a curl command to code?
API documentation and browser DevTools both commonly express an HTTP request as a curl command — it's a universal, copy-pasteable format for describing a request's method, URL, headers, and body. But when you need that same request inside an application, you need it as actual code in your language of choice, and manually translating flags like -H and -d into the right object shape is tedious and easy to get wrong.
How to use this converter
Paste the full curl command — multi-line commands with trailing \ continuations are supported — choose a target (JavaScript fetch(), Axios or Node, Python requests or httpx, Go, PHP or Java), and click Convert.
What gets parsed
-X/--request— the HTTP method (defaults to GET, or POST if a body is present)-H/--header— request headers-d,--data,--data-raw,--data-binary— the request body-u/--user— HTTP Basic authentication, converted into an Authorization header-A/--user-agentand-b/--cookie— added as their corresponding headers
Worked example
curl 'https://api.example.com/users' -H 'Content-Type: application/json' -d '{"name":"John"}' converts to a fetch() call with method: "POST" (inferred from the presence of -d, since no -X was given), the header included, and the body attached as a string.
Common mistakes and edge cases
- Options such as
--cert client.pemor--proxy http://...are skipped together with their values, so they never replace the URL. A flag the tool doesn't know about is ignored, but if it takes a value, the address is picked as the word that starts with a scheme such ashttps://. - Repeating the same header (two
-H 'X-Custom: a'/-H 'X-Custom: b'pairs) combines them into one header,a, b, which is how HTTP treats repeated header lines. Several-doptions are joined with&, as curl does.