Skip to main content

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 browser

Generated code

Generated code will appear here.

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-agent and -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.pem or --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 as https://.
  • 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 -d options are joined with &, as curl does.

Frequently asked questions

Where do I get a curl command to paste here?
Most browser DevTools (Chrome, Firefox, Edge) let you right-click a request in the Network tab and choose "Copy as cURL" — that's the most common source, along with curl commands from API documentation.
Does this support every curl flag?
It covers the flags used in the vast majority of real-world API requests: -X/--request, -H/--header, -d/--data(-raw/-binary), -u/--user, -A/--user-agent, and -b/--cookie. -e/--referer and --url are read too. Options that don't change the request code (client certificates, proxies, timeouts, output files) are skipped together with their values, so they never get mistaken for the address. Words after an unknown option are not used as the URL when a real address (starting with https://) is present.
Is my curl command uploaded anywhere?
No — parsing and code generation both happen entirely in your browser. If your curl command includes an API key or token, it never leaves your machine.
Why does the generated code just print the response instead of doing something with it?
The generated snippet is a starting point showing the equivalent request — logging the response is the simplest way to show it works. You'll typically replace that part with your own handling.
Why does generated fetch code behave differently from curl?
curl runs outside a browser, so it can send any header and talk to any server. Code that runs in a browser with fetch must follow CORS and cannot set some headers such as Host or Cookie by hand. If the generated code fails with a network error while curl works, the server probably does not allow your site as an origin.

Related tools

More Formatters & Parsers

View all Formatters & Parsers tools →