DevToolsmith

cURL to Code Converter

Paste a curl command, from API docs, a terminal or your browser’s “Copy as cURL”, and get working code for Python, JavaScript, Node.js, Go, PHP, Java, C# or Rust. Headers, JSON, forms, file uploads, auth, cookies and timeouts are all converted.

Runs 100% in your browser — nothing is uploaded

curl command
Tip: drop a file here236 chars · 236 bytes · 4 lines
Python · requests
451 chars · 451 bytes · 30 lines

Install: pip install requests

Parsed request

POST https://api.example.com/v1/orders?notify=true

  • Authorization: Bearer YOUR_API_TOKEN
  • Content-Type: application/json
  • Body: JSON

Pick your language

Each language page explains how that client differs from curl, with a reference of curl flags and their equivalents:

C# (HttpClient) and Rust (reqwest) are available in the tool above.

What curl does by default

A good conversion reproduces curl’s implicit behaviour, not just the flags you can see:

  • -d sets the method to POST and the Content-Type to application/x-www-form-urlencoded, even when the data is JSON. If you send JSON with plain -d, add -H 'Content-Type: application/json' or use --json; the converter warns when it spots this.
  • Several -d flags are joined with &, so -d a=1 -d b=2 sends a=1&b=2.
  • -G moves the data into the query string and sends a GET.
  • -F sends multipart/form-data with a generated boundary. The converter never copies a Content-Type header with a fixed boundary into the code, because it would not match the body.
  • curl doesn’t follow redirects without -L, while most libraries do by default. The generated code keeps the library default, which is almost always what you want.
  • A URL without a scheme means http://.

When the code sends different bytes than curl

curl sends the URL and the body exactly as you typed them. HTTP libraries often rebuild them from a dictionary, which means the same thing to most servers but not the same bytes:

  • Query strings: Python’s params= writes spaces as + and escapes commas, so ?q=a%20b&tags=x,y becomes ?q=a+b&tags=x%2Cy.
  • Form bodies: URLSearchParams escapes ~, while Python and .NET escape *.
  • JSON bodies: json= in requests adds a space after every comma and colon and escapes non-ASCII characters, so é becomes \u00e9; JSON.stringify drops whitespace and writes 1.50 as 1.5.

The converter compares the two for the language you pick and lists every difference under Notes, with both versions. It matters when the server checks a signature or hash of the request, such as webhook HMACs or AWS SigV4. In that case send the original text as a string.

Before you share the code

Commands copied from a browser carry your session: Cookie, Authorization and CSRF headers. Remove them, or move secrets into environment variables, before committing the code or pasting it into an issue. Headers like sec-ch-ua, sec-fetch-* and priority are added by the browser and are rarely needed in a script.

Frequently asked questions

How do I copy a request as curl from my browser?

Open DevTools (F12), go to the Network tab, right-click the request and choose Copy → Copy as cURL. In Chrome and Edge on Windows pick “Copy as cURL (bash)”, because the cmd version uses ^ escapes. Firefox and Safari have the same menu item. The copied command includes your cookies and auth headers, so treat it like a password.

Which curl options are supported?

Methods (-X), headers (-H), all data flags (-d, --data-raw, --data-binary, --data-urlencode, --json), multipart forms (-F, including @file uploads and ;type=), -G, -I, basic and digest auth (-u, --digest), cookies (-b), user agent and referer (-A, -e), -k, -L, --compressed, timeouts (-m, --connect-timeout) and proxies (-x). Combined flags like -sSL and -XPOST work too. Options with no equivalent are listed as notes.

Is my curl command sent to a server?

No. Parsing and code generation run in your browser. That matters because copied commands often contain session cookies and API tokens. You can check in DevTools: converting sends no network requests.

How do I know the generated code sends the same request?

We test it. A suite of curl commands (JSON, forms with repeated fields, multipart uploads, file bodies, custom methods, auth, cookies) is sent by real curl to a local echo server, then the generated Python, JavaScript, axios, Go, Java and Rust code is run against the same server. Method, path, query, headers and body must match. PHP and C# output is reviewed by hand.

Why does the code say a header is ignored or not allowed?

Some clients manage certain headers themselves. Browsers never let fetch set Cookie or Host, and Java’s HttpClient throws if you set Host, Connection or Content-Length. Content-Length is always left out because every client computes it from the body.