/

cURL to Code Converter

Processed Client Side

Paste a cURL command and get the same request as Python requests, JavaScript fetch, Node axios, Go net/http, Java or C# HttpClient, or PHP cURL — parsed like a shell would, in your browser.

cURL command · 5 lines
ShellLength: 234Lines: 5Size: 234 BytesCursor: 1:1
Python · requests
Python · requests
PythonLength: 458Lines: 26Size: 458 BytesCursor: 1:1
POSTapi.example.com3 headersJSON body

Bookmark this tool now — skip the search next time you need it.

About cURL to Code Converter

This tool runs entirely in your browser. Whatever you paste is processed on your own device and is never uploaded, logged, or sent to any server.

The cURL to Code Converter takes a command you already have — copied out of an API’s documentation, or out of your browser’s network panel with Copy as cURL — and rewrites it as the same request in Python, JavaScript, Node.js, Go, Java, C#, or PHP. It does not pattern-match the text: the command is tokenized the way a shell would tokenize it, so quotes group, backslashes escape, and a JSON body full of spaces and braces survives intact. Then curl’s own implicit rules are resolved once — that -d means POST and form-urlencoded, that -F means multipart, that -G moves the body into the query string — before any code is written, which is why all seven outputs describe the same request rather than seven slightly different ones. A JSON body comes out as a native dict, object or array you can edit, not as an escaped string you have to unpick. Everything runs in your browser, so the token in that Authorization header never leaves your machine.

Key features

  • Seven targets from one command: Python requests, browser JavaScript fetch, Node.js axios, Go net/http, Java 11+ HttpClient, C# HttpClient, and PHP cURL
  • Standard-library output where a standard library exists — the Go, Java and C# snippets pull in no third-party packages at all
  • A real shell tokenizer — single quotes, double quotes, $’…’ ANSI-C quoting, backslash escapes and line continuations are all handled, so a pasted multi-line command works as-is
  • Reads the Windows shapes of Copy as cURL too: cmd.exe with ^ continuations and doubled "" quotes, and PowerShell with backtick continuations
  • Method inference matching curl’s own: -d implies POST, -F implies POST, -T implies PUT, -I implies HEAD, and an explicit -X always wins
  • Body kinds recognised and expressed idiomatically — JSON as a native structure, form data as URLSearchParams or url.Values or an array, multipart as FormData or CURLFile or multipart.Writer, and a raw body left exactly as written
  • -u becomes each language’s auth idiom: a requests tuple, an axios auth object, Go’s SetBasicAuth, C#’s AuthenticationHeaderValue, a Java Base64 encoder, CURLOPT_USERPWD, and for browser fetch the base64 Authorization header it would have produced
  • Go imports, C# usings and Java imports are each computed from what the snippet actually uses, so nothing arrives unused or missing
  • -G with --data-urlencode is folded into the query string, decoded back into readable key/value pairs
  • Redirect behaviour is always stated explicitly, because curl and the seven clients disagree about the default — curl needs -L, requests, fetch, axios, Go and C# follow regardless, and Java refuses unless asked
  • Flags that cannot survive the translation are reported rather than dropped in silence: client certificates, DNS overrides, Unix sockets, cookie files
  • A summary row showing the method, host, header count, body kind and any warning, so you can check the parse before you trust the code
  • Copy to clipboard or download as a .py, .js, .go, .java, .cs or .php file — and nothing you paste is uploaded

How to use it

  1. Paste your cURL command into the left pane, replacing the sample. A multi-line command with backslashes at the end of each line is fine.
  2. Pick your target language from the selector in the toolbar.
  3. Read the badges under the panes to confirm the method, host, headers and body kind were parsed the way you expected.
  4. Read the generated code on the right — it re-runs on every keystroke and every change of language.
  5. Copy it, or download it as a file, and replace any credentials with a variable before you commit it.

Tips & common mistakes

  • The fastest way to get a command worth converting is your browser: open the network panel, right-click the request, and choose Copy as cURL. It captures the exact headers and cookies the page sent, which is usually what you were trying to reproduce.
  • Check the redirect line before you ship the snippet. Every generated snippet states it, because curl and the client libraries disagree: curl does not follow a 301 unless you pass -L; requests, fetch, axios, Go’s http.Client and .NET’s HttpClient all follow by default; and Java’s HttpClient follows nothing unless you ask it to. A POST that silently follows a redirect is turned into a GET by most servers, which is a genuinely confusing bug to chase.
  • Anything you paste stays in the browser, but the code you copy out does not. A command copied from a browser carries session cookies and bearer tokens — move them into an environment variable before the snippet reaches a repository.
  • A JSON body is re-emitted as a dict, object or PHP array in the languages that have a literal syntax for one — Python, JavaScript, Node and PHP. That is deliberate: it is the form you will want to edit, and it removes a whole class of escaping bugs. Go, Java and C# have no such literal, so they get a string that needs no escaping instead: a Go backtick literal and a C# verbatim string. Either way, a body that is not valid JSON is kept exactly as written.
  • For browser fetch, -k has no counterpart and is reported instead of quietly ignored. A page cannot turn off certificate verification — that is the browser’s decision, not the script’s. Node, Python, Go, C# and PHP all can, and their snippets do. Java can too, but only by building an SSLContext by hand, so the snippet says where to put it rather than printing twenty lines you did not ask for.
  • The C# snippet puts Content-Type on the content object, never on request.Headers. That split trips up almost everyone writing HttpClient for the first time: .NET refuses to attach a content header to a request, and TryAddWithoutValidation drops it silently rather than throwing, so the request goes out with no type at all and the server answers 415.
  • Java gets a hand-built multipart body because java.net.http has no builder for one. It is more code than the other targets, and it is the code you would have had to write yourself — boundary, part headers, CRLFs and the closing delimiter — against a stock JDK with no dependency added.
  • A multipart Content-Type header from the original command is deliberately dropped. The header has to carry the boundary that the client generates for the body it just built, so copying the old one across would describe a body that no longer exists.
  • Data read from a file with -d @payload.json cannot be inlined, because the file is on your machine and this tool never sees it. The snippet opens the file by name instead, which is almost always what you wanted.
  • The converter reports what it cannot carry across rather than pretending. A client certificate, a --resolve DNS override, a Unix socket, or a cookie jar on disk are all configuration of the transport that no short snippet can express — they appear as a warning so you can add them yourself.
  • If the parse looks wrong, check the quoting first. A command that was pasted through a chat client often loses its backslashes or has its quotes turned into typographic ones, and no shell would read that command the way you intended either.

Related tools

Browse all 9 Web / API tools

Frequently asked questions

13

Paste the command into the left pane and pick a language from the selector. The equivalent code appears on the right immediately and updates as you type or switch language. Copy it, or download it as a .py, .js, .go or .php file. Nothing is uploaded — the parsing and the code generation both run in your browser.

Seven targets: Python with requests, browser JavaScript with fetch, Node.js with axios, Go with net/http, Java 11+ with java.net.http.HttpClient, C# with HttpClient, and PHP with the cURL extension. The Go, Java and C# snippets use only the standard library — no package to add before the code runs. Node is given axios rather than a second fetch snippet because the things a browser cannot do — skipping certificate checks, proxying, streaming a file off disk — are exactly what a server-side curl command is usually doing.

Yes. The command is tokenized the way a shell would tokenize it, so a backslash at the end of a line continues it, single and double quotes group their contents, and escapes inside them behave as they do in bash. Bash $’…’ quoting, used when a body contains real newlines, is understood too.

Yes, and that is the most common way to get a command worth converting. All three bash variants work, and so do the two Windows shapes: cmd.exe, which continues lines with ^ and writes a literal quote as "", and PowerShell, which continues lines with a backtick. Remember that a command copied this way carries your session cookies and any bearer token.

The ones that describe a request: -X, -H, -d and every --data variant, --data-urlencode, --json, -F and --form-string, -G, -u, -b, -A, -e, -T, -I, -L, -k, --compressed, -x, -m and --connect-timeout, --oauth2-bearer, and --url. Bundled short flags such as -sSL and glued values such as -XPOST are read correctly. Output-only flags like -s, -v and -o are listed as ignored, because they change what curl prints rather than what it sends.

The same way curl does. An explicit -X always wins. Otherwise -I means HEAD, -T means PUT, any -d or -F means POST, and everything else is GET. That is worth knowing when a command has both -X GET and -d: curl sends a GET with a body, and so does the generated code.

For the request itself, yes — the method, URL, headers, authentication and body all carry across. The one place the clients disagree with curl is redirects, and they disagree with each other too: curl does not follow a 301 unless you pass -L; requests, fetch, axios, Go and .NET follow by default; Java follows nothing unless told. Every snippet therefore states its redirect behaviour explicitly rather than inheriting a default that would differ.

If the body parses as JSON it is re-emitted as a native structure wherever the language has a literal for one: a Python dict, a JavaScript object, a PHP array. That is the form you would have written by hand and the form you will want to edit. Go, Java and C# have no such literal, so they get a string that needs no escaping — a Go backtick literal, a C# verbatim string. A body that is not valid JSON is kept verbatim rather than reformatted.

Yes. Each -F becomes the right idiom for the target: a requests files dict, a FormData in the browser, form-data with a read stream in Node, multipart.Writer in Go, MultipartFormDataContent in C#, and a CURLFile in PHP. Java is the exception — java.net.http has no multipart builder, so the snippet assembles the body by hand with a boundary, part headers and the closing delimiter, which is what you would have had to write anyway. The ;type= and ;filename= modifiers are carried over, and the Content-Type header from the original command is dropped on purpose because the client has to supply its own boundary.

No. Java uses java.net.http.HttpClient, in the JDK since Java 11, and C# uses System.Net.Http.HttpClient from the base class library — the same as Go, which uses net/http alone. The C# snippet is written as top-level statements, so it drops straight into a Program.cs. One .NET detail the generator handles for you: Content-Type is attached to the content object rather than to request.Headers, because .NET silently refuses a content header set on the request and the server then answers 415.

Anything that reads from your disk or reconfigures the transport cannot be inlined, since the file never leaves your machine and this tool never sees it. Reading a body from a file is turned into code that opens that filename; client certificates, DNS overrides, Unix sockets and cookie jars are reported as warnings so you can add them yourself rather than discovering the omission at runtime.

The command never leaves your browser — there is no server to send it to, and the page keeps working offline. The risk is on the way out: the generated snippet contains the same token, so move it into an environment variable before the code reaches a repository or a ticket.

Not this tool, but the cURL Command Builder does the same job from the other direction: fill in the method, URL, headers and body in a form and it assembles a ready-to-run command with the shell quoting handled for you.