curl to Code Converter — Python, JavaScript, Go, PHP & More

Paste a curl command, including Chrome "Copy as cURL", and get the same request in Python, JavaScript, Node, Go, PHP, Ruby, Java, C#, wget or HTTPie.

Examples:
Convert to
POST https://api.example.com/v1/orders · 2 headers · JSON body
import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json',
}

json_data = {
    'customer_id': 'cus_123',
    'items': [
        {
            'sku': 'TSHIRT-M',
            'qty': 2,
        },
    ],
    'note': 'Leave at the door',
}

response = requests.post('https://api.example.com/v1/orders', headers=headers, json=json_data)
print(response.status_code)
print(response.text)

Runs entirely in your browser. The command is only parsed, never executed or sent anywhere, so tokens and cookies in it stay on your machine. Browse all free tools.

Found a problem, or something that could be better? We read every message and we fix things quickly.

This free curl to code converter takes a curl command and writes the same HTTP request in Python (requests), JavaScript (fetch or Axios), Node.js, Go, PHP, Ruby, Java, C#, wget or HTTPie. The usual workflow: find a request in your browser’s DevTools, choose Copy as cURL, paste it here and get working code without retyping headers or escaping a JSON body by hand.

The parser follows curl’s own rules: short options can be combined (-sSL) or attached (-XPOST), the URL can appear anywhere, -d implies POST with a form content type, -G moves the data into the query string, and --data-urlencode encodes the way curl does. It understands bash quoting, including the $'…' strings Chrome produces, and Windows cmd quoting with ^ escapes. Anything a target language cannot express, such as skipping TLS verification in a browser, is pointed out in a comment rather than silently dropped.

How to use

  1. In Chrome or Edge DevTools, open the Network tab, right-click a request and choose Copy → Copy as cURL (bash or cmd). In Firefox, choose Copy Value → Copy as cURL. Or write your own curl command.
  2. Paste it into the box. The method, URL, header count and body type appear above the output so you can check it was read correctly.
  3. Pick the target language. The code updates instantly.
  4. Read any notes shown in the yellow box: they list options that were ignored or need attention.
  5. Copy the code or download it. Replace tokens and cookies before committing it anywhere.

Frequently asked questions

How do I copy a request as cURL from Chrome?

Open DevTools (F12 or Cmd+Option+I), go to the Network tab and reload the page if the list is empty. Right-click the request you want, choose Copy, then Copy as cURL (bash) on macOS and Linux or Copy as cURL (cmd) on Windows. Both formats work here. The copied command includes your cookies and authorization headers, so treat it like a password.

Why are some headers missing from the browser fetch code?

Browsers do not let JavaScript set certain request headers: Cookie, Host, Origin, Referer, User-Agent in practice, Content-Length, Accept-Encoding, Connection and anything starting with Sec- or Proxy-. They are called forbidden request headers in the Fetch standard and the browser fills them in itself. The browser fetch output leaves them out and says so in a comment; the Node.js fetch output keeps them, because Node has no such restriction.

What is the difference between -d, --data-raw and --data-binary?

-d (--data) sends the text as the body, but a value starting with @ is read from a file, with carriage returns and newlines stripped. --data-raw is the same without the @ file behaviour, which is why browsers use it. --data-binary also reads @files but keeps the bytes exactly. All three set Content-Type: application/x-www-form-urlencoded unless you pass your own header, and several -d options are joined with &.

Does curl follow redirects?

Not by default; it returns the 3xx response unless you add -L (--location). Most HTTP libraries do the opposite: fetch, Python requests, Go net/http, Axios in Node and .NET HttpClient follow redirects automatically. Java HttpClient, PHP cURL and Ruby Net::HTTP do not, so when your command has -L the generated code turns following on for them (Ruby gets a note, because Net::HTTP has no switch for it).

What does --compressed do, and do I need it in code?

It makes curl send an Accept-Encoding header (gzip, deflate, br and zstd, depending on how curl was built) and decompress the response. Browsers, Python requests, Go and Node fetch already ask for and decode compressed responses without being told. The generated code adds it only where the library needs it switched on: CURLOPT_ENCODING in PHP, AutomaticDecompression in C#, --compression=auto in wget.

Is my curl command sent anywhere?

No. The command is parsed and converted by JavaScript in this page. It is never executed and never sent to a server, so the tokens and session cookies in a copied DevTools request stay on your machine.

curl options and what they become

• -X / --request sets the method. Without it the method is GET, POST when there is -d, --json or -F, HEAD with -I, and PUT with -T.

• -H / --header adds a header. "Name:" with nothing after it removes a header, and "Name;" sends an empty one.

• --json body sends JSON and sets both Content-Type and Accept to application/json (curl 7.82 and later).

• -F name=value and -F file=@photo.jpg;type=image/jpeg build a multipart/form-data body; the code uses FormData, files=, CURLFile or MultipartFormDataContent as appropriate.

• -u user:password becomes Basic authentication; -b "a=1; b=2" becomes a Cookie header (or a cookies dict in Python).

• -A and -e set User-Agent and Referer. -k / --insecure disables certificate checks; this is shown with a warning where possible because it should never reach production.

• -G / --get appends all -d and --data-urlencode values to the URL as a query string and sends a GET.

• -s, -S, -v, -i, -o and progress options affect only how curl prints output, so they have no equivalent in code and are ignored.

Bash and Windows quoting, briefly

In bash, text in 'single quotes' is literal; "double quotes" allow \" and \$ escapes; $'…' strings understand \n, \t, \' and \xHH escapes. A backslash at the end of a line continues the command on the next line. Chrome uses $'…' whenever a header or body contains a single quote or a non-ASCII character.

In Windows cmd, ^ is the escape character and also continues a line. Chrome’s "Copy as cURL (cmd)" wraps every value in ^"…^" and escapes characters such as &, %, { and } with ^. PowerShell is different again: it aliases curl to Invoke-WebRequest in Windows PowerShell 5, so run curl.exe explicitly there. This converter reads both bash and cmd forms; PowerShell-specific syntax such as backtick continuations is not supported.

Related free tools

  • JSON to TypeScript — Paste a JSON sample and get TypeScript interfaces, a Zod schema, JSON Schema or types for Go, Python, Java, C#, Kotlin, Swift and Rust.
  • JSON Formatter — Pretty-print, minify and validate JSON, with parse errors located by line and column. In your browser, no upload.
  • JWT Decoder — Decode a JWT's header and payload, read the expiry in plain language, verify HS, RS, PS and ES signatures, or sign a new token. Nothing leaves your browser.
  • Base64 Encoder / Decoder — Encode text or files to Base64, turn images into data URIs with CSS and <img> snippets, and decode Base64 back to a previewable file. Nothing leaves your browser.
  • SSL Certificate Decoder — Paste a PEM certificate, a chain or a CSR, or upload a .crt file, to see SANs, expiry, issuer, key type and fingerprints. Decoded in your browser.