Skip to content
browser/engine/os/device detection tool
JavaScript CSS HTML
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.
dist 3.3.0 Nov 19, 2019


Sniffer is a browser/engine/os/device detection tool. Works both in a browser and with Node.

Live demo (tests your browser UA string)

Test suite

You have three options:

1. Default Sniffer build

Get sniffer.js from dist/. Drop the script tag in the <head>:

<script src="path/to/sniffer.js"></script>

It will run automatically, collect the information on current device/os/browser and put the results in window.Sniff object (or expose it via module.exports, if available). See “Detection results” for details. Now you can do horrible things:

if ('android' &&
	Sniff.os.majorVersion &&
	Sniff.os.majorVersion < 3 &&
	! &&
	Sniff.browser.engine=='webkit') {
		//looks like default Android 2.x browser!

It will also add browser name shortcode, browser engine shortcode, OS name shortcode and device features’ shortcodes to <html> tag’s className, so you can alter the styles accordingly (pretty much the Modernizr way):

/* contrast colors for monochrome devices */ body {
	color: black;
	background: white;

/* make sure code snippets are readable in Opera Mini */
html.operamini pre code {
	white-space: pre-wrap;

2. Sniffer module

Get sniffer.module.js from dist/. It exposes Sniffer function into global scope or via module.exports, if available. Compatible with Node. Just feed it a user agent string:


It will return detection result, see “Detection results” for details.

Also available via npm: npm install snifferjs.

3. Pure Sniffer function

Get sniffer.pure.js from dist/. It contains pure Sniffer function (no wrap, no autolaunch, no css classes, no exports), you decide how to use it.

Detection results

Sniffer returns an object which looks like this:

	browser: {
		fullName: String, // full human readable name
		name: String, // shortcode
		version: String, // semantic version, up to three parts (major.minor.patch)
		majorVersion: Number,
		minorVersion: Number,
		patchVersion: Number,
		engine: String // shortcode
	os: {
		fullName: String, // full human readable name
		name: String, // shortcode
		version: String, // semantic version, up to three parts (major.minor.patch)
		versionName: String, // human readable version name, e.g. 'Vista', 'Mavericks', etc.
		versionAltNames: Array, // possible alternatives, e.g. Windows NT 5.2 can be 'XP' or 'Server 2003'
		majorVersion: Number,
		minorVersion: Number,
		patchVersion: Number
	features: {
		bw: Boolean, /* black and white (e-book readers) */
		mobile: Boolean, /* includes phones, tablets, e-book readers, portable game consoles, etc. */
		tv: Boolean, /* smart tv */
		proxy: Boolean /* serverside js & rendering, like in Opera Mini */


Class names/shortcodes in square brackets.


  • Chrome [chrome]
  • Firefox [firefox]
  • IE [ie]
  • Edge [edge]
  • Safari [safari]
  • Opera [opera]
  • Opera Mini [operamini]
  • Opera Coast [coast]
  • Nokia Browser [nokiabrowser] (!= Nokia Xpress) — Symbian Belle phones
  • Ovi Browser a.k.a Nokia Xpress [ovi] — Nokia Asha, Series40 & Series60 phones, etc.
  • Sailfish Browser [sailfishbrowser]


  • WebKit [webkit]
  • Gecko [gecko]
  • Trident [trident]
  • Presto [presto]
  • EdgeHTML [edgehtml]


  • Windows [win]
  • Mac OS X [osx]
  • Ubuntu [ubuntu]
  • Fedora [fedora]
  • Windows Phone [winphone]
  • Android [android]
  • iOS [ios]
  • BlackBerry [blackberry]
  • Sailfish OS [sailfish]
  • Symbian [symbian]
  • Kindle [kindle] (Kindle Fire should be detected as Android)
  • PlayStation [playstation]
  • PlayStation Vita [psvita]
  • Nintendo DSi [dsi]
  • Nintendo 3DS [3ds]
  • New Nintendo 3DS [n3ds]
  • Viera [viera] (Panasonic Viera smart tv)


  • Black and white [bw]
  • Mobile [mobile]
  • TV [tv]
  • Proxy broswer (serverside rendering) [proxy]


MIT license.

Have fun, lads.

You can’t perform that action at this time.