cURL to Code Converter

Paste a curl command, get ready-to-run fetch, axios, Python or PHP code.

Free cURL to code converter. Paste any curl command and instantly get fetch, axios, Node https, Python requests, Python httpx, PHP cURL or Go code. Method, headers, JSON, form and basic-auth all parsed. Runs entirely in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What does a cURL to code converter do?

It reads a curl command, breaks it into its parts (HTTP method, URL, headers, request body, authentication) and rewrites that same request as code in your chosen language. Instead of hand-translating flags like -X, -H and -d, you paste once and get idiomatic fetch, axios, Python requests, httpx, PHP cURL, Node https or Go code that makes the identical request.

A cURL to code converter that turns any curl command into ready-to-run client code. Paste a command copied from your terminal, an API’s documentation, or your browser’s “Copy as cURL” menu, and the tool parses every flag — the HTTP method, the URL and query string, each header, the request body, and basic authentication — then rewrites the exact same request as fetch, axios, Node https, Python requests, Python httpx, PHP cURL, or Go net/http code. It is for developers who test an endpoint with curl and then need that call inside a real application without hand-translating a wall of -H and -d flags.

How it works

The converter runs a small shell-aware tokeniser over your command. It respects single and double quotes, backslash line continuations (the trailing \ that wraps a long curl command across multiple lines), and the limited set of escapes a POSIX shell applies inside double quotes. The resulting arguments are parsed into a structured request: method, URL, an ordered list of headers, the body, any -F form fields (including @file uploads), and -u basic-auth credentials.

From that structured request, each language generator emits idiomatic code. A JSON body is pretty-printed and rendered as a native object — a JavaScript object literal wrapped in JSON.stringify, a real Python dict, a PHP associative array, or a string reader in Go. URL-encoded bodies become URLSearchParams, a Python data= dict, or http_build_query. Multipart uploads map to FormData, Python files=, or PHP CURLFile. Transport-only flags such as --max-time, --compressed and -s are recognised and skipped, and every dropped or inferred detail is surfaced as a warning so nothing changes silently.

Example

Take a typical POST with a JSON body:

curl -X POST 'https://api.example.com/v1/orders' \
  -H 'Authorization: Bearer sk_test_abc123' \
  -H 'Content-Type: application/json' \
  --data-raw '{"item":"widget","qty":3}'

The fetch output sets the method, copies both headers into a headers object, and emits body: JSON.stringify({ item: "widget", qty: 3 }). Switch to the Python requests tab and the same body becomes json={'item': 'widget', 'qty': 3} with a matching headers dict; the PHP tab builds a CURLOPT_HTTPHEADER array and json_encodes the payload. Every tab makes the identical HTTP request — only the language differs.

Everything is computed in your browser. Your command, tokens and request bodies are never uploaded, logged or stored on any server.