A user agent is the software that acts on behalf of a user when accessing the web, most often a browser, but also crawlers, command-line clients, feed readers and assistive tools. Among browser technologies, the term has two closely related meanings: the client program itself and the user-agent string, the text identifier that the program sends to servers in the User-Agent HTTP request header.
Web standards use the term deliberately. HTML and CSS specifications describe what a conforming user agent must do, which places responsibility for parsing, rendering and security on the client. Servers, analytics tools and scripts read the identifier to adapt responses, collect statistics and detect automated traffic, although modern practice discourages relying on it.
How the user-agent string is built and sent
Every HTTP request from a typical client carries a User-Agent header, defined in the HTTP semantics specification as a list of product tokens with optional comments. A browser string usually contains a legacy Mozilla/5.0 prefix, platform details in parentheses, the rendering engine token and the browser name with its version.
The odd structure is historical baggage. Early servers sent advanced pages only to clients that claimed to be Mozilla, so competitors copied the token, and later browsers appended like Gecko or Safari for the same reason. The table breaks down a representative desktop string.
| Component | Example value | What it signals |
|---|---|---|
| Compatibility prefix | Mozilla/5.0 | Legacy token kept for old server checks |
| Platform comment | (Windows NT 10.0; Win64; x64) | Operating system and architecture |
| Engine token | AppleWebKit/537.36 (KHTML, like Gecko) | Rendering engine family |
| Browser token | Chrome/131.0.0.0 | Browser name and major version |
| Trailing token | Safari/537.36 | Further compatibility claim |
Scripts can read the same value through navigator.userAgent. Because both the header and the property are controlled entirely by the client, any program can send any string, which is why the value is a hint rather than proof of identity.
Kinds of user agents on the web
Browsers produce most human traffic, but a large share of requests comes from non-browser user agents. Recognizing the category helps when reading server logs and configuring access rules.
| Category | Examples of behavior | Identifies itself by |
|---|---|---|
| Desktop and mobile browsers | Render pages, run JavaScript, store cookies | Engine and browser tokens |
| Search engine crawlers | Fetch and index pages at scale | Bot name and verification address |
| HTTP libraries and CLI tools | Fetch resources without rendering | Library name and version |
| Headless browsers | Automated testing and scraping | Often a modified browser token |
| Assistive technology hosts | Expose content to screen readers | Usually the underlying browser |
| Embedded webviews | Show web content inside native apps | Browser token plus app marker |
Legitimate crawlers can usually be verified through reverse DNS lookup of the requesting address, because the user-agent string alone is trivially copied by scrapers that impersonate well-known bots.
User-agent reduction and client hints
Detailed strings expose information that helps passive fingerprinting, the tracking of users without cookies by combining many small signals. Chromium-based browsers therefore froze and reduced the string: minor version numbers, detailed operating system versions and device models are replaced by fixed placeholder values.
The replacement mechanism is User-Agent Client Hints. The browser sends a small set of low-entropy headers by default, such as Sec-CH-UA and Sec-CH-UA-Mobile, and a server must explicitly request high-entropy hints like the full version or device model with the Accept-CH response header. Gecko-based and WebKit-based browsers apply their own forms of reduction and have not adopted every client hint.
| Aspect | User-agent string | Client hints |
|---|---|---|
| Delivery | Sent on every request | Low-entropy by default, rest on request |
| Format | One free-form text value | Structured header fields |
| Privacy impact | Exposes details passively | Detailed data only when asked |
| Script access | navigator.userAgent | navigator.userAgentData |
| Engine support | Universal | Mainly Chromium-based browsers |
Sniffing versus feature detection
User-agent sniffing means choosing behavior by parsing the identifier. It is fragile because strings change with every release, browsers impersonate one another and new browsers inherit wrong assumptions. The recommended alternative is feature detection: testing whether an API or CSS feature exists before using it, often combined with a polyfill.
| Situation | Recommended approach | Reason |
|---|---|---|
| Using a new JavaScript API | Feature detection | Tests real capability, not a claim |
| Serving responsive layouts | CSS media queries | Adapts to screen, not device name |
| Traffic statistics | Parse the string or hints | Aggregate trends tolerate errors |
| Working around a known engine bug | Narrow, documented sniffing | No feature test can detect the bug |
| Blocking abusive bots | Combine with rate limits and verification | Strings are easily forged |
When a server varies its response by user agent, it should send a Vary: User-Agent header so that shared caches do not serve the wrong variant. This header greatly fragments cache keys, which is another reason to avoid server-side sniffing where possible.
Pitfalls and misconceptions
- Treating the string as authentication: any client can send any value, so it must never grant access.
- Assuming one string per device: the same phone produces different values in a browser, a webview and an app.
- Parsing with brittle patterns: a check for
Chromealso matches Edge, Opera and many other Chromium browsers. - Ignoring reduced values: frozen version numbers make fine-grained version targeting unreliable.
Changing the identifier in browser developer tools is useful for testing mobile layouts and server branches, but it does not emulate the engine itself. A desktop browser that claims to be a phone still renders with its own engine and supports its own feature set.
Explained without jargon
When your browser asks a website for a page, it introduces itself with a short note that says roughly which program it is and which system it runs on. That program is the user agent, and the note is the user-agent string. Think of it as a name badge that the visitor writes for itself.
Websites read the badge to count visitors or adjust a page, but because anyone can write any badge, it is a hint, not a proof. Modern browsers now share fewer details on that badge to protect privacy.
A typical use case
An online shop notices a sudden rise in traffic to its product search pages, all from requests whose user-agent string claims to be a major search engine crawler. Server load climbs and search results slow down for real customers.
The operations team performs a reverse DNS check on the requesting addresses and finds that most of them do not belong to the search engine at all. They add a rule that verifies crawler claims before granting higher rate limits and keeps strict limits for unverified clients, regardless of the identifier they send.
At the same time, the developers remove an old script that redirected visitors to a mobile site by searching the string for the word Mobile. They replace it with responsive CSS and feature detection, which ends complaints from tablet users who had been sent to the wrong version.