# fake-useragent

> Up-to-date simple useragent faker with real world database

- **URL**: https://www.freshcrate.ai/projects/fake-useragent
- **Author**: pypi
- **Category**: Databases
- **Latest version**: `2.2.0` (2026-04-21)
- **License**: Unknown
- **Source**: https://github.com/fake-useragent/fake-useragent
- **Homepage**: https://pypi.org/project/fake-useragent/
- **Language**: Python
- **GitHub**: 4,049 stars, 535 forks
- **Registry**: pypi (`fake-useragent`)
- **Tags**: `agent`, `fake`, `pypi`, `user`, `useragent`

## Description

[![Test & Deploy fake-useragent](https://github.com/fake-useragent/fake-useragent/actions/workflows/action.yml/badge.svg?branch=main)](https://github.com/fake-useragent/fake-useragent/actions/workflows/action.yml?query=branch%3Amain)
[![Ruff linter](https://github.com/fake-useragent/fake-useragent/actions/workflows/ruff.yml/badge.svg?branch=main)](https://github.com/fake-useragent/fake-useragent/actions/workflows/ruff.yml?query=branch%3Amain)
[![CodeQL](https://github.com/fake-useragent/fake-useragent/actions/workflows/codeql.yml/badge.svg?branch=main)](https://github.com/fake-useragent/fake-useragent/actions/workflows/codeql.yml?query=branch%3Amain)

# fake-useragent

Up-to-date simple useragent faker with real world database.

## Features

- Data is pre-downloaded & post-processed from [Intoli LLC](https://github.com/intoli/user-agents/tree/main/src) and the data is part of the package itself
- The data consists of a wide range of browser agents and various browsers
- Retrieves user-agent strings (both of type: `desktop`, `tablet` and/or `mobile` UAs)
- Retrieve user-agent Python dictionary (aka object), with fields like `useragent`, `percent`, `type`, `device_brand`, `browser`, `browser_version`, `os`, `os_version` and `platform`
- Supports Python 3.x

### Installation

```sh
pip install fake-useragent
```

Or if you have multiple Python / pip versions installed, use `pip3`:

```sh
pip3 install fake-useragent
```

### Usage

Simple usage examples below, see also next chapters in this readme for more advanced usages:

```py
from fake_useragent import UserAgent
ua = UserAgent()

# Get a random browser user-agent string
print(ua.random)
# Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0

# Or get user-agent string from a specific browser
print(ua.chrome)
# Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
print(ua.google)
# Mozilla/5.0 (iPhone; CPU iPhone OS 18_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/343.0.695551749 Mobile/15E148 Safari/604.1
print(ua['Chrome'])
# Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
print(ua.firefox)
# Mozilla/5.0 (Android 14; Mobile; rv:133.0) Gecko/133.0 Firefox/133.0
print(ua.ff)
# Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0
print(ua.safari)
# Mozilla/5.0 (iPhone; CPU iPhone OS 17_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Mobile/15E148 Safari/604.1 Ddg/17.6
print(ua.opera)
# Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 OPR/114.0.0.0
print(ua.edge)
# Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0
```

#### Additional usage

Additional features that fake-useragent now offers since v1.2.0.

If you want to specify your own browser list, you can do that via the `browsers` argument (default is: `["Google", "Chrome", "Firefox", "Edge", "Opera", "Safari", "Android", "Yandex Browser", "Samsung Internet", "Opera Mobile", "Mobile Safari", "Firefox Mobile", "Firefox iOS", "Chrome Mobile", "Chrome Mobile iOS", "Mobile Safari UI/WKWebView", "Edge Mobile", "DuckDuckGo Mobile", "MiuiBrowser", "Whale", "Twitter", "Facebook", "Amazon Silk"]`).  
This example will only return random user-agents from Edge and Chrome:

```py
from fake_useragent import UserAgent
ua = UserAgent(browsers=['Edge', 'Chrome'])
ua.random
```

_Note:_ Fakeuser-agent knowns about browsers: Chrome, Edge, Firefox, Safari, Opera, Android, Opera Mobile, Mobile Safari, Firefox Mobile, Firefox iOS, Chrome Mobile, Chrome Mobile iOS and more (see again full list above).  
_Note #2:_ Since fakeuser-agent v2.0.0 the browser names are case-sensitive!

---

If you want to specify your own operating systems, you can do that via the `os` argument (default is: `["Windows", "Linux", "Ubuntu", "Chrome OS", "Mac OS X", "Android", "iOS"]`).  
In this example you will only get Linux user-agents back:

```py
from fake_useragent import UserAgent
ua = UserAgent(os='Linux')
ua.random
```

_Note:_ Since fakeuser-agent v2.0.0 the OS names are case-sensitive!

---

You can also specify the type of platforms you want to use, you can do that via the `platforms` argument (default is `["desktop", "mobile", "tablet"]`).
This example will only return random user-agents from a mobile device:

```py
from fake_useragent import UserAgent
ua = UserAgent(platforms='mobile')
ua.random
```

And a random user-agent from a desktop device:

```py
from fake_useragent import UserAgent
ua = UserAgent(platforms='desktop')
ua.random
```

---

If you want to return more recent user-agent strings, you can play with the `min_version` argument (default is: `0.0`, meaning all user agents will match).  
In this example you get only user agents that have a minimum version of 120.0:

```py
from

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `2.2.0` | 2026-04-21 | Low | Imported from PyPI (2.2.0) |
| `2.1.0` | 2025-03-12 | Low | ## What's Changed * Update README.md by @matecsaj in https://github.com/fake-useragent/fake-useragent/pull/415 * Refactor UA updater CLI and add GH action to run updates automatically by @sebastian-correa in https://github.com/fake-useragent/fake-useragent/pull/404 * Trigger only once per month by @melroy89 in https://github.com/fake-useragent/fake-useragent/pull/422 * Speedup `ua_convert` parser by @sebastian-correa in https://github.com/fake-useragent/fake-useragent/pull/424 * Bump ruff f |
| `2.0.3` | 2024-12-10 | Low | - Fix `importlib-resources` in `dependencies` toml file. **See the `2.0.0` release below [for all the changes that are in v2.0.0](https://github.com/fake-useragent/fake-useragent/releases/tag/2.0.0)!!**  **Full Changelog**: https://github.com/fake-useragent/fake-useragent/compare/2.0.2...2.0.3 |
| `2.0.2` | 2024-12-09 | Low | Sync latest docs to PyPi. **See the `2.0.0` release below [for all the changes that are in v2.0.0](https://github.com/fake-useragent/fake-useragent/releases/tag/2.0.0)!!**  **Full Changelog**: https://github.com/fake-useragent/fake-useragent/compare/2.0.1...2.0.2 |
| `2.0.1` | 2024-12-07 | Low | Small patch release after v2.0.0, by adding a requires-python line to the toml file. We only support Python 3.9 or newer.  ## What's Changed * Bump validate-pyproject from 0.22 to 0.23 by @dependabot in https://github.com/fake-useragent/fake-useragent/pull/393 * Bump coverage from 7.6.4 to 7.6.8 by @dependabot in https://github.com/fake-useragent/fake-useragent/pull/398 * Bump ruff from 0.7.3 to 0.8.1 by @dependabot in https://github.com/fake-useragent/fake-useragent/pull/403 * Bump tomli |
| `2.0.0` | 2024-12-04 | Low | # fake-useragent v2.0.0  Finally, we successfully switched (again) to a new data source from [Intoli](https://intoli.com/), which allows us to have much more user-agent strings again. Thank you all for your support!  **Important:** Keep in mind that v2.0.0 does have some breaking changes like `platform` type "pc" value is now changed to "desktop" (in case you were using this). See below for all breaking changes!  ## Breaking changes  - OS and browser options are now case sensitive!!  - |
| `1.5.1` | 2024-03-16 | Low | **Fix:** Remove trailing spaces in user agent strings  ## What's Changed * Bump pytest from 7.4.3 to 8.1.1 by @dependabot in https://github.com/fake-useragent/fake-useragent/pull/306 * Bump lxml from 4.9.3 to 5.1.0 by @dependabot in https://github.com/fake-useragent/fake-useragent/pull/305 * Bump virtualenv from 20.25.0 to 20.25.1 by @dependabot in https://github.com/fake-useragent/fake-useragent/pull/303 * Bump ruff from 0.2.1 to 0.3.2 by @dependabot in https://github.com/fake-useragent/f |
| `1.5.0` | 2024-03-08 | Low | Most important change: The user-agent database has been updated with a more recent list of user agents. It also now comes with mobile UA's, meaning a new parameter: `platforms` has been introduced (see [README.md](https://github.com/fake-useragent/fake-useragent/blob/main/README.md)).   The only down-side is that this new data source didn't contain any usage data, meaning `min_percentage` is not useful anymore. Despite which `min_percentage` value you set, fake-useragent always return all data |
| `1.4.0` | 2023-11-24 | Low | ## What's Changed * Bump urllib3 from 2.0.4 to 2.0.6 in /cache_scraper by @dependabot in https://github.com/fake-useragent/fake-useragent/pull/217 * Bump tzlocal from 5.0.1 to 5.1 by @dependabot in https://github.com/fake-useragent/fake-useragent/pull/218 * Bump build from 0.10.0 to 1.0.3 by @dependabot in https://github.com/fake-useragent/fake-useragent/pull/221 * Bump tldextract from 3.4.4 to 3.6.0 by @dependabot in https://github.com/fake-useragent/fake-useragent/pull/220 * Bump cffi fro |
| `1.3.0` | 2023-10-02 | Low | - Introducing new `ua.getRandom`, `ua.getFirefox`, `ua.getChrome`, `ua.getSafari`. And a generic method: `ua.getBrowser(..)` (eg. `getBrowser('firefox')`)     - These new properties above allows you to retrieve the whole raw Python dictionary, instead of only the UA string.     - These properties might return different key/values pairs in the future! So `ua.random` is a more stable interface.   - Fix the `os` argument 'windows' to check for both `win10`and `win7` values (previously only che |

## Citation

- HTML: https://www.freshcrate.ai/projects/fake-useragent
- Markdown: https://www.freshcrate.ai/projects/fake-useragent.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/fake-useragent/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
