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

Use cURL’s -A or --user-agent option to send a custom HTTP User-Agent value. For example, curl -A "MyApp/1.0" https://example.com identifies the request as MyApp/1.0. The option changes request metadata; it does not turn cURL into a web browser.

The cURL options you need

The dedicated option is -A, with --user-agent as its long form. Both set the User-Agent string sent to an HTTP server.

Purpose Command form What it does
Set a value -A "MyApp/1.0" Sends MyApp/1.0 as the User-Agent.
Set a value with the long option --user-agent "My App/1.0" The readable equivalent of -A; quote values containing spaces.
Set the header generically -H "User-Agent: MyApp/1.0" Sets the same HTTP header through cURL’s general header option.
Remove the header --user-agent "" Disables cURL’s User-Agent header for the request.
Send a blank value --user-agent " " Sends a User-Agent header whose value is one space; this is different from removing it.

If an option appears more than once, the last User-Agent value supplied is the one cURL uses.

Set a User-Agent in a cURL command

Use a descriptive application identifier

A maintainable User-Agent normally identifies your application and, when useful, its version:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -A "MyApp/1.0" https://example.com

The long form is equivalent:

curl --user-agent "My App/1.0" https://example.com

Shell quoting matters. Put the value in single or double quotes when it contains spaces, parentheses, semicolons, or other shell punctuation. Without an explicit value, the cURL command-line tool sends a default in the form curl/VERSION; the current man-page example shows curl/8.23.0. A custom value replaces that default.

Set the header with -H

You can express the same request with general header syntax:

curl -H "User-Agent: MyApp/1.0" https://example.com

Use -A when you are specifically controlling the User-Agent: it communicates intent and avoids manually writing the header name. Use -H when you are already assembling several headers in one place.

Remove or blank the User-Agent

To stop cURL from sending a User-Agent header, pass an empty string:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl --user-agent "" https://example.com

That is not the same as passing one space:

curl --user-agent " " https://example.com

The first command removes the option’s header. The second deliberately sends a header with a blank-looking value. Choose the first behavior when a server or test requires no User-Agent field; choose the second only when you specifically need a present-but-empty value.

Control precedence when scripts add options

When a command contains multiple -A or --user-agent options, cURL uses the last one. This makes a later command-line setting an effective override for a value added by a shared script fragment:

curl -A "OldClient/1.0" --user-agent "NewClient/2.0" https://example.com

The request uses NewClient/2.0. Keep one authoritative setting in production commands when possible so that the identity is easy to audit.

What a User-Agent can—and cannot—do

Use browser-style values only for a clear reason

cURL’s tutorial demonstrates a browser-style value such as Mozilla/3.0 (Win95; I). You can supply a similar string:

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.
curl -A 'Mozilla/3.0 (Win95; I)' https://example.com

This changes the identifying string that the server receives. It does not add a browser’s JavaScript engine, cookie handling, layout engine, TLS behavior, or other capabilities. A site may still serve different content, require JavaScript, or reject the request for reasons unrelated to the text of the User-Agent.

For software that is making an automated request, a descriptive identifier such as InventorySync/2.4 is easier to maintain than pretending to be a particular browser. Follow the destination site’s terms, robots policy, rate limits, and access rules; changing an identifying header is not permission to bypass controls.

Proxy requests and the User-Agent header

-A controls the User-Agent sent to the HTTP server. If you need to control headers addressed to an HTTP proxy instead, cURL provides --proxy-header. Keep the two destinations separate in your design: an origin-server header and a proxy header are not interchangeable.

Set the User-Agent from code

C with libcurl

In libcurl, set the option on an easy handle with CURLOPT_USERAGENT:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (!curl) return 1;

    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    curl_easy_setopt(curl, CURLOPT_USERAGENT, "MyApp/1.0");
    CURLcode result = curl_easy_perform(curl);

    curl_easy_cleanup(curl);
    return result == CURLE_OK ? 0 : 1;
}

The API reference defines the string as the User-Agent header for HTTP requests. A later setting overrides an earlier one; passing NULL disables the option. CURLOPT_USERAGENT has been available since curl 7.1. The command-line -A option and this libcurl setting are separate interfaces, so use the one that matches your integration.

Python with Requests

Python’s HTTP libraries generally expose headers as a mapping. This complete example sends the same metadata:

import requests

url = "https://example.com"
headers = {"User-Agent": "MyApp/1.0"}
response = requests.get(url, headers=headers, timeout=30)
response.raise_for_status()
print(response.status_code)

To remove the header, omit it from the mapping rather than supplying an empty-looking value. Whether a library adds its own default headers is library-specific, so inspect the actual outgoing request when exact wire behavior matters.

Node.js with the built-in Fetch API

In a current Node.js release with fetch, put the header in the request options:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const response = await fetch('https://example.com', {
  headers: { 'User-Agent': 'MyApp/1.0' }
});

if (!response.ok) {
  throw new Error(`HTTP ${response.status}`);
}

console.log(await response.text());

As with Python, removing your explicit header does not necessarily mean that the runtime sends no User-Agent at all; a client library may provide a default. Test the behavior of the exact runtime and version you deploy.

Choosing between the three cURL approaches

Approach Best fit Important detail
-A / --user-agent Normal cURL commands and scripts Purpose-built, concise, and supports explicit removal with an empty value.
-H "User-Agent: ..." Commands that centralize all HTTP headers Uses general header syntax; you manage the header name yourself.
CURLOPT_USERAGENT Applications embedding libcurl Set it on each relevant easy handle; later settings replace earlier ones.

The cURL project records --user-agent/-A as introduced in curl 4.5.1. That history does not change the syntax used by current cURL versions.

Troubleshooting common User-Agent problems

The value is cut off or the shell reports a syntax error

Cause: the value contains spaces or shell metacharacters and was not quoted.

Fix: wrap the complete value in single or double quotes, for example --user-agent "My App/1.0". If the value itself contains a quote, choose the other quote style or escape the character according to your shell.

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

The request still identifies as the old client

Cause: another User-Agent option appears later in the command or in a wrapper script.

Rank #4
Sale
Haofy Legal Pads A4 Size, 4 Pack Colored Notepads (4pcs 21.4x29.6cm 50
  • Sturdy Backing Support: Place on lap or outdoor bench without curling, stiff cover prevents page flapping in breeze, maintains flat writing surface for park sketching and commute journaling.
  • Red Margin Guidance: Left column reserved for annotations or page numbers, right space holds 27 clean lines, reduces eye strain during lengthy study sessions and project brainstorming.
  • Tear-Off Top Binding: Remove sheets cleanly along score lines, no loose fragments or damaged corners, paper accepts pencil and rollerball ink evenly for daily schedules.
  • Designated Header Zone: Top section marked for date and subject, color-coded covers help separate courses or clients, simplifies folder organization after semester ends.
  • Multi-Purpose 4-Pack: Four vibrant notepads for dorm desks, office cubicles, or home command centers, 200 total sheets support semester-long note-taking without restock.

Fix: search the assembled command for every -A, --user-agent, and -H "User-Agent: ...". The last dedicated User-Agent option wins; remove the unintended override.

The server sees a blank value when you wanted no header

Cause: the command used one space rather than an empty string.

Fix: use --user-agent "" for removal. Reserve --user-agent " " for tests that require a present header with a one-space value.

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

A site still rejects the request after you copied a browser string

Cause: User-Agent is only request metadata. It does not supply browser capabilities, and a destination may apply other access checks.

Fix: use an honest application identifier, check the site’s access requirements, and determine whether the workflow actually needs a browser automation tool rather than cURL. Do not assume that changing the string bypasses a bot check or other restriction.

The origin works but the proxy behaves differently

Cause: the header needed by the proxy was configured as an origin-server header.

Fix: configure proxy-directed headers with --proxy-header, while keeping the origin User-Agent under -A or -H.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and cost considerations

Setting a User-Agent is a local option that changes the request header; it does not add a separate network round trip or a paid service. The main reliability concern is accuracy: a misleading browser claim can produce content or access behavior that your client cannot actually handle. A versioned application identifier makes logs and support investigations easier, while an empty or blank value should be used only when your protocol test calls for it.

For repeatable jobs, keep the value in one configuration variable and apply it consistently across command-line, Python, Node.js, or libcurl implementations. Document whether the requirement is “no header,” “blank header,” or a particular identifier—those are different wire-level requests.

Or skip the browser setup

If your end goal is a clean screenshot of a web page rather than an HTTP response, changing cURL’s User-Agent is not a substitute for page rendering. ScreenshotNeo is a website screenshot API and MCP server that can load the page and return a PNG, JPEG, WebP, or PDF.

Its capture flow accepts cookie and consent banners before taking the shot, then 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. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

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.

One request is enough:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for parameters and response details. The service supports full-page and element captures, device presets or custom viewports, dark mode, retina scale, PDF page settings, custom CSS and JavaScript, clicks, waits, blocked resources, cookies, headers, authorization, geolocation, caching, signed image links, asynchronous webhooks, bulk capture, and a usage API. Those options are useful when a raw cURL request cannot execute the page’s browser-side behavior.

There is a free allowance of 1,000 screenshots per month with no card required. Paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account to try the capture API.

Bottom line

Use -A or --user-agent for a clear, versioned identifier, quote values that contain spaces, and remember that the last setting wins. Use an empty value to remove the header, a one-space value to send a blank header, --proxy-header for proxy-directed metadata, and CURLOPT_USERAGENT when embedding libcurl. A User-Agent changes identification only; it does not create browser functionality.

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.