This free cURL to code converter turns a curl command into working fetch(), Python requests or Node.js code, right in your browser. Paste a snippet from API docs, a README or your browser’s DevTools, and you get code you can drop into a script, plus a clear list of anything that did not carry over.
Most converters guess: they quietly drop the flags they don’t know and leave you debugging a request that isn’t the one you tested. This cURL to code converter reads the command the way your shell and curl actually do, and tells you when the generated code behaves differently.
What This cURL to Code Converter Does
- 🐚 Reads three shells. bash and zsh (including the
$'...'strings DevTools produce, here-documents and redirects), Windows cmd with its^escapes, and PowerShell with backtick line breaks. The shell is detected automatically, or you pick it. - 🔍 Applies curl’s defaults.
-dswitches to POST and adds a form Content-Type,-Gmoves the data into the query string,-ubecomes Basic auth,-Tuploads with PUT, and--jsonsets both JSON headers, just like curl. - 🧩 Covers the common flags. Methods, headers, cookies, user agent and referer,
--data,--data-raw,--data-binary,--data-urlencode,--json, multipart-Fuploads, query strings, Basic, Digest and bearer auth, proxies,-k, client certificates, timeouts,-L,-fand-o. - 🧾 Writes four outputs. fetch() for the browser, Python requests, Node.js with the built-in fetch, and Node.js with axios.
- ⚠️ Flags what it can’t translate. Every option the generated code does not reproduce gets a “Not translated” note, and behaviour differences get a “Check” note.
- 🔎 Shows its work. A parsed-request panel lists the method, URL, decoded query parameters, headers, auth and body. You can also expand the exact argument list curl would receive.
How to Use It
- Copy a curl command. In your browser’s DevTools, right-click a request in the Network tab and copy it as cURL.
- Paste it into the curl command box. The status line shows which shell syntax the cURL to code converter detected.
- Pick the output: Fetch, Python or Node.js (then fetch or axios).
- Read the conversion notes, especially anything marked “Not translated”.
- Copy the code, or download it as a
.js,.pyor.mjsfile.
How the cURL to Code Converter Reads Your Command
Conversion happens in three steps. First, the command is split into arguments with your shell’s quoting rules, so single quotes, $'line\n' strings or Windows ^" escapes end up as the exact strings curl would see. Second, those arguments go through curl’s own option table: short flags can be bundled (-sSL), values can be attached (-XPOST), and curl’s implied behaviour is applied. Third, each generator writes idiomatic code for its client.
A few details matter more than they look:
- JSON bodies become a Python dict or a JavaScript object when that is lossless. A number such as
9007199254740993, which JavaScript cannot hold exactly, keeps the original string instead. - Query strings are split into Python
params=only when requests would re-encode them to the same text. - Data from files follows curl’s rules:
-d @filestrips line breaks,--data-binary @filekeeps them.
The output of the cURL to code converter was checked against real curl 8 with a local echo server. The same commands, sent by curl, Python requests, Node.js fetch and axios, produced matching requests, including Windows cmd escaping, here-documents and multipart uploads.
What Doesn’t Translate, and Why You’re Told
Some curl behaviour has no equivalent, and pretending otherwise would give you broken code. The cURL to code converter tells you when:
- Redirects. curl follows them only with
-L; requests, fetch and axios follow them by default. - Browser limits. A web page can’t set Cookie, Origin, Referer or
sec-*headers, can’t skip certificate checks, can’t pick a proxy, and needs CORS permission to call other origins. - Tuning flags.
--retry,--http2,--resolve, rate limits and TLS cipher options stay with curl. - Shell variables.
$TOKENis kept as text, because only your shell knows its value. - PowerShell 5.1. It strips embedded double quotes when it calls
curl.exe, so the request curl really sends can differ from what you typed.
Practical Use Cases
- 📨 Notification scripts: the Telegram hook in my qBittorrent notification guide is a single curl call. Paste it into the cURL to code converter when the script outgrows bash, and the
$BOT_TOKENnote reminds you where the secret goes. - 🔌 Self-hosted APIs: test an endpoint with curl first, like the Moonraker checks in my K1 Max helper script post, then get the Python version for a Home Assistant or cron script.
- 🧪 Reproducing a browser request: copy a failing request from DevTools, run it through the cURL to code converter and replay it from Node.js with the same headers and body.
- 📚 Porting API docs: most docs show only curl; the cURL to code converter gives you a fetch() starting point for a web app.
- 🔐 Checking auth: see exactly which Authorization header
-uor--oauth2-bearerproduces, then inspect a token with the JWT Token Decoder.
Privacy, Ads, and Data Policy
- ✅ 100% free — no registration.
- ✅ No data storage — commands, tokens and passwords never leave your browser.
- ✅ No ads in results — no watermarks, no tracking.
- ✅ Client-side only — the tool makes no network requests of its own.
API keys often sit right in a curl command, which is why this cURL to code converter never sends it anywhere and never puts it in the page URL.
Open Source and Self-Hosting
The cURL to code converter is open source on GitHub: three files (index.html, style.css and script.js) with no dependencies, so you can drop the folder onto any static web server in your homelab. The generated Node.js code may need undici or axios from npm for proxies and TLS options; the notes tell you when.
Browse more free tools on the Tools page, for example the Docker Run to Compose Converter or the JSON Formatter and Validator for the responses your new code receives.
Built by VahaC — 100% client-side, no data sent anywhere.
