cURL to code converter
About cURL to Code
This cURL to code converter turns a cURL command into request code. Copy a command from your browser's DevTools, an API doc or a terminal, and get the same request as JavaScript fetch, Python requests or Go net/http.
Pick JSON output to inspect the command instead: the method, URL, headers, body, auth and any flags the converter did not translate. The command is only read as text. It never runs, and no request is sent.
Runs in your browser. Nothing is uploaded.
How it works
Text-only tokenizing
Single quotes, double quotes, escapes and backslash line continuations are read only to split the arguments. Variables, substitutions, globs, redirects and shell operators are never evaluated.
What gets converted
The method (-X), URL, headers (-H), body (-d, --data-raw, --data-binary, --json), basic auth (-u), cookies (-b), -G query data and -I HEAD requests carry over to the code. Flags with no equivalent, such as -k or -o, are listed in a comment at the top.
JSON bodies stay readable
When the body is valid JSON, fetch code builds it with JSON.stringify and Python code passes a dict through json=, with true, false and null written as True, False and None. Go keeps the body as a string literal.
Credentials hidden by default
Authorization headers, cookies, API key headers and basic auth passwords are replaced with [REDACTED] in every output. Turn redaction off when you need the real values in the code.
Frequently asked questions
Will this run the cURL command?
No. The command is parsed as plain text. No process, shell, file read or HTTP request is created.
How do I convert cURL to Python requests?
Paste the command and pick Python. You get a script that imports requests, sets the URL, headers and body, calls requests.post or the matching method, and prints the status and response text.
How do I convert cURL to JavaScript fetch?
Paste the command and keep the fetch output. The code uses the standard fetch API with await, so it runs in browsers, Node.js 18 and later, Deno and Bun.
Does it support every cURL option?
No. It covers the options that shape the request. Others, such as --compressed, -k or --retry, are listed in a comment instead of being guessed.
What happens to --data @file.json?
The @file.json token is copied as written. The browser never reads the referenced file, so replace it with the file contents in your code.
Learn more
Sources & last verified
We checked this tool's behavior and the claims on this page against the specifications below on . The tool runs in your browser, so the output you see is exactly what the engine produced.
Found a wrong result or an outdated claim? Report an error and we will check it again.