Skip to content

cURL Converter — JavaScript, Python, Go, PHP

cURL Command
JS (fetch) Output0 chars
Generated code will appear here...

Supports:
- GET, POST, PUT, PATCH, DELETE
- Custom headers (-H)
- JSON body (-d)
- Form data (-F / --data-urlencode)
- Basic auth (-u)
- Multi-line with backslash continuation

Supported Features

All HTTP methods (GET, POST, PUT, PATCH, DELETE)
Custom headers (-H / --header)
JSON body (-d / --data / --data-raw)
Form data (-F / --form / --data-urlencode)
Basic auth (-u / --user)
Multi-line with \ continuation
Single and double quoted values
6 target languages
Parsed request summary
Download generated file
Copy to clipboard

What This Tool Does

Paste a curl command and get equivalent HTTP request code in six targets: JavaScript fetch, JavaScript axios, Python requests, Node.js http, PHP, and Go. Parsing runs entirely in your browser — no request is sent. It reads headers, JSON and form bodies, and -u basic auth, which it expands into a static Authorization: Basic header. Scrub those credentials before you share the generated code.

Last updated:

This tool is provided as-is for convenience. Output should be verified before use in any production or critical context.

Programmatic Access

cURL Converter — JavaScript, Python, Go, PHP is also callable as a free HTTP JSON API at https://aidevhub.io/api/curl-converter/ — GET with query parameters or POST with a JSON body, no authentication, CORS enabled, 50 requests/day per IP. Responses return { ok, tool, result, meta }.

curl -s -X POST https://aidevhub.io/api/curl-converter/ \
  -H "Content-Type: application/json" \
  -d '{"curl":"curl -X POST https://api.example.com/users -H \"Content-Type: application/json\"","lang":"python"}'

Machine-readable contract: /api/tool/curl-converter.json All API endpoints: /agents/ LLM site index: /llms.txt

Agent Invocation

Best Path For Builders

Dedicated API endpoint

Deterministic outputs, machine-safe contracts, and production-ready examples.

Dedicated API

https://aidevhub.io/api/curl-converter/

OpenAPI: https://aidevhub.io/api/openapi.yaml

GET /api/curl-converter/ GET curl-converter
POST /api/curl-converter/ POST curl-converter

Unified Runtime API

https://aidevhub.io/api/tools/run/?toolId=curl-converter&a=...

GET and POST are supported at /api/tools/run/ with identical validation and limits.

Limit: 30 req / 60s, input max 256 KB.

How to Use cURL Converter — JavaScript, Python, Go, PHP

  1. 1

    Paste your cURL command

    Copy any cURL command from your terminal, browser DevTools, API docs, or Postman and paste it into the left panel. Multi-line commands with backslash continuation are supported automatically.

  2. 2

    Select target language

    Click a language tab — JS (fetch), JS (axios), Python, Node.js http, PHP, or Go — to generate idiomatic code for that language. The output updates instantly without any server calls.

  3. 3

    Review parsed request details

    Below the panels, a summary shows the detected HTTP method, URL, and headers extracted from your cURL command. Use this to confirm the parser understood the request correctly before copying.

  4. 4

    Copy or download the code

    Click Copy Code to copy to clipboard, or Download to save as a file with the correct extension (.js, .py, .go, .php). Drop it directly into your project.

Frequently Asked Questions

What is cURL Converter?
cURL Converter is a free online tool that transforms cURL commands into idiomatic code for JavaScript (fetch or Axios), Python requests, Node.js http, PHP curl, and Go net/http — instantly and entirely in your browser.
How do I convert a cURL command?
Paste your cURL command into the left panel, then click the target language tab (JS fetch, JS axios, Python, Node.js, PHP, or Go). The converted code appears immediately in the right panel. Use the Sample cURL button to try an example.
Is cURL Converter free?
Yes. cURL Converter is completely free with no sign-up required.
Does cURL Converter send my data to a server?
No. All parsing and code generation happens entirely in your browser. Your cURL commands — which may contain API keys or tokens — never leave your device.
What cURL options are supported?
Supported flags include: -X (method), -H (headers), -d / --data / --data-raw / --data-binary (body), -F / --form (form data), --data-urlencode (URL-encoded fields), -u (basic auth), -L (follow redirects), and multi-line commands with backslash continuation.

How do I convert a curl command to fetch, Python, or Go?

Paste the full curl command, pick a target language, and copy the generated code. The converter tokenizes the command in your browser — handling quoting and backslash line continuations — then rebuilds the request using each language's idiomatic HTTP client. No call is made; it only translates the command into source code.

Step by step

  1. Paste a command starting with curl — single and double quotes and multi-line \ continuations are supported.
  2. Choose a target: JS fetch, JS axios, Python, Node.js http, PHP, or Go.
  3. Read the parsed request summary (method, URL, headers) to confirm it was understood.
  4. Copy the generated code or download it as a file with the right extension.

curl flags this converter understands

Flag How it is translated
-X, --request Sets the HTTP method
-H, --header Added to the request headers
-d, --data, --data-raw, --data-binary Request body; JSON is auto-detected, and the method defaults to POST
--data-urlencode Field in an application/x-www-form-urlencoded body
-F, --form Field in a multipart/form-data body
-u, --user Encoded into an Authorization: Basic header (base64)
-L, -s, -v, --compressed, -k Recognized, but do not change the generated code

Flags as this converter parses them. Options outside this set are skipped rather than translated, so review the parsed summary if a request looks incomplete.

Does it handle JSON and form bodies correctly?

Yes, and it picks the matching body type per language. A -d payload that starts with { or a JSON Content-Type becomes a real JSON body (JSON.stringify, json=, and so on); --data-urlencode maps to url-encoded form data and -F to multipart. That is why the axios and requests output uses URLSearchParams or files= rather than sending a plain object.

Which languages and libraries can it output?

Six targets: browser fetch, axios, Python requests, the Node.js built-in http/https module, PHP curl_*, and Go net/http. The Node output even selects http or https based on the URL scheme, since using the wrong one fails the TLS handshake.

Is my curl command sent anywhere?

No. The command is parsed and converted in the page; nothing is transmitted. curl commands frequently contain API keys, cookies, and bearer tokens, so translating them locally — and scrubbing any -u or Authorization value before sharing the code — keeps those secrets off the network.