Code and data

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 13 HTTP clients, with every flag it can't convert called out. Or build a curl command from a form.

Converted in this tab: the command is never sent anywhere, never saved and never put in the page address, so tokens in it stay on this device. Use Redact secrets before you share a command.

    Python (requests)

      Runs in your browser. Nothing you type or open is uploaded. Free to use, no account. More code and data tools

      How to convert curl to Python, JavaScript, Swift or Kotlin

      1. Paste a curl command: one from API documentation, a terminal, Postman's code view or your browser's developer tools. Line continuations, comments, a leading $ prompt and a trailing | jq are handled.
      2. Pick the language. The code updates as you type and uses each language's usual HTTP client: requests or httpx for Python, fetch or axios for JavaScript, URLSession for Swift, OkHttp or Ktor for Kotlin.
      3. Read the checks above the code. They list flags that have no equivalent in code (such as --cert or --proxy), bodies read from files, and environment variables kept as placeholders.
      4. Copy or download the code, replace placeholders such as $API_TOKEN with values from your configuration, and run it.

      Which curl options are converted

      Headers (-H, -A, -e, -b), the method (-X, -I, -G), every body option (-d, --data-raw, --data-binary, --data-urlencode, --json, -F, -T), Basic auth (-u or credentials in the URL), --oauth2-bearer, -L, -k, --compressed, -m and --connect-timeout.

      The parser knows all of curl's options, so an option's value is never mistaken for the URL. Options that only change curl's own output, such as -s, -v or -o, are listed as having no effect. Options that change the request but have no direct equivalent, such as client certificates, proxies, Digest auth or cookie files, are reported so nothing is dropped silently.

      curl details the converter follows

      -d sends the text as typed and adds Content-Type: application/x-www-form-urlencoded unless you set another type; with @file it reads the file and removes its line breaks, which --data-binary doesn't. Several -d values are joined with &. --data-urlencode encodes the value (current curl sends spaces as +) and --json adds both the JSON Content-Type and Accept headers.

      A header written Name: removes a header curl would add, and Name; sends it with an empty value. -G moves -d data into the query string. A method typed in lower case, such as -X post, is sent by curl exactly as typed; the code uses POST and says so.

      Copy as cURL from Chrome, Edge and Firefox

      In the Network panel, right-click a request and choose Copy, then Copy as cURL. On macOS and Linux you get bash quoting, with $'...' strings for special characters. On Windows, Chrome and Edge also offer Copy as cURL (cmd), which wraps every value in ^" and escapes characters with ^; Windows cmd is detected and decoded the way cmd.exe and curl.exe read it.

      Browser commands carry every header the browser sent, including cookies and sec-ch-ua hints. Most APIs only need the method, URL, authorization, content type and body, so delete the rest from the generated code once it works. Chrome's cmd format replaces non-ASCII characters with spaces, so copy the bash version when a body contains accented letters or emoji.

      Build a curl command from a form

      The Build a curl command tab works the other way round: choose a method, enter the URL, headers, a JSON, form or raw body and Basic or Bearer authentication, and it writes a correctly quoted command for bash or Windows cmd. Quotes, apostrophes, dollar signs and line breaks in values are escaped for the shell you choose. Convert to code sends the command to the first tab.

      Placeholders, secrets and sharing

      Shell variables such as $OPENAI_API_KEY or ${TOKEN} (and %TOKEN% in cmd) are left in the code as text and listed, because their values exist only in your shell. Read them from the environment in your program rather than pasting real keys into source files.

      Redact secrets replaces Authorization and API key headers, cookies, Basic auth passwords, token-like query and form fields, JSON fields named like secrets, and known key formats (JWTs, Stripe, GitHub, Slack, AWS and Google keys) with REDACTED. Check the result before posting it in an issue or a chat. To inspect a token you find in a command, paste it into the JWT decoder.

      Push notifications and status codes

      The push notification tester and APNs JWT generator print ready curl commands for APNs and Firebase Cloud Messaging. Paste one here to get the same request in Swift, Kotlin, Python or Go for your server. If the response is an error, look the status up in HTTP status codes.

      Private by design

      Privacy

      This page converts the command in your browser tab and makes no network request with it; the generated code only runs where you run it. The command box isn't saved and isn't put in the page address. The language and shell choices are remembered as settings. In the build tab, the password and token fields are never saved and are masked in the preview.

      This page also shows Google ads, which can use cookies. Privacy and cookies explains how.

      Questions

      How do I convert curl to Python?

      Paste the curl command and choose Python (requests) or Python (httpx). Headers become a dictionary, -d becomes data= and -F becomes files=, -u becomes auth=, and -L, -k and -m map to allow_redirects, verify and timeout.

      Does it handle Copy as cURL from Chrome on Windows?

      Yes. Commands copied as cURL (cmd) use ^ escapes and ^" quotes; the shell is detected and decoded as cmd.exe and curl.exe would read it. Copy as cURL (bash) works too.

      Why does the converter warn about some flags?

      Some curl options change the request in ways the generated code can't reproduce simply, such as client certificates, proxies, Digest auth or cookie files. They are listed so you can add the equivalent setting to your client.

      What happens to $TOKEN and other variables?

      They are kept as text in the code and listed under the command, because their values only exist in your shell. Replace them, or read them from environment variables in your program.

      Is my curl command sent to a server?

      No. The conversion runs in this tab and makes no network request, and the command isn't saved or put in the page address. Use Redact secrets before you share a command with anyone.

      Can I turn code or a form into a curl command?

      Use the Build a curl command tab: enter the method, URL, headers, body and authentication, and copy a quoted command for bash or Windows cmd.

      From the same developer