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.
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.
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.
How to use
- Make a basic GET request:
curl https://api.github.com/users/octocat
- POST JSON data:
curl -X POST https://httpbin.org/post \
-H 'Content-Type: application/json' \
-d '{"name": "test", "value": 42}'
- Download a file with progress:
curl -L -O https://example.com/file.tar.gz
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
Related on TokRepo
- AI tools for API — API development and testing tools
- AI tools for automation — Command-line automation tools
Common pitfalls
- Forgetting
-Lto follow redirects. Many URLs return 301/302 redirects, and without-Lcurl 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
-kto skip certificate verification in production scripts. This disables TLS security and should only be used for local development.
Frequently Asked Questions
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.
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.
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.
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.
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
Related on TokRepo
Discussion
Related Assets
HumHub — Open-Source Enterprise Social Network
A flexible, open-source social networking platform built on Yii2 for creating private communities, intranets, and collaboration spaces within organizations.
Dolibarr — Open-Source ERP & CRM for Business Management
A modular open-source ERP and CRM application written in PHP for managing contacts, invoices, orders, inventory, accounting, and more from a single web interface.
PrestaShop — Open-Source PHP E-Commerce Platform
A widely adopted open-source e-commerce platform written in PHP with a rich module marketplace, multi-language support, and a strong European user base.