OpenReplay Logo
12k

curl to code converter

Convert a curl command into fetch, Axios, Python, Node.js, Go, or PHP code — live and processed locally in your browser.

Processed locally

About this tool

A curl command is a compact, shell-quoted description of an HTTP request: a URL, an optional method (-X), headers (-H), and a body (-d, --data-raw, --json, or -F multipart form fields). This converter tokenizes the command exactly like a shell — handling single and double quotes, backslash escapes, line continuations, and ANSI-C $'...' strings — then parses the flags into a normalized request and emits idiomatic client code for six targets.

Use it to turn the curl snippet pasted in API docs or copied from your browser's network tab into working code in seconds. It infers POST when a body is present, decodes -u credentials into an Authorization: Basic header, moves -d data into the query string for -G, builds FormData and multipart bodies for -F, and prints native object, dict, or array literals when the body is JSON — so you get a request you can drop straight into a fetch call, a requests script, a Go net/http handler, or a PHP curl block.

Everything runs in your browser — your curl command, including any tokens, cookies, or Basic-auth credentials, is never uploaded or sent to a server.

Frequently asked questions

Which curl flags does the converter support?

It handles -X/--request, -H/--header, -d/--data/--data-raw/--data-binary/--data-urlencode, --json, -F/--form, -u/--user, -b/--cookie, -A/--user-agent, -e/--referer, -I/--head, and -G. Transport-only flags like -L, --compressed, -k, -s, and -o are noted rather than reproduced, and any unrecognized flag is flagged as a warning instead of breaking the output.

How does it decide the HTTP method when there is no -X flag?

It follows curl's own rules: the method defaults to GET, but becomes POST automatically when a request body or form field is present. An explicit -X always wins, -I forces HEAD, and -G keeps the method GET while moving any data into the query string.

Does the generated code keep JSON request bodies as real objects?

Yes. When the Content-Type is application/json and the body parses cleanly, the converter emits native literals — a JavaScript object for fetch and Axios, a Python dict, a PHP array passed to json_encode — instead of an opaque string, so the request body is easy to read and edit.