{ }
DevToolsLabs
Back to Guides

The Ultimate Guide to cURL Commands

cURL is the Swiss Army knife of data transfer. Whether you are debugging an API or downloading a script, these essential commands will save you hours of work.

March 12, 2026
8 min Read

What is cURL?

cURL (short for "Client URL") is a command-line tool and library for transferring data with URLs. It supports a vast range of protocols, including HTTP, HTTPS, FTP, and more. For most web developers, it is the primary way to test REST APIs without a browser.

The Basics: Simple GET Requests

The most basic cURL command is just the tool name followed by a URL:

curl https://api.example.com/data

To view the response headers along with the body, use the -i flag:

curl -i https://api.example.com/data

Sending Data with POST

To create or update resources, you will use the -X POST method along with the -d (data) flag:

curl -X POST -d "name=John&email=john@example.com" https://api.example.com/users

For JSON payloads, which are the standard for modern APIs, you must explicitly set the Content-Type header using the -H flag:

curl -X POST -H "Content-Type: application/json" -d '{"name": "John", "age": 30}' https://api.example.com/users

Pro Tip: cURL to Fetch

If you have a complex cURL command from your browser's dev tools or documentation, you can use our cURL to Fetch tool to instantly convert it into a JavaScript snippet for your frontend code.

Uploading Files

Need to test a file upload endpoint? Use the -F (form) flag. The @ symbol tells cURL to read the file from your local disk:

curl -F "profile_picture=@/path/to/image.png" https://api.example.com/upload

Authentication

Most APIs are secured. For Basic Auth, use the -u flag:

curl -u "username:password" https://api.example.com/secure

For Bearer Tokens (common in JWT-based systems), use a custom Authorization header:

curl -H "Authorization: Bearer YOUR_TOKEN_HERE" https://api.example.com/protected

Summary

Mastering cURL makes you a more efficient developer. It allows you to isolate server-side behavior from frontend bugs and provides a platform-independent way to share API reproduction steps.