Welcome to Developer's Home Thursday, April 17, 2014
Home - DevelopersHome.com

The User-Agent Header -- Identify a User Agent and Client Device


Preferences - Do not show ads

The User-Agent header contains a line of text that can be used to identify a user agent and client device. Most of the time, we can find the device model and manufacturer from the User-Agent header. It may also contain information such as the client device's OS version, browser version, Java capabilities, etc.

Some example User-Agent headers are provided below.


The User-Agent header of the Nokia 6230i cell phone:

Nokia6230i/2.0 (03.25) Profile/MIDP-2.0 Configuration/CLDC-1.1


The User-Agent header of the Nokia 6600 cell phone:

Nokia6600/1.0 (4.03.24) SymbianOS/6.1 Series60/2.0 Profile/MIDP-2.0 Configuration/CLDC-1.0


The User-Agent header of the Sony Ericsson T610 cell phone:

SonyEricssonT610/R501 Profile/MIDP-1.0 Configuration/CLDC-1.0


The User-Agent header of the Sony Ericsson K700i cell phone:

SonyEricssonK700i/R2AG SEMC-Browser/4.0.3 Profile/MIDP-2.0 Configuration/CLDC-1.1


The User-Agent header of Openwave Mobile Browser 6.2.2:

OPWV-SDK/62 UP.Browser/6.2.2.1.208 (GUI) MMP/2.0


One big problem of the User-Agent header is that its format is different for different manufacturers of mobile devices / cell phones. There are also variations among mobile devices / cell phones of the same manufacturer. Future device models might include a new string token in the User-Agent header or even use a completely new User-Agent header format.

Because of such problems, even though the User-Agent header may contain information about a mobile device's OS version, browser version, Java capabilities, etc, usually we do not use it for device capability detection. To detect the features and capabilities of a mobile device, the UAProf way is preferred, which will be discussed later in this tutorial.

In general, the User-Agent header is useful in the following situations:

  • When we need to identify a specific mobile device model. For example, the User-Agent header can help us determine whether a mobile device is a Nokia 6230i cell phone.

  • When we need to differentiate mobile devices or user agents made by different companies. For example, the User-Agent header can help us determine whether a cell phone is made by Nokia or Sony Ericsson.

  • When we need to determine whether a user agent is a web browser on a personal computer or a microbrowser on a mobile device.


To Identify a Specific Mobile Device Model with the User-Agent Header

In general, to identify a specific mobile device model, check whether the mobile device model name appears in the User-Agent header. For example, if the text "Nokia6230i" exists in the User-Agent header, we know that the mobile device is a Nokia 6230i cell phone; if the text "SonyEricssonK700i" exists in the User-Agent header, we know that the mobile device is a Sony Ericsson K700i cell phone.

As said earlier, each mobile device manufacturer has its own User-Agent header format. Thus, the keyword to use to identify a specific mobile device model is different for different manufacturers. You may need to check the website of the mobile device manufacturer to find its User-Agent header format or consider to use other detection methods such as UAProf. (With UAProf, the mobile device model and manufacturer name are available in the Model attribute and the Vendor attribute of the HardwarePlatform component respectively.)


To Differentiate Mobile Devices or User Agents Made by Different Companies with the User-Agent Header

In general, the User-Agent header contains information that can help us differentiate mobile devices or user agents made by different companies. Here are some examples: (Note: the keywords below are in lowercase but they may not be so in the actual User-Agent header)


  • The word "nokia" can be found in the User-Agent header of Nokia's cell phones.

  • The word "motorola" or "mot-" can be found in the User-Agent header of Motorola's cell phones.

  • The word "samsung" or "sec-" can be found in the User-Agent header of Samsung's cell phones.

  • The word "lg-" can be found in the User-Agent header of LG's cell phones.

  • The word "sonyericsson" can be found in the User-Agent header of Sony Ericsson's cell phones.

  • The word "sie-" can be found in the User-Agent header of Siemens' cell phones.

  • The word "up.b" or "up/" can be found in the User-Agent header of cell phones that uses the Openwave Mobile Browser. The Openwave Mobile Browser can be found in many cell phone models made by a variety of manufacturers such as Motorola, Samsung, LG, Siemens, etc.


Note that UAProf is a more elegant way for differentiating the manufacturers of mobile devices / user agents. (With UAProf, the name of the manufacturer is available in the Vendor attribute of the HardwarePlatform component.)


To Determine Whether a User Agent is a Web Browser on a Personal Computer or a Microbrowser on a Mobile Device with the User-Agent Header

Another common use of the User-Agent header is to determine whether the user agent is a web browser on a personal computer or a microbrowser on a mobile device. Below shows the User-Agent header of Microsoft Internet Explorer 6 and Mozilla Firefox 1.0.7 running on Windows 2000:


Microsoft Internet Explorer 6:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)


Mozilla Firefox 1.0.7:

Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7


If you compare the User-Agent headers of IE and Firefox with those of microbrowsers that were shown earlier, you will find that the User-Agent header of IE and Firefox contains the word "Mozilla" while those of microbrowsers do not. This can be served as a simple rule to determine whether a user agent is a web browser on a personal computer or a microbrowser on a mobile device.

Note that the above rule does not work in all cases. The User-Agent header of some microbrowsers also contains the word "Mozilla". For example, some Nokia 6630 cell phones use a "Mozilla compatible" User-Agent header. The reason is that Nokia 6630 is a web-compatible cell phone and can accept HTML content, but some websites that are designed for desktops will deny access to Nokia 6630 if the "Mozilla compatible" User-Agent header is not present.


"Mozilla compatible" User-Agent header of the Nokia 6630 cell phone:

Mozilla/4.0 (compatible; MSIE 5.0; Series60/2.8 Nokia6630/4.06.0 Profile/MIDP-2.0 Configuration/CLDC-1.1)


To increase accuracy, you can further check the OS name and browser name in the User-Agent header. For example, if you find the word "Mozilla" and the OS name "Windows NT" in the User-Agent string, it is almost certain that the user agent is a web browser on a computer but not on a mobile device; if you find the word "Mozilla" and the browser name "Firefox", it is certain that the user agent is a Firefox browser running on a computer since Firefox does not have a mobile device version (at the time of this writing).

Preferences - Do not show ads


Page 3 of 10 Previous Page | Next Page
Contents at a Glance
Print this Web Page | | Back to Top
Custom Search

Feedback Form (Expand)

What do you think about this web page?






Detecting User Agent and Device Capabilities - Table of Contents Detecting User Agent and Device Capabilities - Contents at a Glance Preferences - Change Color Scheme Preferences - Do Not Show Ads Previous Page Next Page