Skip to content

Menu

cURL Converter

Convert curl commands to fetch, axios, Python requests, Go, and PHP code.

Runs entirely in your browserAPI & HTTPFree, no sign-up
Loading tool

01What is cURL Converter?

API docs love curl. Your codebase probably doesn't. cURL Converter takes a curl command and turns it into code for five targets: JavaScript fetch, Axios, Python requests, Go net/http and PHP's curl extension. The command is read the way a shell would read it first. That covers single and double quotes, backslash line continuations and the $'...' strings that Chrome's Copy as cURL (bash) produces. Then the options are read the way curl itself reads them, following the option list in curl's own manual. The parser knows which options take a value, so in curl --retry 3 https://api.example.com the 3 isn't mistaken for the URL. It also handles short-option clusters like -sSL and attached values like -XPOST. Repeated -d values are joined with &, just as curl joins them, and --data-urlencode values are percent-encoded. With -G the data moves into the query string instead of the body. --json sets both the JSON Content-Type and Accept headers. If you send data without a Content-Type header, the converter adds application/x-www-form-urlencoded, which is what curl would send. It also understands -u basic auth, cookie strings from -b, -A, -e, --oauth2-bearer and -F multipart fields. Go output skips multipart. Timeouts from -m/--max-time and --connect-timeout are mapped where the target library has an equivalent. -L becomes a redirect option in PHP, and -k turns off certificate checks with a warning comment. A worked example: curl -G -d q=hello --data-urlencode 'name=a b' https://example.com/s with the Fetch tab selected. The output is a single fetch call to https://example.com/s?q=hello&name=a%20b, followed by response.json(). Options the parser doesn't recognise aren't silently dropped. They're listed in a Note line at the top of the generated code, so you know what was left out. A few limits are worth knowing. Files referenced with @ can't be read from a browser page, so you get a placeholder to fill in. The generated code is a starting point, not a full port of curl's behaviour. Retries, proxies and most TLS options have no direct mapping, and the output always assumes a JSON response. Redirect handling differs too, since most of these clients follow redirects by default and curl doesn't. Everything runs locally in your browser.

Developers wiring up third-party APIs use it to turn curl snippets from docs or DevTools into fetch, Axios, Python, Go or PHP code. The tool runs entirely in your browser, so your data never leaves your device.

02How to use cURL Converter

  1. Paste a curl command into the cURL Command box, line breaks and all.
  2. Pick a target tab: Fetch, Axios, Python, Go or PHP.
  3. Check the method and URL badge, and read any Note lines at the top of the generated code.
  4. Switch tabs to compare the same request in other languages.
  5. Click Copy Code and paste the result into your project.

03Worked examples

Input: curl https://api.example.com/users (Fetch)
Result: const response = await fetch("https://api.example.com/users"); const data = await response.json();
Input: curl -X POST https://api.example.com/items -H 'Content-Type: application/json' -d '{"name":"pen"}' (Python)
Result: import requests headers = { "Content-Type": "application/json", } response = requests.post("https://api.example.com/items", headers=headers, data="{\"name\":\"pen\"}") data = response.json()
The body is sent as the exact string curl would send rather than re-encoded through json=.
Input: curl -u admin:secret https://example.com/x (Fetch)
Result: const response = await fetch("https://example.com/x", { headers: { "Authorization": "Basic " + btoa("admin:secret"), }, }); const data = await response.json();
-u becomes a Basic Authorization header.
Input: curl -d 'a=1' -d 'b=2' https://example.com/form (Go)
Result: … body := strings.NewReader("a=1&b=2") req, err := http.NewRequest("POST", "https://example.com/form", body) … req.Header.Set("Content-Type", "application/x-www-form-urlencoded") …
Repeated -d values are joined with &, -d implies POST, and curl's default form content type is added (excerpt of the full program).
Input: curl -I https://example.com (Axios)
Result: const { data } = await axios({ method: "head", url: "https://example.com", });
-I is a HEAD request.
Input: curl -G -d q=hello --data-urlencode 'name=a b' https://example.com/s (Fetch)
Result: const response = await fetch("https://example.com/s?q=hello&name=a%20b"); const data = await response.json();
-G moves the data into the query string, and --data-urlencode encodes the space as %20.

04Common use cases

  • Converting curl examples from API documentation into fetch or Axios code for your application
  • Translating browser DevTools Copy as cURL output into Python requests code for scripting
  • Porting curl calls from a shell script into a Go or PHP service
  • Producing the same request in several languages for SDK or API docs
  • Turning a webhook provider's curl test command into a Go handler test or PHP script
  • Spotting which curl flags in a long DevTools capture have no equivalent, using the Note line at the top of the output

05Tips

  • Copy as cURL in the browser DevTools Network tab captures every header and cookie of a real request, so remove session cookies and tokens before sharing the converted code.
  • Files referenced with @ (as in -d @body.json or -F [email protected]) can't be read in the browser, so the code gets a placeholder you need to fill in.
  • fetch, Axios, requests and Go's client follow redirects by default, while curl only does with -L. Check redirect-sensitive calls by hand.
  • Python requests applies its timeout per connection and per read, not as a total limit like curl's --max-time.
  • If the command used -k, the PHP and Python output disables certificate checks too, with a comment. Remove those lines before production.

06Related concepts

HTTP client, fetch API, requests library, net/http.

Frequently Asked Questions

What is cURL Converter?

cURL Converter is a free, browser-based developer tool on AIDToolStack. Convert curl commands to fetch, axios, Python requests, Go, and PHP code. It requires no installation or sign-up and works entirely in your browser.

Is cURL Converter free to use?

Yes. No sign-up, no fees and no usage cap.

Does cURL Converter store my data?

No. It runs in your browser; nothing is uploaded.

Cheat sheet

Related Tools

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe