curl (Command Line Tool) Reference

Kip Landergren

(Updated: )

My cheat sheet for curl covering common commands, documentation links, and frequently asked questions.

Contents

Commands

Note: when in doubt, read the man page—it has a wealth of information.

Non-exhaustive list of commonly used options:

--verbose -v verbose
--silent -s no progress meter or error messages
--http1.1
--http2
--http3
--insecure -k
--output -o e.g. --output /dev/null

Examples

Make a request verbosely, silently (no progress meter or error messages), and write the output (but not the

curl --verbose --silent --output /dev/null https://example.com

Make a request verbosely, ignoring insecure certificate warnings, to a custom IP address X.X.X.X for a specific host and port pair:

curl --verbose                           \
     --insecure                          \
     --resolve 'example.com:443:X.X.X.X' \
     'https://example.com'

Write headers to a file:

curl --dump-header headers.txt \
     example.com

Write headers to a file and suppress final output and progress:

curl --silent                  \
     --dump-header headers.txt \
     --output /dev/null        \
     example.com

Save a remote file locally as some-file.txt, short-form:

curl -O example.com/some-file.txt

Save a remote file locally as some-file.txt, long-form:

curl --remote-name example.com/some-file.txt

Specify headers:

curl -H 'X-Foo: A' -H 'X-Bar: B' example.com

POST with JSON data:

curl -H 'Content-Type: application/json' -X POST -d '{}' example.com

Options

--verbose
--location follow redirects
--output write output to file; use --output /dev/null to hide response contents

Documentation

FAQ

Why does curl sometimes appear to be stylized as “cURL” with capitalized “URL”?

“cURL”, with the capitalized “URL”, refers to the project, where curl refers to the command line utility and libcurl refers to the C Library.

More info available from the official FAQ question “What is cURL?”.

What do the >, <, and * mean when --verbose is used?

> header data sent by curl
< header data received by curl
* additional info provided by curl

From the man page for the --verbose option:

Makes curl verbose during the operation. Useful for debugging and seeing what's going on "under the hood". A line starting with '>' means "header data" sent by curl, '<' means "header data" received by curl that is hidden in normal cases, and a line starting with '*' means additional info provided by curl.