Skip to main content

Official python implementation of the User Agent String Parser project.

Build Status

CI on the master branch Documentation Status

Installing

Add ua-parser[regex] to your project’s dependencies, or run

$ pip install 'ua-parser[regex]'

to install in the current environment.

ua-parser supports CPython 3.10 and newer, recent pypy (supporting 3.10), and GraalPy 25.

Quick Start

Retrieve all data on a user-agent string

>>> from ua_parser import parse
>>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
>>> parse(ua_string) # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
Result(user_agent=UserAgent(family='Chrome',
                            major='41',
                            minor='0',
                            patch='2272',
                            patch_minor='104'),
       os=OS(family='Mac OS X',
             major='10',
             minor='9',
             patch='4',
             patch_minor=None),
       device=Device(family='Mac',
                     brand='Apple',
                     model='Mac'),
       string='Mozilla/5.0 (Macintosh; Intel Mac OS...

Any datum not found in the user agent string is set to None:

>>> parse("")
Result(user_agent=None, os=None, device=None, string='')

Extract only browser data from user-agent string

>>> from ua_parser import parse_user_agent
>>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
>>> parse_user_agent(ua_string)
UserAgent(family='Chrome', major='41', minor='0', patch='2272', patch_minor='104')

For specific domains, a match failure just returns None:

>>> parse_user_agent("")

Extract OS information from user-agent string

>>> from ua_parser import parse_os
>>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
>>> parse_os(ua_string)
OS(family='Mac OS X', major='10', minor='9', patch='4', patch_minor=None)

Extract device information from user-agent string

>>> from ua_parser import parse_device
>>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
>>> parse_device(ua_string)
Device(family='Mac', brand='Apple', model='Mac')

Upgrading

Upgrading from 0.x? See the upgrade guide.

Release files for ua-parser 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ua-parser 1.0.2
File Size Uploaded
ua_parser-1.0.2.tar.gz 33.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ua-parser 1.0.2
File Interpreter ABI Platform
ua_parser-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 64.5 kB

Release files / ua_parser-1.0.2.tar.gz

Download URL ua_parser-1.0.2.tar.gz
Size 33.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bab404ad42fb37f943107da2f6003ffc79724d11cc95076a7a539513371779da
BLAKE2b-256 checksum
How to use checksums
90985e4b52d772a048af122a6fc5ce365c311efb9f5e79c55fd4fdd7c9f59e83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 5, 2026.

Transparency log

Release files / ua_parser-1.0.2-py3-none-any.whl

Download URL ua_parser-1.0.2-py3-none-any.whl
Size 31.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0f8e6d0484af2a9ff804bba5a4fe696e87c028eaba98ad9a7dfae873fef7788a
BLAKE2b-256 checksum
How to use checksums
a97c6367995ff57aaa2d9e1055adbaec2519cf5a979780a83a93fdf8c6ec37be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 5, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page