User-Agent

The HTTP User-Agent request header is sent by a client to inform the server which browser and operating system the client is using.

Usage

The HTTP User-Agent request header, also commonly referred to as the User-Agent String or UA-String, is used to convey information to servers about the client’s browser and operating system. This information is intended to assist in serving the representation of the resource that is best-suited to the client.

There are three directives including the product, the version, and a comment. The product is a simple identifier, and the accompanying version further specifies it. The comment is used to specify further detail such as sub-product information.

User-Agent: <product> / <version> <comment>

Note

The HTTP User-Agent header may be replaced with Client Hints.

Concerns

User-Agent strings are normally general enough to avoid identifying specific users. However, at the same time, it is important to consider that web pages are meant to be viewed properly across a large audience and a large number of devices. As such, websites are recommended to avoid over-tweaking content based on the information contained in the User-Agent string.

Example

This example is of a UA-string that has been used by the Google web crawler.

User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

Takeaway

The HTTP User-Agent header is used to provide information about the client’s browser and operating system to the server in order for the server to tailor the HTTP response accordingly.

See also

Last updated: June 2, 2022