curl Transfer data to or from a URL
Sends a request to a URL and prints the response. It speaks HTTP, HTTPS, FTP and many other protocols. Use it to download files, check a web server, or call an API from the terminal.
Synopsis
curl [OPTION]... URL...
Common options
| Option or form | What it does |
|---|---|
-O | Save the download using the file name from the URL, in the current folder |
-o FILE | Save the response to FILE instead of printing it to the terminal |
-L | Follow redirects. Without it curl stops at the first 301 or 302 response |
-I | Fetch only the response headers (sends a HEAD request) |
-s, -S | -s is silent mode: no progress meter and no error messages. Add -S to show errors again, so -sS is quiet but not blind |
-H HEADER | Add a request header, for example -H "Accept: application/json". Repeat it for more headers |
-d DATA | Send DATA as the request body. This makes curl use POST unless you pick another method |
-X METHOD | Set the request method, such as PUT or DELETE |
-f | Fail quietly on HTTP errors (400 and above): print no body and exit with code 22 |
Examples
curl https://example.com
curl -O https://example.com/files/report.pdf
curl -L -o latest.tar.gz https://example.com/download/latest
curl -I https://example.com
curl -fsSL -o install.sh https://example.com/install.sh
curl -X POST -H "Content-Type: application/json" -d '{"name":"ana"}' https://example.com/api/users
Notes
- By default curl prints the response to the terminal, not to a file. Use -o or -O to save it, or a binary file can flood your screen.
- curl does not follow redirects unless you add -L. A download that saves a tiny HTML page is often an unfollowed redirect.
- A 404 or 500 is not a curl failure. curl prints the error page and exits 0 unless you add -f. Scripts should use -f (usually as -fsSL) and check the exit code.
- -d implies POST and sets Content-Type to application/x-www-form-urlencoded. For JSON, add -H "Content-Type: application/json". You rarely need -X POST alongside -d.
- Do not pipe an unknown URL straight into a shell (curl ... | sh). Download the script, read it, then run it.
- macOS ships curl by default and wget is not installed. The options above work the same on macOS and Linux.
See also
Last reviewed 2026-10-07.