consolelog.tools

cURL to Code Converter

Paste a cURL command → live code in 8 languages. Handles single/double quotes, line continuations, basic auth, --data-urlencode, cookies.

About this ToolHow it works, benefits & use cases

Paste a cURL command and this converter rewrites it as an HTTP request in the language you actually ship. It runs a shell-aware tokenizer over the command — joining `\` line continuations, handling single quotes, double quotes with backslash escapes, and bare tokens — then maps the request onto eight targets: JavaScript Fetch, Axios, Python Requests, PHP cURL, Go net/http, Ruby Net::HTTP, the Java HttpClient, and Rust reqwest. It understands more than the URL and method: `-H` headers, `-d`/`--data-raw` bodies, `--data-urlencode` (with the matching form content-type), `-u` basic auth (base64-encoded into an Authorization header), cookies, user-agent, and referer flags. A live stats strip shows the parsed method, header count, whether a body and auth are present, and how many query parameters are in the URL. Conversion happens as you type, entirely in the browser.

How to Use

  1. 1Pick a Target language from the dropdown (Fetch, Axios, Python, PHP, Go, Ruby, Java, or Rust).
  2. 2Paste your cURL command into the input — multi-line commands with `\` continuations are fine, or click "Load example" to start from a sample POST.
  3. 3Watch the generated code update live, and check the stats strip for the parsed method, header count, body, auth, and query-param totals.
  4. 4Click "Convert to <language>" to confirm the command parsed cleanly (it surfaces an error if no URL was found).
  5. 5Copy the result, download it with the correct file extension, or share the input via URL.

Key Benefits

  • Eight output targets from one command: Fetch, Axios, Python, PHP, Go, Ruby, Java, Rust
  • Shell-aware parsing handles single/double quotes, backslash escapes, and `\` line continuations
  • Decodes `-u` basic auth into a base64 Authorization header automatically
  • Recognises `--data-urlencode` and sets the matching form content-type
  • Pulls in cookies, user-agent, and referer flags as headers
  • Live stats: method, header count, body present, auth present, query-param count
  • Downloads with the right extension per language (.js, .py, .php, .go, .rb, .java, .rs)

Common Use Cases

  • Turning a cURL example from API docs into your project language
  • Converting a request copied from browser DevTools "Copy as cURL" into Fetch or Axios
  • Porting a shell script of API calls into a Python or Go client
  • Learning how the same request maps across HTTP client libraries
  • Reproducing a teammate's reported request in a different stack to debug it

Conversion options

Multi-line commands with `\\` continuations are accepted.

Paste a cURL command to convert.

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related tools