curl is a small command-line tool that moves data to or from a server through a URL. People use it to download files and to check how websites and web APIs respond. This guide, written on November 30, 2026, follows the man page for curl 8.23.1 and covers the options you need for most daily work.
What it does
curl is a program that runs in the terminal, the text window where you type commands. You give it a web address, and it fetches what is stored there. It can also send data to that address, such as the content of a form.
Think of curl as a courier: you hand it one address, it goes there, and it brings back the package that waits at that address. It can also drop off a package. But it does not empty the whole building. Copying an entire website, link by link, is a job for other tools such as Wget.
A web browser also fetches pages, but then it draws them on the screen with images and buttons. curl skips that part. It shows the raw content as plain text, or saves it to a file. That makes it useful for people who test websites and online services. It also helps small automatic programs that download files without a person watching.
It also works with many other kinds of servers (computers that offer files or services over a network), such as mail and file servers.
If you only use a desktop and a browser, you can safely ignore curl. Here is the simplest possible example:
curl https://example.com
This prints the content of the page at that address in the terminal window.
Back to topHow to use it
The project documents every option on the curl website, including the full manual. The examples below use example.com as a placeholder address.
Download a file
Warning:
-Ooverwrites an existing file with the same name without asking. Check the folder first if that file matters to you.
curl -O https://example.com/filename.zip
This saves the file under its own name, filename.zip, in the current directory.
curl -o out.zip https://example.com/filename.zip
This saves the same file under a name that you choose.
curl -C - -O https://example.com/filename.zip
This resumes a download that stopped halfway, so curl does not start again from zero.
A safe default for downloads
curl -fsSL https://example.com/file
This follows redirects (-L), stays quiet (-s), still shows errors (-S), and fails on HTTP errors instead of printing an error page (-f). Add -o or -O to save the result in a file instead of printing it.
Look at headers and status codes
curl -I https://example.com
This shows only the response headers, without the page itself.
curl -L -D - https://example.com
This follows any redirects and prints the response headers first, then the page.
curl -s -o /dev/null -w '%{response_code}\n' https://example.com
This throws away the body and prints only the HTTP status code, for example 200 or 404. It is a quick way to check whether a website answers.
Send data to a server
curl -d 'name=bob' http://example.com/form
This sends form data with a POST request; -d already implies POST, so you do not need -X POST.
curl --json '{"name":"bob"}' https://example.com/api
This sends JSON and sets the matching Content-Type and Accept headers for you.
curl -H 'Authorization: Bearer token' https://example.com
This adds a custom header, here a login token for an API. Replace token with your own value.
Retry when the network is unstable
curl --retry 7 https://example.com
This tries the transfer again, up to 7 times, when a temporary error such as a timeout occurs.
Back to topHow it works
The curl project ships two products: the curl command and libcurl, a client-side transfer library. The command is a thin layer on top of libcurl, which many other programs also use. Daniel Stenberg founded the project, the name has been in use since 1998, and the license is MIT-style.
The tool is built for single transfers. The curl FAQ says plainly that it is not a Wget clone: it does not mirror sites or download recursively. Besides HTTP(S), the man page lists protocols such as FTP(S), SFTP, SCP, IMAP(S), SMTP(S), MQTT(S), LDAP(S) and WebSocket (WS, WSS).
Defaults and redirects
Received data goes to standard output (stdout) unless you use -o or -O. The progress meter stays hidden when output goes to the terminal. Several URLs are fetched one after another, unless you add --parallel. --output-dir sets the target directory, and --create-dirs creates missing local directories.
curl needs -L to follow redirects. It then follows 3XX responses with a Location header, up to 50 by default (--max-redirs changes this). After a POST, a 301, 302 or 303 switches the next request to GET, unless you add --post301, --post302 or --post303. Credentials go only to the first host, unless you use --location-trusted.
Errors and exit codes
Without -f, an HTTP error does not count as a failed transfer, so a 404 page is printed like any other body. With -f, any status of 400 or higher gives exit code 22 and no body. --fail-with-body prints the body and still returns 22.
-s hides the progress meter and error messages alike, so pair it with -S. Other exit codes worth knowing: 6 (host not resolved), 7 (connection failed), 28 (timeout), 35 (SSL connect error) and 60 (certificate not verified with known certificate authorities).
In scripts, combine -f with -sS. HTTP errors then stop the script with a clear exit code, and the message still appears.
Methods and request bodies
-X only changes the method word that curl sends, without validation. For a real HEAD request, use -I. --data-raw and --data-binary differ from -d in how they treat a leading @ and binary data. --json equals --data-binary plus JSON Content-Type and Accept headers. A leading @ reads a file, @- reads standard input, and curl does not validate the JSON.
-w prints details after the transfer through %{variable} names. %{response_code} is the current name; http_code is the older one.
Timeouts and retries
-m limits each transfer in seconds, with decimals allowed; --connect-timeout limits only the connection phase. --retry is off by default (0). It covers timeouts and HTTP 408, 429, 500, 502, 503, 504, 522 and 524. The first wait is 1 second and doubles up to 10 minutes, and a Retry-After header is honored. Partial data in an output file is removed before a retry, but data already sent to stdout stays.
Certificate checks
-k skips TLS certificate verification. The man page warns that this makes the transfer insecure, and that a malicious server could influence the HSTS and Alt-Svc data curl stores. Never use it as a fix for a certificate error.
Warning: This turns off certificate checks, so curl cannot tell whether it talks to the real server. Use it only for tests on a server you control.
curl -k https://example.com
This connects without verifying the server's certificate.
Back to topSources
- curl man page (version 8.23.1) — curl.se
- curl FAQ — curl.se
- tldr-pages: curl — GitHub (tldr-pages)
- Everything curl — everything.curl.dev
