Tools

curl to Code Converter

Convert curl commands to fetch, axios, Python, Go, PHP




  

How to convert curl to code

  1. Paste a curl command. The quickest source is your browser's DevTools: open the Network tab, right-click a request and choose Copy → Copy as cURL. API documentation examples work too.
  2. Choose the target: JavaScript fetch, Node.js axios, Python requests, Go net/http or PHP cURL.
  3. The code updates as you type. Copy it into your project.

What is converted

The converter understands the curl options people actually use: the method (-X), headers (-H), request bodies (-d, --data-raw, --data-binary, --data-urlencode and --json), multipart form fields and file uploads (-F), basic authentication (-u), cookies (-b), user agent and referer, following redirects (-L), skipping certificate checks (-k) and turning data into a query string (-G). Bash line continuations with backslashes, Windows ^ continuations and single, double and $'…' quoting are handled.

JSON bodies are detected and written idiomatically: JSON.stringify for fetch, a plain object for axios, and a json= argument for Python requests, which sets the content type for you. As with curl, a request with a body defaults to POST.

Privacy

Commands copied from DevTools often include cookies, session tokens and API keys. This converter runs entirely in your browser and never sends the command anywhere, so those secrets stay with you. Still, remove them before sharing the generated code.

Why does the fetch version fail with a CORS error?

Browsers block cross-origin requests unless the server allows them. curl has no such rule. Run the code on a server (Node.js) or call an API that sends CORS headers.

Does it support file uploads?

Yes. -F field=@file.png becomes FormData in JavaScript, files= in Python and CURLFile in PHP. In the browser you supply the file from an input element.

Why is my -k option ignored in fetch?

Browsers do not allow skipping TLS certificate checks. It is kept for Python (verify=False) and PHP, but only use it for local testing.