57

Is there a good, up-to-date listing anywhere that maps User-Agent HTTP Header strings --> operating systems?

bignose
  • 30,281
  • 14
  • 77
  • 110
C. Dragon 76
  • 9,882
  • 9
  • 34
  • 41
  • Since this question has been asked, it has become offtopic (asking for third-party resources). It should not be re-opened. – Sumurai8 Jun 28 '14 at 15:40

7 Answers7

54

Here's a quick list... let me know if I missed one you are interested in.

http://www.geekpedia.com/code47_Detect-operating-system-from-user-agent-string.html:

// Match user agent string with operating systems
Windows 3.11 => Win16,
Windows 95 => (Windows 95)|(Win95)|(Windows_95),
Windows 98 => (Windows 98)|(Win98),
Windows 2000 => (Windows NT 5.0)|(Windows 2000),
Windows XP => (Windows NT 5.1)|(Windows XP),
Windows Server 2003 => (Windows NT 5.2),
Windows Vista => (Windows NT 6.0),
Windows 7 => (Windows NT 6.1),
Windows 8 => (Windows NT 6.2),
Windows 10 => (Windows NT 10.0),
Windows NT 4.0 => (Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT),
Windows ME => Windows ME,
Open BSD => OpenBSD,
Sun OS => SunOS,
Linux => (Linux)|(X11),
Mac OS => (Mac_PowerPC)|(Macintosh),
QNX => QNX,
BeOS => BeOS,
OS/2 => OS/2,
Search Bot=>(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves/Teoma)|(ia_archiver)

hytromo
  • 1,501
  • 2
  • 27
  • 57
Nescio
  • 27,645
  • 10
  • 53
  • 72
14

What language are you developing in? That makes a huge difference in what is available to you if you want to do data-mining on the user agent string.

Nescio's response provides a good list. The second link under PHP in my list also contains basically the same information which is simple enough that you should be able to translate it to any language.

Keep in mind that using the user agent for anything is rife with problems. Unless you're willing to dedicate a portion of your development time to monitoring user agents visiting your site and performing constant maintenance, you should try to avoid doing it entirely. No matter what your use-case is for needing to detect the OS, every OS in every platform can have dramatic changes in very short time-frames so it is important to be mindful of this and careful about how and why you do OS detection.

To elaborate on the risks: On the desktop, a new OS version can come out every 6 weeks (Chrome OS), 6 months (Ubuntu), 1 year (Mac OS), or 2-3 years (Windows). Then you also need to account for OSes released for phones, tablets, gaming consoles, clocks, etc which can have much more frequent release cycles and unpredictable changes in market share. Just look at how BlackBerry, Palm OS, Web OS, iOS, Android, Windows Mobile, and Windows Phone have changed market share in just the last few years to name a few.

Unless the operating system is a dependency of your site, like if you're creating a targeted "download" page for an app (which in itself can be rife with problems), it is almost always better to use feature detection, which will allow you to future-proof your development without having to constantly maintain browser or OS detection code.

Dan Herbert
  • 99,428
  • 48
  • 189
  • 219
  • Very useful links. Thanks! I'm using ASP.NET and hadn't noticed HttpBrowserCapabilities. That certainly helps. – C. Dragon 76 Oct 23 '08 at 03:58
  • 1
    @Pacerier It looks like the author has stopped supporting it, according to this page: http://apptools.com/phptools/browser/ Fortunately, someone picked up his work where he left off and made some improvements. – Dan Herbert Sep 24 '11 at 13:53
8

It's worth keeping in mind that the user agent header can easily be faked. I wouldn't rely on it for anything important.

Sherm Pendley
  • 13,556
  • 3
  • 45
  • 57
  • 11
    You can't use it as a security check, but otherwise its fine. Very rarely will a user tweak their user-agent string, and if they do I don't mind if my software fails for them. – Frank Schwieterman Jan 10 '09 at 19:54
  • 3
    "and if they do I don't mind if my software fails for them": So _you're_ the one! – Anonymous May 01 '09 at 08:54
  • 1
    I agree with Frank, it's hard enough to get the detection right without also having to worry about people messing with the UAs. – CRice May 23 '11 at 01:19
2

It's nearly always a bad idea to do UA sniffing. You can't rely on it at all.

If you want to sent the client a response specific to its environment you should perhaps distinguish differences from content-type or encoding. These are rock-solid specified.

mkoeller
  • 4,469
  • 23
  • 30
  • 1
    I think UA sniffing is good to a point, its gets you a fair way into detection for the main/obvious things, but then you need something else backing it up. – CRice May 23 '11 at 01:21
  • 1
    could you explain more on your link? on your idea of rock-solid specified ways of determining the OS? – Pacerier Sep 24 '11 at 12:28
  • Example from 2020: I'm using the user-agent string to detect if the user is running Windows 7, and if they are, my blog post about upgrading to Linux will adjust its text accordingly. – Skylar Ittner Jan 16 '20 at 02:12
2

The User Agent from the browser is not something I would rely on for anything, We all use it for statistics, but we know they're not 100% accurate.

I use firefox and regularly spoof IE for some sites that don't like it, my regular UA is:

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) 
Gecko/2008101315 Ubuntu/8.10 (intrepid) Firefox/3.0.3 

I sometimes use a firefox extension to change it to:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; MS-RTC LM 8; 
.NET CLR 2.0.50727; .NET CLR 1.1.4322)

when you are looking at it, you would need to parse the different parts, the OS is the third part of the semicolon-delimited values between brackets.

Osama Al-Maadeed
  • 5,654
  • 5
  • 28
  • 48
  • 2
    If I'm trying to do the user a favor and show them the most relevant information for their OS (like a .exe download for Windows, or a .dmg for Mac), and they lie to me about their OS, then that's their problem, not mine. – Barmar Dec 30 '15 at 15:25
1

I was searching for the same thing, then found:
http://www.useragentstring.com

Great, but extremely elaborate: you'll probably want to re-think the project you need the list for, since this one puts 'things in perspective'.

Just wanted to share this for future people researching this.

GitaarLAB
  • 14,536
  • 11
  • 60
  • 80
1

Nowadays I can recommend the database from http://user-agent-string.info. You can identify the User-Agent as well as the operating system (if available).

I'm developing the Java library UADetector and merging every month a new version of the database (a.k.a. UAS file), available in XML and INI format. Therefore, I can say from my experience that this data is kept up to date. The usual update intervals is between 5 to 10 days.

before
  • 585
  • 6
  • 12
  • http://user-agent-string.info doesn't work anymore and UADetector didn't have update for 2 years now – igo Jul 22 '16 at 08:14