0.2.2 • Public • Published


    Adding capabilities to ua-parser2

    NOTE: This projects data-sets (yaml files) are outdated as not beiing maintained any more...

    NPM version Build Status

    ua-parser-caps is a parser build upon the extracted data provided by ua-parser2. It adds capabilities to User-Agent String(s) with the following features:

    • Capabilities can be added using the dimensions OS, User-Agent and device.
    • Capabilities can be applied per regular-expression either on complete User-Agent strings or on any extracted value provided by the parsing result from ua-parser2.
    • Capabilities can be extended per OS, User-Agent and Device.
      • Extends can be chained (use capability3 based on capability2 based on capability1 ...).
    • Capabilities can be overwritten if criterias from another dimension match.
    • Capabilities can be attributed within separate files. This allows to choose the proper capabilities for your use-case.

    Table of Contents

    Capability Files

    Within this project the following capability-files are provided:

    • caps_device_type.yaml contains a device-type classification of a User-Agent String.
    • caps_user_view.yaml contains a user view default preference classification.
    • caps_ie_compatibility.yaml contains information on Internet Explorer capability mode.

    Details of the capabilities can be found within the files.

    The set of capability files you want to use in your project can be changed within the file js/config.js.


    To speed up the loading and parsing of the YAML files a preparsed js-module is generated.

    Use js/bin/caps2js.js -c or make caps to generate a new version if the YAML files have changed.

    npm packages always contain the latest capability files.


    A sample usage is provided using the file js/test/sample.js.

    var uaparser = require('ua-parser2')();
    var capsparser = require('ua-parser-caps')();
    var userAgent = 'Mozilla/5.0 (Linux; Android 4.3.1; LG-E980 Build/JLS36I) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Mobile Safari/537.36';
    var uaparsed = uaparser.parse(userAgent);
    var capabilities = capsparser.parse(uaparsed);


    { device: { type: 'phablet' },
      user: { view: 'mobile' },
       { href:
          { '1': '',
            '2': '',
            '3': '' } },
      screen: { size: 5.5, width: 1080, height: 1920 } }

    See sample.js.

    Asynchronous Loading

    var userAgent = "Mozilla/5.0 (Linux; Android 4.3.1; LG-E980 Build/JLS36I) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Mobile Safari/537.36";
    var uaparser = require('ua-parser2')();
    require('ua-parser-caps')(function(err, capsparser){
      /// async loading completed
      if (!err) {
        var uaparsed = uaparser.parse(userAgent);
        var capabilities = capsparser.parse(uaparsed);

    See sampleAsync.js.


    If you are interested to contribute data or even write your own capability files then please take a look into the specification.


    • ./

      • caps_*.yaml capability files
    • ./doc

      • Specification on capability files.
    • ./js

      • index.js A node.js implementation of ua-parser-cap.
      • config.js Configuration file for the parser.
    • ./js/test

      • test files for the parser.
    • ./test/resources/parser

      • test files as yaml files to test a ua-parser-cap implementation.

    Contribution and License Agreement

    If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work.

    If you contribute data to this project, you are implicitly allowing your code to be distributed under the CC-BY-4.0 license. You are also implicitly verifying that all data is your original work.

    Please read the contributors' guide.


    Copyright (c) 2013 commenthol

    Software is released under MIT.
    Data provided within Yaml-Files is released under CC-BY-4.0.


    npm i ua-parser-caps

    DownloadsWeekly Downloads






    Unpacked Size

    7.61 MB

    Total Files


    Last publish


    • avatar