cURL to Code: Python, JavaScript, Go, PHP & Java
Paste any cURL command and get the same request in Python, JavaScript, Node.js, Go, PHP or Java. Headers, JSON and form bodies, file uploads, basic auth, cookies and timeouts are all carried over — including Chrome’s “Copy as cURL” for both bash and Windows.
AI DevRuns in your browser — nothing uploaded
How it works
- 1
Reads the command like a shell
Single and double quotes, $'…' strings, backslash line breaks and Windows ^ escapes are all understood — so Chrome’s “Copy as cURL (bash)” and “(cmd)” both work.
- 2
Understands curl’s options
-X, -H, -d, --data-raw, --data-urlencode, --json, -F, -u, -b, -G, -k, -L, -x, --max-time and more — with curl’s own defaults, like POST when there’s a body.
- 3
Writes idiomatic code
json= in Python, URLSearchParams and FormData in JavaScript, a multipart writer in Go, CURLFile in PHP and a text block in Java — the way each language would normally do it, using only what ships with it where possible.
- 4
Tested against real curl
Code in all seven languages was run against a test server and checked to send the same method, URL, headers and body as curl itself.
Questions, answered
Python (requests), JavaScript fetch for the browser, Node.js, axios, Go (net/http), PHP (the built-in cURL functions) and Java (the HttpClient built into Java 11 and later). Go, PHP and Java code uses only the standard library.
In Chrome or Edge, open DevTools → Network, right-click a request → Copy → Copy as cURL. In Postman, open the request, click the code icon (</>) and choose cURL.
Yes. The conversion runs entirely in your browser — the command, including any API keys or cookies, is never sent to a server.
Chrome adds browser-only headers like sec-ch-ua and sec-fetch-mode that do nothing in a script. They’re dropped by default; untick the option to keep them. Content-Length and Host are always left to the HTTP library.
curl -d without a Content-Type header sends the body as application/x-www-form-urlencoded, even if it looks like JSON. The converter does the same and warns you. Add -H 'Content-Type: application/json' if the API expects JSON.
curl only follows redirects with -L. PHP and Java behave the same way, and the Go code switches redirects off unless the command has -L. Python requests, fetch and axios always follow them, which rarely matters for API calls.
Popular uses
Read the guide
Related tools
- Prompt CompressorCut tokens from prompts and code before you send them to an LLM.AI Dev
- Regex ExplainerPaste a regex, get plain English plus test cases.AI Dev
- AI SQL Query GeneratorEnglish to SQL for Postgres, MySQL and MSSQL.AI Dev
- JSON to Pydantic / TSInstant Pydantic models, TypeScript types or dataclasses.AI Dev