cURL User Agents: Set, Rotate & Test Compatibility


Nathan Reynolds
Bypass Methods
cURL is one of those tools that quietly runs the internet. If you're testing an API, debugging a redirect, or verifying how a server responds to different clients, cURL gives you a fast, scriptable way to inspect exactly what goes over the wire. One header you'll touch constantly during that work is the User-Agent, and knowing how to set it correctly makes your requests behave the way real clients do.
This guide covers the fundamentals of cURL, how User-Agent strings are structured, how to override them per request, and how to save a sensible default. The focus throughout is legitimate work: API and integration testing, cross-browser compatibility checks, and collecting publicly available data in line with each site's terms.
What cURL Is and Why the User-Agent Matters
cURL (short for "Client URL") is a command-line tool for transferring data over HTTP, HTTPS, FTP, and a long list of other protocols. Developers and system administrators lean on it for quick checks against web services, file transfers, and general network debugging. You can read more about the project at the official curl homepage.
Because cURL speaks standard protocols, every HTTP(S) request it sends carries a set of headers alongside the request itself. Those headers are metadata that help the server decide how to respond. The User-Agent header is one of the most visible: it tells the server what kind of client is making the request — operating system, browser family, and version hints.
Originally, the User-Agent existed so servers could tailor content to a client's capabilities. It's still used that way, and it's also part of analytics and session tracking. For your purposes, the practical takeaway is simpler: some servers return different content (or reject requests) depending on the User-Agent, so when you're testing behaviour or collecting public data, setting a realistic value keeps your results consistent with what a normal browser would see. For a curated list of common values, see our reference on User-Agent strings for web scraping.
cURL Basics: Requests, Redirects, and Headers
Good news: cURL ships pre-installed on most modern operating systems, including Windows 10+, macOS, and many Linux distributions. You can call it straight from Terminal or Command Prompt.
By default, cURL performs a GET request. To fetch a page, type curl followed by the URL:
curlThis prints the raw HTML of the page to your console, which can look messy on first sight — that's expected.
cURL follows the exact URL you give it. If the server responds with a redirect (an HTTP 3xx pointing elsewhere), cURL won't follow it automatically; you'll just see a notice that the resource has moved. To follow redirects, add the -L flag:
curl -LWithout -L, requesting https://www.example.com may return only the redirect notice rather than the final page.
You can also add custom headers with the -H flag, followed by the header string:
curl \
-L \
-H "X-Custom-Header: SomeValue"
cURL's options are order-independent, so these two commands do exactly the same thing:
curl -L -H "X-Custom-Header: SomeValue" https://api.example.com
curl -H "X-Custom-Header: SomeValue" -L
Anatomy of a User-Agent String
A User-Agent string is a text label sent with your request that describes the client software. Servers read it to decide, among other things, which version of a page or asset to serve. Here's a typical example:
The format looks cryptic because it's the product of decades of browser history. The header itself is defined in RFC 7231, and there's a good background summary on Wikipedia's User agent page. Breaking down the example above:
Mozilla/5.0: A largely historical token dating to the Netscape era, kept for compatibility with older servers that expect it.(X11; Linux x86_64): Platform details — the X Window System, a Linux OS, and a 64-bit architecture.AppleWebKit/537.36: The layout engine, WebKit (used by Safari and, historically, Chrome), at version 537.36.(KHTML, like Gecko): Another compatibility token. KHTML powered Konqueror, and "like Gecko" signals compatibility with Firefox's engine.Chrome/108.0.0.0: The browser and its version number.Safari/537.36: Because Chrome's engine descends from Safari's, this token is included for compatibility checks.
Setting a Custom User-Agent in cURL
Use the -A (or --user-agent) option to send a specific User-Agent with your request:
curl \
-A "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
cURL doesn't validate the string, so you can technically set it to anything. In practice, use a real, current browser value. A nonsensical string can trigger errors, and an unusually unique one makes your client stand out — the opposite of what you want when you're trying to reproduce genuine browser behaviour.
This matters for realistic testing: browser fingerprinting techniques treat the User-Agent as one signal among many. If you're checking how your own site renders for different clients, a common, well-formed string gives you results that match what real visitors experience. For more on how these signals fit together, see our deep dive on browser fingerprinting.
Rotating User Agents for Compatibility Testing
When you're verifying that a page serves the right content across devices, or collecting public data at scale in line with a site's terms, cycling through a set of realistic User-Agents is a common approach. It lets you confirm that mobile and desktop clients receive appropriate responses, and it spreads requests across values that reflect the actual browser mix of your audience.
Keep the values current — browser versions move quickly, and a Chrome 90 string sent in 2025 looks obviously stale. Pair this with clean, consistent connections for reliable results. If you route requests through ethically sourced residential proxies, you can confirm how a page behaves from different regions during QA and public-data collection. For a broader look at scaling this responsibly, our guide on rotating proxy networks walks through the mechanics.
Configuring a Default User-Agent for cURL
If you use the same User-Agent across many commands, set a default so you don't retype the -A option every time. Create or edit a config file named _curlrc (Windows) or .curlrc (Unix-like systems, including macOS and Linux).
Windows: create or edit
C:\Users\<YourUsername>\_curlrc.Unix-like systems (Linux, macOS): create or edit
~/.curlrcin your home directory.
If the file doesn't exist, make it with any plain text editor, then add one line, replacing the placeholder with your chosen value:
user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"Save the file. To confirm cURL is using your default, run a request with the verbose flag (-v). Evomi's IP checker is a handy target because it echoes the headers it received:
curl -vThe output is detailed. Near the top, look for lines that start with > — those are the request headers cURL sent. You should see the User-Agent: line reflecting the value from your config file.
Wrapping Up
Setting the User-Agent in cURL is a small change with an outsized effect on how servers respond to you. Whether you're debugging an API, running cross-browser QA, or collecting public data within a site's terms, a realistic, current User-Agent keeps your results honest and reproducible. Combine that with clean connections and sensible request pacing, and cURL becomes a dependable part of your testing toolkit.
cURL is one of those tools that quietly runs the internet. If you're testing an API, debugging a redirect, or verifying how a server responds to different clients, cURL gives you a fast, scriptable way to inspect exactly what goes over the wire. One header you'll touch constantly during that work is the User-Agent, and knowing how to set it correctly makes your requests behave the way real clients do.
This guide covers the fundamentals of cURL, how User-Agent strings are structured, how to override them per request, and how to save a sensible default. The focus throughout is legitimate work: API and integration testing, cross-browser compatibility checks, and collecting publicly available data in line with each site's terms.
What cURL Is and Why the User-Agent Matters
cURL (short for "Client URL") is a command-line tool for transferring data over HTTP, HTTPS, FTP, and a long list of other protocols. Developers and system administrators lean on it for quick checks against web services, file transfers, and general network debugging. You can read more about the project at the official curl homepage.
Because cURL speaks standard protocols, every HTTP(S) request it sends carries a set of headers alongside the request itself. Those headers are metadata that help the server decide how to respond. The User-Agent header is one of the most visible: it tells the server what kind of client is making the request — operating system, browser family, and version hints.
Originally, the User-Agent existed so servers could tailor content to a client's capabilities. It's still used that way, and it's also part of analytics and session tracking. For your purposes, the practical takeaway is simpler: some servers return different content (or reject requests) depending on the User-Agent, so when you're testing behaviour or collecting public data, setting a realistic value keeps your results consistent with what a normal browser would see. For a curated list of common values, see our reference on User-Agent strings for web scraping.
cURL Basics: Requests, Redirects, and Headers
Good news: cURL ships pre-installed on most modern operating systems, including Windows 10+, macOS, and many Linux distributions. You can call it straight from Terminal or Command Prompt.
By default, cURL performs a GET request. To fetch a page, type curl followed by the URL:
curlThis prints the raw HTML of the page to your console, which can look messy on first sight — that's expected.
cURL follows the exact URL you give it. If the server responds with a redirect (an HTTP 3xx pointing elsewhere), cURL won't follow it automatically; you'll just see a notice that the resource has moved. To follow redirects, add the -L flag:
curl -LWithout -L, requesting https://www.example.com may return only the redirect notice rather than the final page.
You can also add custom headers with the -H flag, followed by the header string:
curl \
-L \
-H "X-Custom-Header: SomeValue"
cURL's options are order-independent, so these two commands do exactly the same thing:
curl -L -H "X-Custom-Header: SomeValue" https://api.example.com
curl -H "X-Custom-Header: SomeValue" -L
Anatomy of a User-Agent String
A User-Agent string is a text label sent with your request that describes the client software. Servers read it to decide, among other things, which version of a page or asset to serve. Here's a typical example:
The format looks cryptic because it's the product of decades of browser history. The header itself is defined in RFC 7231, and there's a good background summary on Wikipedia's User agent page. Breaking down the example above:
Mozilla/5.0: A largely historical token dating to the Netscape era, kept for compatibility with older servers that expect it.(X11; Linux x86_64): Platform details — the X Window System, a Linux OS, and a 64-bit architecture.AppleWebKit/537.36: The layout engine, WebKit (used by Safari and, historically, Chrome), at version 537.36.(KHTML, like Gecko): Another compatibility token. KHTML powered Konqueror, and "like Gecko" signals compatibility with Firefox's engine.Chrome/108.0.0.0: The browser and its version number.Safari/537.36: Because Chrome's engine descends from Safari's, this token is included for compatibility checks.
Setting a Custom User-Agent in cURL
Use the -A (or --user-agent) option to send a specific User-Agent with your request:
curl \
-A "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
cURL doesn't validate the string, so you can technically set it to anything. In practice, use a real, current browser value. A nonsensical string can trigger errors, and an unusually unique one makes your client stand out — the opposite of what you want when you're trying to reproduce genuine browser behaviour.
This matters for realistic testing: browser fingerprinting techniques treat the User-Agent as one signal among many. If you're checking how your own site renders for different clients, a common, well-formed string gives you results that match what real visitors experience. For more on how these signals fit together, see our deep dive on browser fingerprinting.
Rotating User Agents for Compatibility Testing
When you're verifying that a page serves the right content across devices, or collecting public data at scale in line with a site's terms, cycling through a set of realistic User-Agents is a common approach. It lets you confirm that mobile and desktop clients receive appropriate responses, and it spreads requests across values that reflect the actual browser mix of your audience.
Keep the values current — browser versions move quickly, and a Chrome 90 string sent in 2025 looks obviously stale. Pair this with clean, consistent connections for reliable results. If you route requests through ethically sourced residential proxies, you can confirm how a page behaves from different regions during QA and public-data collection. For a broader look at scaling this responsibly, our guide on rotating proxy networks walks through the mechanics.
Configuring a Default User-Agent for cURL
If you use the same User-Agent across many commands, set a default so you don't retype the -A option every time. Create or edit a config file named _curlrc (Windows) or .curlrc (Unix-like systems, including macOS and Linux).
Windows: create or edit
C:\Users\<YourUsername>\_curlrc.Unix-like systems (Linux, macOS): create or edit
~/.curlrcin your home directory.
If the file doesn't exist, make it with any plain text editor, then add one line, replacing the placeholder with your chosen value:
user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"Save the file. To confirm cURL is using your default, run a request with the verbose flag (-v). Evomi's IP checker is a handy target because it echoes the headers it received:
curl -vThe output is detailed. Near the top, look for lines that start with > — those are the request headers cURL sent. You should see the User-Agent: line reflecting the value from your config file.
Wrapping Up
Setting the User-Agent in cURL is a small change with an outsized effect on how servers respond to you. Whether you're debugging an API, running cross-browser QA, or collecting public data within a site's terms, a realistic, current User-Agent keeps your results honest and reproducible. Combine that with clean connections and sensible request pacing, and cURL becomes a dependable part of your testing toolkit.

Author
Nathan Reynolds
Web Scraping & Automation Specialist
About Author
Nathan specializes in web scraping techniques, automation tools, and data-driven decision-making. He helps businesses extract valuable insights from the web using ethical and efficient scraping methods powered by advanced proxies. His expertise covers overcoming anti-bot mechanisms, optimizing proxy rotation, and ensuring compliance with data privacy regulations.



