How to Configure Curl to Output to Stdout

This article explains how to configure the curl command-line tool to write its retrieved data directly to standard output (stdout). While curl prints to stdout by default, you will learn how to explicitly force this behavior using command-line flags, suppress unwanted progress bars, and pipe the output to other utilities for seamless command-line workflows.

Default Behavior of Curl

By default, when you run a basic curl command followed by a URL, the tool automatically writes the downloaded content directly to stdout.

curl https://example.com

Running this command will display the HTML or API response directly in your terminal window.

Forcing Output to Stdout with -o -

In some scenarios—such as when using shell scripts or when you want to be explicit—you can force curl to write to stdout using the -o (or --output) option followed by a hyphen (-). In command-line conventions, the hyphen represents standard output.

curl -o - https://example.com

This command behaves exactly like the default execution but guarantees that the output stream is directed to stdout regardless of any alias configurations or script wrappers.

Suppressing Progress Meters

When redirecting stdout or piping the output of curl to another command, curl often outputs a progress meter to standard error (stderr). To prevent this progress meter from cluttering your terminal or logs, use the -s (or --silent) flag.

curl -s https://example.com

To combine silent mode with explicit stdout direction:

curl -s -o - https://example.com

Piping Stdout to Other Commands

Directing curl output to stdout is highly useful for piping data directly into other command-line utilities for processing.

For example, to retrieve JSON data and parse it using jq:

curl -s https://api.github.com | jq .

To search for a specific keyword in the downloaded content using grep:

curl -s https://example.com | grep "Example"