Productivity and Utilities

cURL to Code Converter

Turn a curl command into Python, JavaScript or PHP code.

Paste one curl command, for example from your browser's network panel (copy as bash) or from API documentation. The command is only read as text. It is never run.

    Supported: method, headers, data, JSON bodies, basic auth, cookies, query data with -G, redirects, timeouts and skipping certificate checks. Not supported: multipart forms, file uploads and reading data from files. Review the code before you run it, and keep secrets such as tokens out of anything you share.

    Next step

    How to use the curl to code converter

    1. Paste one curl command into the first box, for example from your browser network panel (copy as bash) or from API documentation. The command is read as text. It is never run.
    2. Choose the output language: Python with requests, JavaScript with fetch, or PHP with cURL.
    3. Read the notes under the box. They list options that were ignored, variables that need real values and anything the target language cannot do.
    4. Press Copy code and review it before use. Replace any secrets such as tokens with your own safe way of storing them.

    Worked example

    The command curl -X POST https://e.test/items -H "Accept: application/json" -d "{\"a\": 1}" -u bob:pw --max-time 30 -L -k becomes a Python script that sets the Accept header, adds the Content-Type header that curl adds for -d, sends the data as the body with requests.post, passes auth=('bob', 'pw'), follows redirects, skips certificate checks with verify=False and uses timeout=30.

    The generated Python, JavaScript and PHP for ten different commands were each run against a local test server and compared with what the real curl sends. The method, path, query string, Content-Type, Authorization, cookie and body matched in every case.

    What is converted

    The converter understands the request method (-X), headers (-H), data (-d, --data-raw, --data-binary and --data-urlencode), JSON bodies (--json), basic authentication (-u), cookies (-b), user agent (-A), referer (-e), query data with -G, redirects (-L), skipping certificate checks (-k), timeouts (--max-time) and HEAD requests (-I). It handles single quotes, double quotes, backslash line breaks and the $'...' form that browsers produce.

    Like curl, it sends a POST when you give data without a method, adds the form content type when you send data without a Content-Type header, and uses http:// if the address has no scheme. Without -L it does not follow redirects, so the generated code turns them off too.

    What is not converted

    Multipart forms (-F), file uploads (-T), reading data from a file with @, cookie files, proxies, client certificates and other advanced options are not converted. Options that only change what curl prints, such as -s, -v or -i, are ignored. Pipes, redirects and chained shell commands are refused, and so are Windows Command Prompt commands that use the caret character.

    Web browsers do not let page scripts set headers such as Cookie, Referer and User-Agent, so fetch code that sets them works in Node.js 18 or newer but not in a browser. Nothing is sent to a server while you use this tool. See also the HTTP status codes list, the query string to JSON converter and the URL encoder and decoder.

    Assumptions and limits

    • The command must start with the word curl and contain one http or https address.
    • Generated code uses the Python requests package, the fetch function of Node.js 18 or newer and browsers, and the PHP cURL extension.
    • Percent-encoding for --data-urlencode uses the plus sign for spaces, as curl does, and uppercase hex digits.
    • Shell variables such as $TOKEN are copied as plain text because the converter cannot know their values.

    Formulas reviewed October 10, 2026. See the calculation methodology for how SumPanda rounds, tests and sources its formulas.

    Frequently asked questions

    Is the curl command run when I paste it?

    No. The text is only parsed. Nothing is executed and no request is made, so it is safe to paste commands you are still reading.

    Why does the Python code include allow_redirects=False?

    curl does not follow redirects unless you add -L, while the requests package follows them by default for most methods. The converter sets the option so the code behaves like the command you pasted.

    Can I convert a command that uploads a file?

    Not with this tool. Multipart forms and file uploads need file handling that depends on where the file lives. Write that part by hand using the documentation of your language.

    Why do headers like Cookie not work in browser fetch?

    Browsers treat a few headers as forbidden for page scripts to protect users. The same code works in Node.js, where no such restriction applies. The tool adds a note when your command includes one of them.