PHPackages                             lacus/br-utils - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. lacus/br-utils

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

lacus/br-utils
==============

Utilities to deal with Brazilian-related data

2.0.1(3w ago)0178↓12.5%MITPHPPHP ^8.2CI passing

Since Oct 20Pushed 3w agoCompare

[ Source](https://github.com/LacusSolutions/br-utils-php_br-utils)[ Packagist](https://packagist.org/packages/lacus/br-utils)[ Docs](https://br-utils.vercel.app/)[ RSS](/packages/lacus-br-utils/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (14)Versions (4)Used By (0)

[![br-utils for PHP](https://camo.githubusercontent.com/769cb87b3225243e1d1b934cb27ad0a5275d38cd66e71aefa7aa6fb70b1ca26c/68747470733a2f2f62722d7574696c732e76657263656c2e6170702f696d672f636f7665725f62722d7574696c732e6a7067)](https://camo.githubusercontent.com/769cb87b3225243e1d1b934cb27ad0a5275d38cd66e71aefa7aa6fb70b1ca26c/68747470733a2f2f62722d7574696c732e76657263656c2e6170702f696d672f636f7665725f62722d7574696c732e6a7067)

[![Packagist Version](https://camo.githubusercontent.com/163154ffc89a90deea829288025da9f4405f8e9ed9e718c1aeb711e9a3454bd8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c616375732f62722d7574696c73)](https://packagist.org/packages/lacus/br-utils)[![Packagist Downloads](https://camo.githubusercontent.com/c35d3d90ac638194ce8f58cb3217e4d5814a033e9f4686e8d0bda359057f96cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6c616375732f62722d7574696c73)](https://packagist.org/packages/lacus/br-utils)[![PHP Version](https://camo.githubusercontent.com/fae2244840299c29d1db81fc4b6e90441db34f67343b7cdf71047ce99aef6e8e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c616375732f62722d7574696c73)](https://www.php.net/)[![Test Status](https://camo.githubusercontent.com/bc71a889730b33757624a7665d324206586beb2c64e6a2d2d32852e2b30f1df1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4c61637573536f6c7574696f6e732f62722d7574696c732d7068702f63692e796d6c3f6c6162656c3d63692f6364)](https://github.com/LacusSolutions/br-utils-php/actions)[![Last Update Date](https://camo.githubusercontent.com/3de9411599aeb23885d20d61de36d9b02a1b43618d8b4360e57fd371469c61cb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f4c61637573536f6c7574696f6e732f62722d7574696c732d706870)](https://github.com/LacusSolutions/br-utils-php)[![Project License](https://camo.githubusercontent.com/3831eac41446c923d630ebf80bfc848f862c79619ee4814821521ccf13dfef2a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4c61637573536f6c7574696f6e732f62722d7574696c732d706870)](https://github.com/LacusSolutions/br-utils-php/blob/main/LICENSE)

> 🚀 **Full support for the [new alphanumeric CNPJ format](https://github.com/user-attachments/files/23937961/calculodvcnpjalfanaumerico.pdf).**

> 🌎 [Acessar documentação em português](https://github.com/LacusSolutions/br-utils-php/blob/main/packages/br-utils/README.pt.md)

A PHP toolkit to handle the main operations with Brazilian-related data: CPF (Individual's Taxpayer ID) and CNPJ (Business Tax ID). It provides a top-level `BrUtils` wrapper around [`lacus/cpf-utils`](https://packagist.org/packages/lacus/cpf-utils) and [`lacus/cnpj-utils`](https://packagist.org/packages/lacus/cnpj-utils), exposing all bundled resources under unified namespaces.

PHP Support
-----------

[](#php-support)

[![PHP 8.2](https://camo.githubusercontent.com/6dab1427c2636572a765f9e0f332c0665ce863cbc46cece88aa44f747132c260/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/6dab1427c2636572a765f9e0f332c0665ce863cbc46cece88aa44f747132c260/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![PHP 8.3](https://camo.githubusercontent.com/2bace8bb56a21d62a4c1c2e2018eb2e83eff46e07cab21c26ca42feda0bdd46e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/2bace8bb56a21d62a4c1c2e2018eb2e83eff46e07cab21c26ca42feda0bdd46e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![PHP 8.4](https://camo.githubusercontent.com/cf871f594e557c5b9ae8715a2b7207b9b73686ee83156cd0308489979d0d84e5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/cf871f594e557c5b9ae8715a2b7207b9b73686ee83156cd0308489979d0d84e5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![PHP 8.5](https://camo.githubusercontent.com/38189c74fa19d38a84282702897dcd5bf0e54f8ee6be5cb02aa9a3a1f5711862/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e352d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/38189c74fa19d38a84282702897dcd5bf0e54f8ee6be5cb02aa9a3a1f5711862/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e352d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)Passing ✔Passing ✔Passing ✔Passing ✔Features
--------

[](#features)

- ✅ **Unified top-level API**: One `BrUtils` instance with `$cpf` and `$cnpj` domain accessors
- ✅ **Bundled domains**: [`lacus/cpf-utils`](https://packagist.org/packages/lacus/cpf-utils) and [`lacus/cnpj-utils`](https://packagist.org/packages/lacus/cnpj-utils) installed together
- ✅ **Alphanumeric CNPJ**: Full support for the new alphanumeric CNPJ format (introduced in 2026)
- ✅ **Configurable defaults**: Set formatter, generator, and (for CNPJ) validator options on each domain instance
- ✅ **Per-call overrides**: Override any component option for a single method call
- ✅ **Dual API style**: Top-level façade (`BrUtils`), domain aggregators (`CpfUtils`, `CnpjUtils`), standalone components, and functional helpers
- ✅ **Shared namespaces**: CPF symbols under `Lacus\BrUtils\Cpf\`; CNPJ symbols under `Lacus\BrUtils\Cnpj\`
- ✅ **Typed error handling**: Dedicated exception hierarchies from bundled packages (CNPJ v2 `TypeError` / `Exception` model; CPF v1 `InvalidArgumentException` for invalid options)

Installation
------------

[](#installation)

```
# using Composer
$ composer require lacus/br-utils
```

This installs **`lacus/br-utils`** together with [`lacus/cpf-utils`](https://packagist.org/packages/lacus/cpf-utils) and [`lacus/cnpj-utils`](https://packagist.org/packages/lacus/cnpj-utils) (which in turn pulls in the CNPJ component packages). You do **not** need separate `composer require` calls for the domain packages when using **`lacus/br-utils`**.

Import
------

[](#import)

Pick the API that fits your use case.

**Top-level façade:**

```
