cURL to Code Converter
Convert a curl command into equivalent request code — Python requests, JavaScript fetch/axios, Node.js, PHP (Guzzle or the cURL extension), Go net/http, or Ruby Net::HTTP.
Input
Output
Guides
What this tool does
API docs, Postman's "Copy as cURL", and your browser's DevTools Network tab all hand you a request as a curl command. That's great for a quick terminal test, but it's not code you can drop into an app. This tool parses that curl command — method, URL, headers, body, basic auth, and redirect handling — and generates an equivalent HTTP request in the language you're actually writing.
It supports eight targets:
- Python (requests)
- JavaScript (fetch)
- JavaScript (axios)
- Node.js (node-fetch)
- PHP (Guzzle)
- PHP (cURL extension)
- Go (net/http)
- Ruby (Net::HTTP)
How to use it
- Paste the full curl command into the cURL Command box — including the leading
curl, or without it, either works. - Pick a Target Language from the dropdown.
- Toggle Include explanatory comments if you want a leading comment line noting the code was generated.
- The equivalent code appears instantly in the output panel. Copy it or download it with the right file extension for the language.
What gets parsed
The parser tokenizes the command the way a real shell would — respecting single quotes (fully literal), double quotes (with backslash escapes), and line continuations (\ at end of line) — so a JSON body with spaces and nested double quotes, like -d '{"name": "Alice Smith"}', comes through intact rather than getting split on the spaces inside it.
It recognizes:
-X/--request— HTTP method (inferred asPOSTif there's a body and no explicit method,GETotherwise)-H/--header— request headers, including anAuthorization: Bearer …header-d,--data,--data-raw,--data-binary,--data-urlencode,--json— request body (JSON bodies are detected and rendered as native data structures, not raw escaped strings)-u/--user— HTTP Basic auth, rendered using each language's proper auth mechanism-L/--location— follow redirects-k/--insecure,-x/--proxy,--connect-timeout,--max-time— carried through to the equivalent client option where the target library supports it- Combined short flags (
-sL,-kL) and--flag=valuesyntax - The first bare (non-flag) argument as the URL
Flags with no equivalent in generated request code (like -o for saving to a file, or -v for verbose logging) are simply ignored — they affect curl's own behavior, not the shape of the HTTP request.
FAQ
My curl command doesn't start with curl — does that matter?
No. The tool also accepts a bare argument list, or a command copied with a leading $ curl prompt.
Why does the JSON body come out as a Python dict / PHP array instead of a string?
When the body looks like valid JSON and there's a JSON content type (explicit or inferred), the tool parses it and renders it as a native structure — a Python dict, a JS/PHP object, etc. — instead of a raw string, so the generated code is actually editable.
What if I don't include -X?
The method is inferred: POST if there's a request body, otherwise GET, matching curl's own default behavior.
Does this send any requests? No. Parsing and code generation happen entirely in your browser — the curl command and generated code never leave your machine unless you choose to copy or download it.
Privacy note
Everything runs client-side. curl commands often contain real credentials — bearer tokens, API keys, basic-auth passwords — so nothing is sent to a server, and the tool's share-link feature only carries your selected options, never the command text itself.
Use it from code
From 3 credits per callREST API
curl -X POST https://api.iotools.cloud/v1/tool/curl-to-code-converter \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"curlCommand": "curl -X POST \"https://api.example.com/v1/users\" …",
"targetLanguage": "python-requests",
"includeComments": "true"
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `curl-to-code-converter` tool (cURL to Code Converter) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.