ConfigsApr 13, 2026·3 min read

curl — The Command Line Tool for Transferring Data with URLs

curl is the most widely used command-line tool for transferring data with URL syntax. It supports HTTP, HTTPS, FTP, SFTP, and 25+ other protocols. Installed on billions of devices, curl and libcurl are foundational internet infrastructure.

TL;DR
curl transfers data using URL syntax across 25+ protocols including HTTP, HTTPS, FTP, and SFTP, installed on virtually every modern operating system.
§01

What it is

curl is a command-line tool and library (libcurl) for transferring data with URL syntax. It supports HTTP, HTTPS, FTP, SFTP, and over 25 other protocols. curl is installed on billions of devices and is the de facto standard for making HTTP requests from the command line and from applications via libcurl.

Developers, sysadmins, and anyone who interacts with APIs or web services uses curl daily. It is the standard tool for testing endpoints, downloading files, and scripting HTTP interactions in shell scripts and CI/CD pipelines.

§02

How it saves time or tokens

curl is a single binary with no dependencies that works identically across Linux, macOS, and Windows. One curl command replaces writing HTTP client code in any programming language. For API testing and debugging, curl commands are shareable, reproducible, and can be directly pasted from documentation.

§03

How to use

  1. Make a basic GET request:
curl https://api.github.com/users/octocat
  1. POST JSON data:
curl -X POST https://httpbin.org/post \
  -H 'Content-Type: application/json' \
  -d '{"name": "test", "value": 42}'
  1. Download a file with progress:
curl -L -O https://example.com/file.tar.gz
§04

Example

# Send a request with bearer token auth
curl -s https://api.example.com/data \
  -H 'Authorization: Bearer sk-your-token' \
  -H 'Accept: application/json' | python3 -m json.tool

# Upload a file with multipart form data
curl -X POST https://api.example.com/upload \
  -F 'file=@document.pdf' \
  -F 'description=Q1 report'

# Follow redirects and save cookies
curl -L -c cookies.txt -b cookies.txt https://example.com/login
§05

Related on TokRepo

§06

Common pitfalls

  • Forgetting -L to follow redirects. Many URLs return 301/302 redirects, and without -L curl stops at the redirect response.
  • Not quoting URLs with special characters. Ampersands, brackets, and query strings need proper quoting or escaping in shell environments.
  • Using -k to skip certificate verification in production scripts. This disables TLS security and should only be used for local development.

Frequently Asked Questions

What is the difference between curl and wget?+

curl supports more protocols (25+ vs wget's HTTP/HTTPS/FTP), outputs to stdout by default (pipe-friendly), and has extensive API via libcurl. wget is better for recursive downloads and mirroring websites. curl is the standard for API interaction; wget is the standard for bulk downloads.

How do I send POST data with curl?+

Use -X POST with -d for form data or -d with -H 'Content-Type: application/json' for JSON. For file uploads, use -F for multipart form data. Example: curl -X POST -d '{"key":"value"}' -H 'Content-Type: application/json' https://api.example.com/endpoint.

Does curl support HTTP/2 and HTTP/3?+

Yes. curl supports HTTP/2 when built with nghttp2, and HTTP/3 when built with ngtcp2 and nghttp3. Use --http2 or --http3 flags to force a specific version. Most modern curl builds include HTTP/2 support by default.

How do I debug curl requests?+

Use -v (verbose) to see the full request and response headers, TLS handshake details, and connection info. Use --trace or --trace-ascii for even more detail including raw bytes sent and received. Use -w to format specific timing metrics.

Can curl handle authentication?+

Yes. curl supports Basic auth (-u user:pass), Bearer tokens (-H 'Authorization: Bearer token'), digest auth (--digest), NTLM (--ntlm), and client certificates (--cert). It also handles cookies for session-based auth with -c and -b flags.

Citations (3)
  • curl GitHub— curl supports HTTP, HTTPS, FTP, SFTP and 25+ protocols
  • curl Users— libcurl is used in billions of installations worldwide
  • curl HTTP/3 Docs— curl supports HTTP/2 and HTTP/3

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets