curl to code converter
Turn a curl command — including Chrome's Copy as cURL — into fetch, Python requests, Go, axios or PHP code.
Input
Result
The result will appear here.API documentation gives its examples as curl commands and browser developer tools copy requests as curl, but the code you are writing is not a shell script. This converter reads the command the way a shell and curl would — quoting, backslash line continuations, $'…' strings, repeated -d joined with &, --json setting both JSON headers, -G moving the data into the query string — and writes the same request as JavaScript fetch, Python requests, Go net/http, axios or PHP cURL. Anything that cannot be carried over, such as a proxy, digest authentication or a client certificate, is named in a comment at the top of the generated code instead of being dropped without a word.
How it works
- The command is split into words with POSIX shell quoting rules, and with cmd.exe's ^ escapes when you paste Chrome's Copy as cURL (cmd) output.
- A JSON body is written as a native literal — a dict for Python, an object for fetch and axios — so it is easy to edit; other bodies are kept as the exact string curl would send.
- -F becomes a multipart form with files opened from disk, -u becomes Basic authentication, -m a timeout and -k the target language's way of skipping certificate checks.
- Anything after a pipe, such as | jq, is left out, and a comment says so; shell variables like $API_KEY are copied as they are, with a reminder to substitute them.
Where your data goes
Nowhere. This tool runs entirely in your browser: the text you paste is processed by the page and is never transmitted to a server or written to a log.
This tool is free and needs no account. Its results exist only in your open page and are not saved anywhere.
What it costs
This tool is free, with no sign-in and no points.
Common questions
- Does it handle Copy as cURL from Chrome and Firefox?
- Yes. The bash version (Copy as cURL, or Copy as cURL (bash)) is ordinary shell quoting. On Windows, Chrome also offers Copy as cURL (cmd), which escapes characters with ^; that form is recognised and unescaped too. The PowerShell variant is not curl syntax at all — it is a PowerShell Invoke-WebRequest script — and is not supported.
- Why is my API key still written as $OPENAI_API_KEY?
- Because in the shell that is a variable, filled in when the command runs, and the converter cannot know its value. The code keeps it literally and a comment lists every variable it found. Read it from the environment in your language — os.environ in Python, process.env in Node, os.Getenv in Go — rather than pasting the key into source code.
- Is this the curlconverter library?
- No. curlconverter is the well-known open-source project for the same job, credited on this page, but this tool has its own smaller parser written for the five targets it offers. It covers the options that shape the request — method, headers, data, forms, auth, cookies, timeouts, redirects, TLS verification — and lists the options it did not convert in the code's opening comment.
- What happens to -L and --compressed?
- fetch, requests, Go's http.Client and axios already follow redirects and decompress gzip responses by default, so nothing needs to be added for them. PHP's cURL does neither on its own, so the PHP output sets CURLOPT_FOLLOWLOCATION and CURLOPT_ENCODING when the command asked for them.
The open-source behind it
This tool is a self-contained implementation. curlconverter/curlconverter (MIT) does the same job as a library — if you need this behaviour inside your own program, start there rather than calling a web page.
curlconverter/curlconverterAlso known as
- curl to code
- curl to python requests
- curl to fetch
- curl to go
- convert curl command
- copy as curl to code
- curl to axios
- curl to php