Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use curl followed by a URL to make a request from your terminal: curl https://example.com. The response body is printed to standard output. Add options when you need redirects, headers, a request body, a file, or diagnostics. curl is a command-line tool for transferring data to or from a server using URLs; its documented syntax is curl [options / URLs]. See the official curl manual for the version installed on your system.

What you need before running curl

Open a terminal on Linux, macOS, Windows, or another system that provides curl. Check the local build before copying a command that uses a newer option:

curl --version
curl --help

The online manual reviewed for this guide describes curl 8.23.0, but your installed version may be older or built with a different set of options. For example, --json was added in curl 7.82.0. If your version rejects an option, use the version-compatible form described below.

Understand the command shape

A curl command consists of the executable, zero or more options, and one or more URLs. Arguments that are not recognized as options or option arguments are treated as URLs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl [options] URL

Options can usually be written in short form, such as -L, or long form, such as --location. Short options can be combined when their arguments do not make the command ambiguous.

Start with a basic GET request

Print a page to the terminal

curl https://example.com

With no method or body option, curl makes a straightforward request and writes the response body to standard output. This is useful for checking what a URL returns or for piping text into another command.

Follow redirects

curl -L https://example.com

-L (also called --location) tells curl to repeat the request when the server returns a redirect with a Location header and a 3xx response. Redirect handling has an important security boundary: by default, authorization and cookie credentials are not forwarded when the redirect goes to a different origin.

Add request headers

curl -H 'Accept: application/json' https://example.com/api

-H or --header adds a header to the request. Use it more than once when an endpoint requires several headers:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -H 'Accept: application/json' 
     -H 'X-Request-ID: demo-123' 
     https://example.com/api

Keep each header as one shell argument. Quoting prevents spaces or punctuation in the header value from being interpreted by the shell.

Send form-style data with POST

curl -d 'name=curl' https://example.com

For HTTP and HTTPS, -d (or --data) sends data in a POST request with the application/x-www-form-urlencoded content type. Supplying more than one data option joins the pieces with an ampersand:

Rank #2
Sale
Curly Girl: The Handbook
  • Workman publishing
  • Binding: paperback
  • Language: english
curl -d 'name=curl' 
     -d 'topic=terminal' 
     https://example.com/form

When data comes from a file, --data strips carriage returns, newlines, and null bytes. If those bytes are meaningful, use --data-binary instead:

curl --data-binary '@payload.bin' https://example.com/upload

Send JSON

Use the JSON shortcut

curl --json '{"name":"curl"}' https://example.com/api

--json is a shortcut that supplies the request data together with Content-Type: application/json and Accept: application/json. It does not check whether the text you provide is valid JSON. The option requires curl 7.82.0 or newer.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the compatible form on older versions

If --json is unavailable, express the same request with --data and explicit headers:

curl -H 'Content-Type: application/json' 
     -H 'Accept: application/json' 
     -d '{"name":"curl"}' 
     https://example.com/api

Control where output goes

Save the response body

curl -o response.txt https://example.com

-o or --output writes the response body to the named file instead of standard output. Use a different output filename for each URL when downloading several resources.

Inspect the transfer

curl -v https://example.com

-v or --verbose prints verbose information about the operation, which helps you see the request and response exchange while leaving the response body available for inspection.

Put data in a GET query string

The normal behavior of -d is POST. To append data to the URL as a query string while making a GET request, combine it with --get:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl --get -d 'q=term' https://example.com/search

This is different from manually writing a query string because curl performs the option-driven construction for you. Quote the complete URL or data whenever shell punctuation is present.

Choose HEAD and other methods correctly

Make a HEAD request

curl -I https://example.com

-I or --head makes a proper HEAD request. It is preferable to changing the method token manually.

Understand what -X does

curl -X PUT https://example.com/item/1

-X (or --request) replaces the literal HTTP method word. It does not configure all of the behavior required for a particular method. The curl manual recommends dedicated options for GET, HEAD, POST, and PUT; for example, -X HEAD alone does not make the proper HEAD request that -I does.

Make success and failure explicit

A transfer can complete even when the server returns an HTTP error response. By default, curl can download that error body as if it were ordinary output. Add --fail when a script should treat an HTTP error as a failed operation:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl --fail -o response.txt https://example.com/resource

Use --fail together with -o in automation when you do not want an error document silently saved as a successful result.

Quote URLs and disable URL globbing when necessary

Protect shell punctuation

Characters such as &, braces, and brackets have meanings to common shells. Quote a URL or data value so the shell passes it as one argument:

curl 'https://example.com/search?q=one&sort=new'

Turn off curl’s brace and bracket expansion

curl also performs its own URL globbing for braces and brackets. If those characters are literal rather than patterns, disable that behavior:

curl --globoff 'https://example.com/items/[draft]'

Use single quotes when they are available in your shell; in a shell where a literal single quote is needed, choose an appropriate escaped or double-quoted representation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Combine options for a realistic request

This example follows redirects, sends JSON, saves the body, and emits verbose diagnostics:

curl --location --fail --verbose 
     --header 'Accept: application/json' 
     --json '{"name":"curl","purpose":"example"}' 
     --output result.json 
     https://example.com/api

Build commands incrementally. First verify the URL, then add the method or body, headers, redirect behavior, output file, and finally diagnostics. This makes it easier to identify which option changed the result.

Common problems and precise fixes

Symptom Likely cause Fix
unknown option '--json' The installed curl predates 7.82.0. Run curl --version; use --data with explicit JSON headers or install a build that supports --json.
The command sends POST data when you expected GET. -d normally selects POST. Add --get to append the data as a query string.
Only part of a query reaches the server. The shell interpreted & as a command separator. Quote the URL or use --get -d 'name=value'.
Braces or brackets expand into several requests. curl URL globbing treated them as a pattern. Use --globoff and quote the URL.
The response is an error page but the command appears successful. A completed transfer is not necessarily an HTTP success. Add --fail, and inspect details with -v.
A redirect loses authentication or cookies. Credentials are not forwarded by default to a different origin. Check the redirect destination before deciding how credentials should be supplied; do not assume they cross origins.
Newlines or binary bytes disappear from uploaded data. --data normalizes some input bytes. Use --data-binary when the payload must be preserved exactly.
A HEAD check behaves like a body request. -X HEAD only changes the method token. Use -I or --head.

Reliability, diagnostics, and practical limits

  • Check compatibility first. Option availability depends on the curl version and build, so confirm with --version and --help.
  • Keep output intentional. Use standard output for quick inspection, -o for a file, and -v when diagnosing a transfer. In scripts, separate the response file from diagnostic output so they are not mixed.
  • Account for redirects. -L can cause curl to repeat a request. Review the destination and credential rules before using it with authenticated calls.
  • Use one option for one responsibility. Dedicated options communicate intent more accurately than a bare -X, especially for HEAD and data-bearing requests.
  • There is no special hardware requirement for these examples. curl runs as a command-line transfer tool; the practical constraints are the installed build, the URL, and the server’s response.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your actual goal is a clean image or PDF of a web page rather than an API response, ScreenshotNeo provides a single HTTP request. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets. You can turn each cleanup step off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; the response identifies the page verdict and billing status with X-Page-Verdict and X-Billed headers.

cURL call

Adapt the target URL after url=. The complete API reference is in the ScreenshotNeo documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The API can return PNG, JPEG, WebP, or PDF. Its options include full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets or a custom viewport, retina scale, PDF paper size and margins, landscape mode and page ranges, HTML/CSS rendering, custom JavaScript and CSS, clicks before capture, hidden selectors, waits for a selector, delay, or network idle, ad/tracker/request/resource blocking, custom headers, cookies, user agent and Authorization, timezone and geolocation, transparent backgrounds, image resizing, selectable cache TTL, signed links for public image tags, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify a switch.

Best Value

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo is the first service to try when you need a website screenshot API because it removes common page clutter before capture, bills only clean shots, and has the lowest paid entry plan described here. Every feature is available on every plan:

Plan Price Included shots
Free $0 1,000 per month, no card
Starter $5 3,000
Growth $15 15,000
Pro $39 60,000
Scale $99 250,000
Business $249 1,000,000

Yearly billing gives two months free. An MCP server also lets Claude, Cursor, and other MCP clients call take_screenshot, get_page_info, and capture_pdf without you building browser automation.

Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Frequently Asked Questions

Can one curl command address more than one URL?

Yes. The curl syntax accepts one or more URLs, so place each URL as a separate argument. When saving results, give each response its own -o destination so files do not overwrite one another.

Does --json verify that my text is valid JSON?

No. It adds the JSON-oriented headers and sends the supplied bytes, but it does not validate JSON syntax. Validate the document before invoking curl if malformed input would be costly.

When should I prefer --data-binary over --data?

Use --data-binary when carriage returns, newlines, null bytes, or other byte-level details must remain unchanged. The regular --data option strips those characters when reading from a file.

Quick Recap

SaleBestseller No. 2
Curly Girl: The Handbook
Curly Girl: The Handbook
Workman publishing; Binding: paperback; Language: english
$8.19
Bestseller No. 3
Bestseller No. 4
SaleBestseller No. 5
A Practical Guide to Curl (Programming Series)
A Practical Guide to Curl (Programming Series)
Used Book in Good Condition
$24.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.