Free Online cURL Converter
Convert cURL commands into fetch, Axios, PHP, and Python code.
Supported flags include -X, -H, -d, --data-raw,
--data-binary, -F, -u, --url, -b, and
-A. Unknown flags are ignored with a note. Generated code uses the URL exactly as parsed.
About the cURL Converter
cURL is the common language of HTTP examples. Documentation, browser developer tools, API consoles, and support threads all offer a copyable cURL command because it contains every detail needed to reproduce a request. Translating that command into application code by hand is tedious and error-prone: headers must become objects, the body must be quoted correctly, and authentication has to move into the right place. This converter reads the command and produces equivalent snippets for JavaScript fetch, Axios, PHP cURL, and Python requests.
What is parsed
- Method and URL: explicit
-Xor--requestvalues, plus positional or--urltargets. - Headers: any number of
-Hentries, split at the first colon so values containing colons survive. - Bodies:
-d,--data,--data-raw, and--data-binaryare joined the way cURL joins them. - Forms:
-Ffields become multipart form data, with file references marked as placeholders. - Credentials and metadata:
-ubecomes a Basic Authorization header, while-band-Abecome Cookie and User-Agent headers.
Shell quoting is the first obstacle in any converter. Single quotes preserve everything literally, double
quotes allow variable expansion and backslash escapes, and a backslash outside quotes escapes the next
character. The tokenizer here follows those rules well enough for typical commands, including multi-line
commands joined with a trailing backslash. It does not execute substitutions such as $(cat token)
or environment variables; those arrive as literal text, which is usually what you want when moving a request
into source code.
Generated snippets preserve the body as a raw string rather than parsing and re-serializing JSON. That choice
keeps byte-for-byte fidelity, which matters for signatures, webhooks, and APIs that are strict about formatting.
If you prefer an object literal, parse the string with JSON.parse or let your HTTP client serialize
a dictionary. Multipart forms are the exception: they must be built with the platform's form API so the boundary
is generated correctly, and any @file reference becomes an obvious placeholder you must replace
with a real file handle.
Credentials deserve caution. A Basic header is only an encoding, not encryption, so the generated code should read secrets from environment variables rather than embedding them in a repository. The converter does not contact the target service; it only rewrites text in your browser. Review the output before running it, because cURL flags that are not supported here, such as client certificate options or custom resolve rules, are skipped and reported in the warning area.
How to use this tool
- Paste a cURL command, including its line continuations if it spans several lines.
- Click Convert to parse the method, URL, headers, and body.
- Select the language tab you need and review the generated snippet.
- Copy the current snippet or download all four versions in one text file.
Frequently asked questions
Why is my request body shown as a string instead of an object?
The converter preserves the exact body text so signatures and formatting are not altered. Convert it yourself with JSON.parse(body) if your client prefers an object, or edit the generated code to pass an object directly.
What happens to @file references in form fields?
They cannot be read by a browser without the user selecting a file, so the generated code includes a clear placeholder such as a file input or a path string. Replace it with a real file reference before running the snippet.
Are unknown cURL flags supported?
Common flags are recognized. Others are skipped and listed in a warning so the translation is transparent. Flags that change transport behavior, such as certificate pinning or DNS overrides, have no direct equivalent in the generated snippets.