More games at WuGames.ioSponsoredDiscover free browser games — play instantly, no download, no sign-up.Play

cURL to Code Converter

Convert curl to fetch, Python, PHP, Node, Java, C# and more. Paste a Chrome DevTools 'Copy as cURL' and redact API keys in one click. Client-side.

Mask tokens, cookies & basic-auth in the output
Parsed request

About the cURL to Code Converter

Paste a cURL command and instantly get equivalent code in JavaScript (fetch / axios / XHR), Python (requests), PHP (cURL), Node.js (https), Go (net/http), Ruby (Net::HTTP), Java (HttpClient), C# (HttpClient), Rust (reqwest) or Swift (URLSession). The tool parses cURL flags faithfully — -X, -H, -d, --data-urlencode, -F, -u, -b, --cookie, -A, --compressed, -L, -k, -G — so the generated code matches the exact request your terminal would send.

How does the cURL to code converter work?

It tokenizes your cURL command exactly like a shell would (respecting quotes, escapes and line continuations), parses the flags into a request object (URL, method, headers, body, auth, cookies), then renders that object as idiomatic code for the target language. The whole process happens client-side in your browser — no server roundtrip and no data leaves your machine.

Which cURL flags are supported?

-X / --request, -H / --header, -d / --data / --data-ascii / --data-raw / --data-binary, --data-urlencode, -F / --form, -u / --user, -b / --cookie, -A / --user-agent, -e / --referer, -L / --location, -k / --insecure, -G / --get, --compressed, --url. Flags that don't affect the generated code (-s, -v, -i, -I, -o, --http2) are recognized and safely ignored.

Can I paste a cURL with line breaks (\ continuations)?

Yes. The parser collapses backslash-newline pairs before tokenizing, so you can paste a multi-line cURL command copied from Chrome DevTools, Postman or your terminal history directly into the input box.

Does it detect JSON bodies?

When the body looks like a JSON object or array and parses successfully, the converter adds the Content-Type: application/json header in the generated code automatically (unless you already set one explicitly via -H). In Python it uses json= instead of data= so requests serializes the body for you.

How are multipart form uploads (-F) handled?

The converter emits FormData (JS), a {data, files} pair (Python), CURLFile entries (PHP), or the equivalent multipart construct for each language. Fields starting with @ are recognized as file paths and the generated code includes a placeholder line for attaching the file.

cURL to Code Converter — Convert curl to fetch, Python, PHP, Node, Java, C# and more. Paste a Chrome DevTools 'Copy as cURL' and redact API keys
cURL to Code Converter

What about -u for HTTP basic auth?

-u user:pass is translated to the idiomatic auth API of each language: Basic + base64 in fetch/XHR/Node, auth=(user,pass) in Python, CURLOPT_USERPWD in PHP, SetBasicAuth in Go, basic_auth() in Ruby/Rust, AuthenticationHeaderValue in C#, and a base64 Authorization header in Java/Swift.

Why is the output for -G different?

When cURL sees -G (or --get), it moves the -d data into the URL as a query string instead of sending it as a body. The converter does the same: data from -d is appended to the URL with ? or & and the request becomes a GET with no body — matching cURL's actual behavior.

Can I copy a cURL command from Chrome DevTools and convert it?

Yes — that is the most common use case. Open DevTools → Network tab → right-click a request → Copy → Copy as cURL (bash). Paste it into the input box. The tool handles all the shell quoting, headers, cookies and bodies Chrome generates, then produces clean code in the language of your choice.

Is it safe to paste a cURL with API keys or tokens?

Yes. The conversion is 100% client-side — your cURL command, Authorization headers, cookies and Basic-auth credentials are parsed entirely in your browser and never sent to any server. For extra safety when you plan to commit or share the snippet, tick the 'Redact secrets' checkbox: it masks Authorization, api-key, token, cookie and -u credentials and rewrites them as an environment-variable accessor (process.env.API_TOKEN in JS/Node, os.environ['API_TOKEN'] in Python, getenv('API_TOKEN') in PHP, os.Getenv in Go, ENV[] in Ruby, System.getenv in Java, and so on), so no live secret ever ends up in the generated code.

fetch vs axios vs XHR — which should I pick?

Use fetch for modern browsers and edge/serverless runtimes — it is built in, promise-based and needs no dependency. Use axios when you want automatic JSON parsing, request/response interceptors, timeouts and broad Node + browser support (it does add a dependency). Pick XHR only for legacy environments that lack fetch. For the Node.js (https) target you get the zero-dependency core module, while axios on Node also works server-side — choose axios for richer features, native fetch or https for the lightest footprint.

Features

  • 12 target languages and libraries — fetch, axios, XHR, Python requests, PHP cURL, Node.js, Go, Ruby, Java, C#, Rust, Swift
  • Handles shell quoting: single quotes, double quotes, escapes, line continuations (\), $'...' ANSI strings
  • Recognizes 25+ cURL flags including -X, -H, -d, --data-raw, --data-urlencode, --data-binary, -F, --form, -u, --user, -b, --cookie, -A, -e, -L, -k, -G, --compressed
  • Auto-detects JSON bodies and emits the right Content-Type
  • Multipart form-data (-F) generates FormData / files = {} / CURLFile boilerplate
  • Basic auth (-u user:pass) is mapped to language-idiomatic auth APIs
  • Cookie header consolidation from multiple -b flags
  • -G + -d moves data into the query string as cURL does
  • Real-time conversion — switch target tabs and the code updates instantly
  • Copy + download the generated snippet with one click
  • 100% client-side: your cURL command and headers never leave the browser
  • Available in English, Spanish, Vietnamese, Portuguese and French