DocumentsImagesMediaPDF Tools

cURL to Code

Convert cURL commands to JavaScript, Python, Go, PHP, and more, in your browser.

const response = await fetch("https://api.example.com/users", {
  method: "POST",
  headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer token123"
  },
  body: "{",
});
const data = await response.json();
console.log(data);
Processed in your browser

From cURL command to production-ready code

Multiple languages

JavaScript, Python, Go, PHP, Ruby, and more. Choose the language for your stack.

Headers and auth included

Converts commands with Bearer tokens, Basic Auth, API keys, and JSON body without losing anything.

Instant

Convert any cURL command to functional code in under 1 second.

Private

Your tokens and commands never leave your browser. No logs, no servers.

Three steps, no hassle

1

Paste your cURL command

Copy the cURL command from your terminal, API documentation, or browser DevTools (right-click on a request > Copy as cURL).

2

Choose the target language

Select JavaScript (fetch/axios), Python (requests), Go (net/http), PHP (cURL), Ruby, or whatever you need for your project.

3

Copy the generated code

The converter generates the equivalent HTTP code with headers, body, method, and authentication included. Ready to paste into your project.

Got questions?

cURL (Client URL) is a command-line tool and library for transferring data with URLs, created by Daniel Stenberg in 1997. The first prototype was called httpget and appeared in November 1996; in March 1998 it was renamed to curl and became open source. Today libcurl (the underlying C library) is embedded in billions of devices: Windows, macOS, iOS, Android operating systems, routers, smart TVs, game consoles, and virtually any internet-connected device.

cURL accepts authentication headers via the -H flag. For Bearer tokens: curl -H 'Authorization: Bearer YOUR_TOKEN'. For Basic Auth: curl -u user:password (cURL encodes it in Base64 automatically) or curl -H 'Authorization: Basic BASE64_ENCODED'. For API keys: curl -H 'X-API-Key: YOUR_KEY'. The converter detects the authentication type and generates the equivalent code in the selected language.

GET is the default method in cURL when no data flags are specified. POST is activated automatically when using -d or --data. You can force methods explicitly with -X: curl -X POST, curl -X PUT, curl -X DELETE, curl -X PATCH. For PATCH with JSON body: curl -X PATCH -H 'Content-Type: application/json' -d '{"field":"value"}' URL.

To send JSON in the body: curl -X POST -H 'Content-Type: application/json' -d '{"key":"value"}' URL. The Content-Type: application/json header is required for the server to interpret the body as JSON. For JSON in a file: curl -X POST -H 'Content-Type: application/json' -d @data.json URL. The @ symbol indicates the value is a file path.

The -k or --insecure flag tells cURL to ignore TLS/SSL certificate errors, including self-signed, expired, or unrecognized CA certificates. It is useful for development environments with local certificates, but should NEVER be used in production or in scripts handling sensitive data: without TLS verification, the connection is vulnerable to man-in-the-middle attacks. In production, the correct solution is to install your private CA root certificate with --cacert or properly configure the server certificate.

cURL: history, the libcurl ecosystem, and how HTTP works

The cURL story begins with Daniel Stenberg, a Swedish developer who in November 1996 published httpget, a small script to download currency exchange data from the internet for an IRC channel. In January 1998 the project was renamed to curl (version 4.0) and began supporting multiple protocols. In March 1998 libcurl appeared, the reusable C library, which transformed the command-line tool into an infrastructure component. In 2024, cURL version 8.x supports over 25 protocols: HTTP/1.1, HTTP/2, HTTP/3 (QUIC), HTTPS, FTP, FTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS, IMAP, SMTP, POP3, RTSP, RTMP, and more.

libcurl is arguably the most widely distributed software library in the world. It is embedded in the Windows operating system (since Windows 10 build 17063, 2017, as native curl.exe), macOS (since macOS 10.15 Catalina), iOS, Android NDK, and in thousands of products: Cisco and Juniper routers, Samsung and LG smart TVs, PlayStation and Xbox consoles, the International Space Station control system, and NASA's Mars Curiosity and Perseverance rovers. Daniel Stenberg actively maintains the project with over 25 years of uninterrupted commits. In 2020, the Internet Society recognized cURL with the Internet Hall of Fame award.

The Postman vs cURL vs Insomnia comparison reflects different API workflow philosophies. Postman (founded 2012, currently over 25 million users) and Insomnia (acquired by Kong in 2019) offer graphical interfaces for organizing request collections, managing environments, and team collaboration. cURL is the universal command-line tool: present on any Linux/macOS system, scriptable in bash, reproducible in documentation and CI/CD. The 'Copy as cURL' feature in Chrome, Firefox, and Safari DevTools (right-click any request in the Network tab) turns the browser into a cURL command generator, allowing you to exactly reproduce any browser HTTP request in the terminal or convert it to code with this tool.