Skip to main content
Toolisti

Curl to Code Converter

The Curl to Code Converter turns a curl command into working code in six languages.

100% in-browser ยท no data sent

Paste the command โ€” straight from a terminal or from a browser's "Copy as cURL" โ€” and get JavaScript fetch, Node axios, Python requests, PHP cURL, Go net/http or Java HttpClient. Headers, JSON and form bodies, multipart uploads, basic auth and query-string flags all carry across, and the tool shows you exactly what it understood before it writes the code.

Embed This Tool

Add this tool to your website with customizable styling

Get Embed Code

How to Use

1

Paste the curl command

Multi-line commands work as they are: backslash continuations from a shell and caret continuations from cmd.exe are both folded away, and quoting is read the way a shell reads it.

2

Check what was parsed

A short summary shows the method, URL, header count and body type, so you can see the command was read the way you meant it before trusting the output.

3

Pick a target language

Switch between JavaScript fetch, Node axios, Python requests, PHP cURL, Go net/http and Java HttpClient. Each uses that language's own idioms rather than a mechanical translation.

4

Copy or download the code

Copy the snippet straight into your project, or download it with the right file extension for the language you chose.

Frequently Asked Questions

Which curl options are supported?

The common ones for HTTP work: -X/--request, -H/--header, -d/--data and its variants, --data-urlencode, --json, -F/--form and --form-string, -u/--user, -b/--cookie, -A/--user-agent, -e/--referer, -G/--get, -I/--head, -L/--location, -k/--insecure and --url. Flags that only affect curl's own output โ€” -s, -v, -o, --max-time and similar โ€” are recognised and skipped so they cannot be mistaken for the URL.

How is the method decided when there is no -X?

The same way curl decides it. With no data and no form fields the request is a GET. Add -d or -F and it becomes a POST. Use -I and it becomes a HEAD. An explicit -X always wins, so -X PUT with -d gives a PUT.

Why does the generated code turn redirect-following off?

Because curl does not follow redirects unless you pass -L, while fetch, requests and most HTTP clients follow them by default. To make the code behave like the command you pasted, redirect-following is disabled when -L is absent and enabled when it is present. A note under the code points this out so you can change it if you would rather follow redirects.

Is it safe to paste a command containing an API key?

Yes โ€” the conversion runs entirely in your browser. No request is made and nothing is uploaded, so a token in an Authorization header never leaves the page. The generated code will of course contain that token, so treat the snippet as a secret before pasting it anywhere shared.