1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
---
title: User-Agent
slug: Web/HTTP/Headers/User-Agent
tags:
- HTTP
- NeedsTranslation
- Reference
- TopicStub
- header
translation_of: Web/HTTP/Headers/User-Agent
---
<div>{{HTTPSidebar}}</div>
<p>The <strong>User-Agent</strong> request header contains a characteristic string that allows the network protocol peers to identify the application type, operating system, software vendor or software version of the requesting software user agent.</p>
<div class="note">
<p>Please read <a href="/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent">Browser detection using the user agent</a> and why serving different Web pages or services to different browsers is usually a bad idea.</p>
</div>
<table class="properties">
<tbody>
<tr>
<th scope="row">Header type</th>
<td>{{Glossary("Request header")}}</td>
</tr>
<tr>
<th scope="row">{{Glossary("Forbidden header name")}}</th>
<td>no</td>
</tr>
</tbody>
</table>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox">User-Agent: <product> / <product-version> <comment>
Common format for web browsers:
User-Agent: Mozilla/<version> (<system-information>) <platform> (<platform-details>) <extensions>
</pre>
<h2 id="Directives">Directives</h2>
<dl>
<dt><product></dt>
<dd>A product identifier</dd>
<dt><product-version></dt>
<dd>A version number of the product.</dd>
<dt><comment></dt>
<dd>Zero or more comments containing sub product information, for example.</dd>
</dl>
<h2 id="Firefox_UA_string">Firefox UA string</h2>
<p>For more details on Firefox and Gecko based user agent strings, see the <a href="/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox">Firefox user agent string reference</a>. The UA string of Firefox itself is broken down into four components:</p>
<p><strong>Mozilla/5.0 (<em>platform</em>; rv:<em>geckoversion</em>) Gecko/<em>geckotrail</em> Firefox/<em>firefoxversion</em></strong></p>
<ul>
<li><em><strong>Mozilla/5.0</strong></em> is the general token that says the browser is Mozilla compatible, and is common to almost every browser today.</li>
<li><strong><em>platform</em></strong> describes the native platform the browser is running on (e.g. Windows, Mac, Linux or Android), and whether or not it's a mobile phone. Firefox OS phones simply say "Mobile"; the web is the platform. Note that <strong><em>platform</em></strong> can consist of multiple "; "-separated tokens. See below for further details and examples.</li>
<li><strong>rv:<em>geckoversion</em></strong> indicates the release version of Gecko (such as <em>"17.0"</em>). In recent browsers, <strong><em>geckoversion</em></strong> is the same as <strong><em>firefoxversion</em></strong>.</li>
<li><strong><em>Gecko/geckotrail</em></strong> indicates that the browser is based on Gecko.</li>
<li>On Desktop, <em><strong>geckotrail</strong></em> is the fixed string "20100101"</li>
<li><em><strong>Firefox/firefoxversion</strong></em> indicates the browser is Firefox, and provides the version (such as "<em>17.0"</em>).</li>
</ul>
<h3 id="Examples">Examples</h3>
<pre>Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0
Mozilla/5.0 (Macintosh; Intel Mac OS X <em>x.y</em>; rv:42.0) Gecko/20100101 Firefox/42.0
</pre>
<h2 id="Chrome_UA_string">Chrome UA string</h2>
<p>The Chrome (or Chromium/blink-based engines) user agent string is similar to the Firefox format. For compatibility, it adds strings like "KHTML, like Gecko" and "Safari".</p>
<h3 id="Examples_2">Examples</h3>
<pre>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36</pre>
<h2 id="Opera_UA_string">Opera UA string</h2>
<p>The Opera browser is also based on the blink engine, which is why it almost looks the same, but adds "OPR/<version>".</p>
<h3 id="Examples_3">Examples</h3>
<pre>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36 OPR/38.0.2220.41</pre>
<h2 id="Safari_UA_string">Safari UA string</h2>
<p>In this example, the user agent string is mobile safari version. It contains the word "Mobile".</p>
<h3 id="Examples_4">Examples</h3>
<pre>Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1</pre>
<h2 id="Internet_Explorer_UA_string">Internet Explorer UA string</h2>
<h3 id="Examples_5">Examples</h3>
<pre>Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)</pre>
<h2 id="Crawler_and_bot_UA_strings">Crawler and bot UA strings</h2>
<h3 id="Examples_6">Examples</h3>
<pre>Googlebot/2.1 (+http://www.google.com/bot.html)</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Title</th>
</tr>
<tr>
<td>{{RFC("7231", "User-Agent", "5.5.3")}}</td>
<td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
<p>{{Compat("http.headers.User-Agent")}}</p>
<h2 id="See_also">See also</h2>
<ul>
<li><a href="https://hacks.mozilla.org/2013/09/user-agent-detection-history-and-checklist/">User-Agent detection, history and checklist</a></li>
<li><a href="/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox">Firefox user agent string reference</a></li>
<li>
<p><a href="/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent">Browser detection using the user agent</a></p>
</li>
</ul>
|