User agent string parser in golang
Clone or download
xojoc Merge pull request #13 from pendo-io/master
Complete googlebot support
Latest commit 5290380 Feb 15, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
COPYING s Feb 20, 2015 fixes #5 + cleanup Feb 12, 2017
browser.go fixes #5 + cleanup Feb 12, 2017
crawler.go Add support for Googlebot News Feb 14, 2017
lex.go fixes #5 + cleanup Feb 12, 2017
lex_test.go fixes #5 + cleanup Feb 12, 2017
parse.go fixes #5 + cleanup Feb 12, 2017
parse_test.go Add support for Googlebot News Feb 14, 2017

User agent parsing

useragent is a library written in golang to parse user agent strings.


First install the library with:

go get

useragent is simple to use. First parse a string with useragent.Parse and then access the fields of useragent.UserAgent for the required information. Example:

see godoc for the complete documentation.

How it works?

      Lasciate ogne speranza, voi ch'intrate. -Dante

Parsing user agent strings is a hell. There is no standard for user agent strings, so useragent must use some heuristics. The site has been invaluable during development. Some relevant links are also:

for the supported user agents see:

If you think useragent doesn't parse correctly a particular user agent string, just open an issue :).

Why this library?

useragent doesn't just split the user agent string and look for specific strings like other parsers, but it has specific parser for the most common browsers/crawlers and falls back to a generic parser for everything else. Its main features are:

  • Simple and stable API.
  • High precision in detection of the most common browsers/crawlers.
  • Detects mobile/tablet devices.
  • OS detection.
  • URL with more information about the user agent (usually it's the home page).
  • Security level detection when reported by browsers.


useragent was written by Alexandru Cojocaru ( and uses blang/semver to parse versions.

Thanks a lot to @brendanwalters (from for the contributions.



useragent is released under the GPLv3 or later, see COPYING.