cURL to Code Converter
Paste any curl command and get the same HTTP request as ready-to-run code in JavaScript (fetch & axios), Python, Node.js, Go, and PHP. Everything is parsed in your browser — nothing is uploaded, no signup.
How it works
A curl command looks simple, but turning it into code by hand means remembering how each flag maps to your HTTP client. This converter does that mechanically. It runs a small shell-style tokenizer over the command — respecting single quotes, double quotes, backslash escapes, and \ line continuations — then classifies each token against the official curl flag definitions. There is no eval and no shell: the command is read as data, never executed.
The flag-to-code mapping follows the curl man page:
-X/--requestsets the HTTP method (uppercased).-H/--headerbecomes one header, split on the first colon so values with colons survive.-d,--data,--data-rawand--data-binaryset the body. With no-X, the presence of data makes the request a POST — curl's documented default.-u user:passbecomes anAuthorization: Basicheader, base64-encoded per RFC 7617.-F/--formbecomes a multipart form;-bbecomes a Cookie header;-Gmoves the data into the query string as a GET.
Bodies are normalized before emitting. When the request carries Content-Type: application/json and the body parses as JSON, the JavaScript targets use JSON.stringify and Python uses the json= keyword (which lets requests set the header itself). A -d body with no content type is emitted as a raw string and tagged application/x-www-form-urlencoded, matching what curl actually sends. Runtime-only flags such as -o, --proxy, and --insecurecan't be reproduced in code, so they are listed in a warning banner rather than silently dropped — the output is never quietly wrong. The three worked examples below are encoded as an in-code self-test (verifyWorkedExamples()) that runs on every build.
Worked examples
Frequently asked questions
Sources & references
- curl man page — canonical definition of every flag (-X, -H, -d, -u, -F, -b, -G, --url)
- MDN — Fetch API (request init: method, headers, body)
- WHATWG Fetch Standard — method casing and header semantics
- Python requests documentation — request(), json=, data=, files=
- RFC 7617 — HTTP Basic authentication (base64 of user:pass)
The flag mappings on this page were last cross-checked against the curl man page on 2026-06-30. The parser's three worked examples are re-verified automatically on every deploy.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a curl flag that converts wrong, or want another target language?
Email me at [email protected] — most fixes ship within 24 hours.