Curl Cheatsheet

cURL is a powerful and versatile command-line tool for transferring data with URLs. It supports a wide range of protocols including HTTP, HTTPS, FTP, and more. cURL is widely used by developers and system administrators for testing APIs, automating file downloads and uploads, debugging network issues, and scripting complex data transfers. Its flexibility and extensive options make it an essential tool for web development, DevOps, and cloud workflows.

This cheatsheet provides a comprehensive and practical reference for common curl commands. It covers HTTP requests, authentication, headers, cookies, data transfer, and more. Use it to boost your productivity and master curl workflows.

cURL Cheatsheet

HTTP client commands for API testing

54

Commands

8

Categories

0

Favorites

15

Sections

Basic
Basic Requests
curl https://example.com

Simple GET request

curl -o file.html https://example.com

Save output to file

curl -O https://example.com/file.zip

Save with original filename

curl -L https://example.com

Follow redirects

curl -I https://example.com

Fetch headers only (HEAD)

curl -i https://example.com

Include response headers

Basic
Output Control
curl -s https://example.com

Silent mode (no progress)

curl -v https://example.com

Verbose output

curl -w '%{http_code}' https://example.com

Show HTTP status code

curl -w '%{time_total}' https://example.com

Show total time

Methods
Request Methods
curl -X GET https://api.example.com/users

GET request (default)

curl -X POST https://api.example.com/users

POST request

curl -X PUT https://api.example.com/users/1

PUT request

curl -X PATCH https://api.example.com/users/1

PATCH request

curl -X DELETE https://api.example.com/users/1

DELETE request

Methods
POST Data
curl -d 'key=value' https://example.com

Send form data (POST)

curl -d 'key1=val1&key2=val2' https://example.com

Multiple form fields

curl -d @data.txt https://example.com

Send data from file

curl --data-urlencode 'key=value with spaces' https://example.com

URL-encode data

Headers
Custom Headers
curl -H 'Content-Type: application/json' https://example.com

Set Content-Type

curl -H 'Accept: application/json' https://example.com

Set Accept header

curl -H 'X-Custom: value' https://example.com

Custom header

curl -A 'Mozilla/5.0' https://example.com

Set User-Agent

curl -e 'https://referrer.com' https://example.com

Set Referer header

Headers
JSON Requests
curl -H 'Content-Type: application/json' -d '{"name":"John"}' https://api.example.com

POST JSON data

curl -H 'Content-Type: application/json' -d @data.json https://api.example.com

POST JSON from file

💡 Always set Content-Type header when sending JSON

Auth
Basic & Digest Auth
curl -u user:pass https://example.com

Basic authentication

curl -u user https://example.com

Basic auth (prompt for password)

curl --digest -u user:pass https://example.com

Digest authentication

Auth
Token Authentication
curl -H 'Authorization: Bearer TOKEN' https://api.example.com

Bearer token

curl -H 'X-API-Key: YOUR_KEY' https://api.example.com

API key header

Cookies
Cookie Management
curl -b 'name=value' https://example.com

Send cookie

curl -c cookies.txt https://example.com

Save cookies to file

curl -b cookies.txt https://example.com

Load cookies from file

curl -b cookies.txt -c cookies.txt https://example.com

Load and save cookies

💡 Use -b and -c together to maintain session

SSL/TLS
SSL Options
curl -k https://example.com

Allow insecure SSL

curl --cacert ca.crt https://example.com

Use custom CA certificate

curl --cert client.crt --key client.key https://example.com

Client cert with key

curl --tlsv1.2 https://example.com

Force TLS 1.2

curl --tlsv1.3 https://example.com

Force TLS 1.3

Advanced
Proxy & Network
curl -x http://proxy:8080 https://example.com

Use HTTP proxy

curl -x socks5://proxy:1080 https://example.com

Use SOCKS5 proxy

curl --resolve example.com:443:1.2.3.4 https://example.com

Custom DNS resolution

Advanced
Timeouts & Limits
curl --connect-timeout 10 https://example.com

Connection timeout (seconds)

curl -m 30 https://example.com

Max time for operation

curl --limit-rate 100k https://example.com/file.zip

Limit download speed

curl --retry 3 https://example.com

Retry on failure

Advanced
File Upload
curl -F '[email protected]' https://example.com/upload

Upload file (multipart)

curl -T file.txt https://example.com/upload

PUT upload

Combos
API Testing
curl -s https://api.example.com/users | jq .

Pretty print JSON response

curl -s -o /dev/null -w '%{http_code}' https://example.com

Get only status code

curl -s -w '\nTime: %{time_total}s\n' https://example.com

Show response time

Combos
Download
curl -C - -O https://example.com/file.zip

Resume download

curl -r 0-999 https://example.com/file.zip

Download first 1000 bytes

Quick Reference

GET request

curl URL

POST data

curl -d 'data' URL

Headers

curl -H 'Key: Val' URL

Auth

curl -u user:pass URL

Categories

  • Basic Usage

    Simple GET requests, download files, and view responses.

  • HTTP Methods

    Use different HTTP methods like POST, PUT, DELETE, etc.

  • Headers & Cookies

    Set custom headers, user agents, and manage cookies.

  • Authentication

    Use basic, bearer, and other authentication methods.

  • Data Transfer

    Send data as form, JSON, or upload files.

  • Advanced Usage

    Advanced options, debugging, proxies, and more.

Features

  • Quick search functionality
  • Organized by categories
  • Clear command descriptions
  • Common and advanced use cases covered
  • Easy to copy commands
  • Responsive design
  • Perfect for quick reference