Advertisement

Free Online cURL Converter

Convert cURL commands into fetch, Axios, PHP, and Python code.

Waiting for input
Ready

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.

Advertisement

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 -X or --request values, plus positional or --url targets.
  • Headers: any number of -H entries, split at the first colon so values containing colons survive.
  • Bodies: -d, --data, --data-raw, and --data-binary are joined the way cURL joins them.
  • Forms: -F fields become multipart form data, with file references marked as placeholders.
  • Credentials and metadata: -u becomes a Basic Authorization header, while -b and -A become 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

  1. Paste a cURL command, including its line continuations if it spans several lines.
  2. Click Convert to parse the method, URL, headers, and body.
  3. Select the language tab you need and review the generated snippet.
  4. 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.

Sponsored
Find a bug? Report now