curl to Code Converter
Developer Tools · Added
Every API's documentation gives you a curl command, and you need it in something else. Paste it here and get working code for fetch, axios, Python requests or Node's https module, with headers, body and auth carried across rather than approximated.
How to use the curl to code converter
- 1Copy the curl command from the documentation, or from your browser's Copy as cURL.
- 2Paste it in — line continuations and multi-line commands are fine.
- 3Pick the target language or library.
- 4Read the notes about any flag that has no direct equivalent before using the output.
Examples
A POST with a JSON body
- Input
- curl -X POST https://api.example.com/v1/items -H "Content-Type: application/json" -d '{"name":"widget"}'
- Result
- A fetch call with method, headers and body set, awaiting response.json() — or the equivalent requests.post with a headers dict in Python.
A request with basic auth
- Input
- curl -u user:pass https://api.example.com/status
- Result
- An Authorization header built from the encoded credentials, with a note that the password is now sitting in your source rather than in a shell history.
About the curl to code converter
The mismatches worth knowing about
A curl command and its equivalent in another language are rarely a line-for-line match, because the defaults differ. curl does not follow redirects unless told; fetch follows them automatically. curl verifies TLS certificates unless you pass -k; Python's requests does the same but warns differently. curl sets no timeout at all by default, while some libraries impose one.
Those defaults are where translated requests go wrong, and they go wrong quietly — the request succeeds, it just does something slightly different from the one in the documentation. The generated code here sets them explicitly rather than relying on whichever default happens to apply.
Credentials do not survive the journey
A curl command pasted from documentation usually carries a placeholder token. A curl command copied from your own terminal usually carries a real one, and converting it moves that secret from a shell history into a source file that may well end up committed.
Nothing here is uploaded — the parsing and generation happen entirely in your browser — but the output is still code with a secret in it. The five seconds it takes to replace the literal with an environment variable read is the whole of the fix, and it is worth doing before the file is saved rather than after.
Frequently asked questions
Which curl flags are supported?
Does it handle shell quoting properly?
Is the generated code safe to paste straight in?
Why does the output not follow redirects unless I asked for it?
Related tools
JSON Formatter
Developer Tools
Pretty-print, minify and inspect JSON with precise error positions.
JWT Decoder
Developer Tools
Decode a JSON Web Token's header, payload and claims, and see whether it has expired.
URL Encoder / Decoder
Developer Tools
Percent-encode and decode URLs and query parameters, with a query string breakdown.