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.

Basic Usage

curl https://example.comSimple GET request to fetch a web page
curl -O https://example.com/file.zipDownload a file and save with original filename
curl -o myfile.zip https://example.com/file.zipDownload a file and save as myfile.zip
curl -I https://example.comFetch only the HTTP headers
curl -L https://example.comFollow redirects automatically

HTTP Methods

curl -X POST https://example.comSend a POST request
curl -X PUT https://example.comSend a PUT request
curl -X DELETE https://example.comSend a DELETE request
curl -X PATCH https://example.comSend a PATCH request
curl -d 'key=value' https://example.comSend form data with POST (default method)

Headers & Cookies

curl -H 'User-Agent: CustomAgent' https://example.comSet a custom User-Agent header
curl -H 'Authorization: Bearer TOKEN' https://example.comSet a Bearer token header
curl -b 'name=value' https://example.comSend cookies with request
curl -c cookies.txt https://example.comSave cookies to a file
curl -b cookies.txt https://example.comSend cookies from a file
curl -e https://referrer.com https://example.comSet the Referer header

Authentication

curl -u user:pass https://example.comHTTP Basic authentication
curl --digest -u user:pass https://example.comHTTP Digest authentication
curl -H 'Authorization: Bearer TOKEN' https://example.comBearer token authentication
curl --negotiate -u : https://example.comNegotiate authentication (Kerberos, etc.)

Data Transfer

curl -d 'key=value' https://example.comSend URL-encoded form data
curl -d @data.json https://example.comSend data from a file
curl -H 'Content-Type: application/json' -d '{"key":"value"}' https://example.comSend JSON data
curl -F 'file=@/path/to/file' https://example.com/uploadUpload a file with multipart/form-data
curl --data-urlencode 'key=value' https://example.comSend URL-encoded data

Advanced Usage

curl -x http://proxy:8080 https://example.comUse a proxy server
curl -k https://example.comAllow insecure SSL connections
curl -v https://example.comShow verbose output for debugging
curl --limit-rate 100k https://example.com/file.zipLimit download speed
curl --compressed https://example.comRequest a compressed response (gzip, deflate)
curl -s https://example.comSilent mode (no progress or error messages)
curl -w '%{http_code}' https://example.comShow only the HTTP status code
curl -T file.txt https://example.com/uploadUpload a file with PUT

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