How to use the cURL to Code
- Copy a request as curl — in Chrome or Firefox DevTools right-click a request in the Network tab and choose Copy › Copy as cURL — or take a curl example from API documentation.
- Paste it into the curl command box. Multi-line commands with
\continuations are fine. - Pick a language tab: JavaScript fetch, Axios, Node.js, Python, PHP or Go.
- Read the notes below the code for anything that needs your attention, then click Copy code.
What does a curl to code converter do?
curl is the universal language of HTTP examples: API documentation, Postman exports and every browser’s “Copy as cURL” feature produce curl commands. Translating one by hand into your application’s language means re-typing headers, escaping JSON and remembering how each HTTP client handles forms and authentication. This converter parses the command the way a POSIX shell and curl would, then generates idiomatic code for the client library you use.
Supported curl options
| Option | Converted to |
|---|---|
-X, --request | HTTP method (otherwise GET, or POST when a body is present) |
-H, --header, -A, -e, -b | Request headers, including User-Agent, Referer and Cookie |
-d, --data, --data-raw, --data-binary, --data-urlencode | Request body (form-encoded by default, like curl); @file reads a file |
--json | JSON body with Content-Type and Accept: application/json |
-F, --form | Multipart form data, including file uploads with ;type= and ;filename= |
-u, --user, --oauth2-bearer | Basic authentication or a Bearer token |
-G, --get, --url-query | Data appended to the URL query string |
-I, -L, -k, -m, -x, --compressed | HEAD requests, redirects, TLS verification, timeouts, proxies and compression where the library supports them |
Quoting follows shell rules: single quotes, double quotes with backslash escapes, ANSI-C $'…' strings (Chrome uses these for bodies containing quotes) and line continuations. Windows “Copy as cURL (cmd)” commands with ^ escapes are detected and converted too. Output-only flags such as -s, -v or -o are ignored, and anything unsupported is listed in the notes rather than silently dropped.
Choosing a target
- JavaScript fetch — built into every browser. Cross-origin requests also need the server to send CORS headers, and browsers refuse to set headers like
CookieorHost; the converter warns you when that applies. - Node.js fetch — built into Node 18+, no dependency needed; file uploads use
fs.openAsBlob. - Axios — popular for its interceptors and automatic JSON handling.
- Python requests — JSON bodies become native dictionaries passed with
json=; forms becomedata=dicts. - PHP cURL — uses
curl_setopt_arraywith the matchingCURLOPT_*constants, ideal for WordPress or Laravel code without extra packages. - Go net/http — a complete runnable
main.gowith error handling and multipart support.
Security tips
Commands copied from DevTools often contain session cookies and access tokens. The conversion runs entirely in your browser and the command is never sent anywhere or added to the URL, but remember to remove secrets before committing generated code — load them from environment variables instead. Want to try a request right away? Use the API Tester. Need to inspect a token from the command? Paste it into the JWT Decoder.
Tools that pair well with the cURL to Code
- Base64 Encode / Decode — Convert text to Base64 and back with full UTF-8 support (accents, emoji), switch to URL-safe Base64, or drop a file to get its Base64 string or data URI.
- HTTP Header Checker — Fetch any URL and see exactly what the server sends back — status code, redirect chain and every response header, with a plain-English explanation of the ones that matter for SEO, caching and security.
- HTML Formatter — Paste minified or messy markup and get clean, consistently indented HTML — including embedded <style> and <script> blocks.
- CSS Formatter — Turn a minified stylesheet into readable CSS with one property per line and properly nested @media blocks.
Frequently asked questions
Is it safe to paste a curl command with my API key or cookies?
How do I copy a request as curl from Chrome?
Why is my -d data sent as form data and not JSON?
-d sets Content-Type: application/x-www-form-urlencoded unless you pass your own header. Add -H 'Content-Type: application/json' or use --json and the converter will produce a JSON body.What happens to file uploads like -F file=@photo.jpg?
FormData in JavaScript, files= in Python, CURLFile in PHP and mime/multipart in Go — referencing the same local path, which you may need to adjust.Does it follow redirects like curl -L?
-L. In PHP the converter adds CURLOPT_FOLLOWLOCATION when -L is present.