PHPackages                             lacus/cnpj-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. lacus/cnpj-utils

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lacus/cnpj-utils
================

Utilities to deal with CNPJ (Brazilian Business Tax ID)

2.0.1(3w ago)0435↓37.5%1MITPHPPHP ^8.2CI passing

Since Oct 15Pushed 3w agoCompare

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

READMEChangelogDependencies (9)Versions (5)Used By (1)

[![cnpj-utils for PHP](https://camo.githubusercontent.com/0bf21c740a589ecd1a9407957b6b69b0589ae669d2b7bdb4b3ffcb031be8dd97/68747470733a2f2f62722d7574696c732e76657263656c2e6170702f696d672f636f7665725f636e706a2d7574696c732e6a7067)](https://camo.githubusercontent.com/0bf21c740a589ecd1a9407957b6b69b0589ae669d2b7bdb4b3ffcb031be8dd97/68747470733a2f2f62722d7574696c732e76657263656c2e6170702f696d672f636f7665725f636e706a2d7574696c732e6a7067)

[![Packagist Version](https://camo.githubusercontent.com/d4ddd596e15857d80d0065b310d18bd3ecba1deb45d8eb85fa22f2414d2bc738/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c616375732f636e706a2d7574696c73)](https://packagist.org/packages/lacus/cnpj-utils)[![Packagist Downloads](https://camo.githubusercontent.com/c7ad6e1e5c1856f657ea2c919dd1ee24f721954f4bd842e42dab92aad2f93df1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6c616375732f636e706a2d7574696c73)](https://packagist.org/packages/lacus/cnpj-utils)[![PHP Version](https://camo.githubusercontent.com/94289bb27c902473c309288541a7c593ecf3d5a098ebb09885cd8fad02e55af0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c616375732f636e706a2d7574696c73)](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/cnpj-utils/README.pt.md)

A PHP utility to format, generate, and validate CNPJ (Brazilian Business Tax ID). It provides a wrapper class to [`lacus/cnpj-fmt`](https://packagist.org/packages/lacus/cnpj-fmt), [`lacus/cnpj-gen`](https://packagist.org/packages/lacus/cnpj-gen), and [`lacus/cnpj-val`](https://packagist.org/packages/lacus/cnpj-val) alongside the resources provided by these packages.

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 API**: One `CnpjUtils` class for formatting, generation, and validation
- ✅ **Bundled components**: All formatter, generator, and validator classes, options objects, enums, and helpers from the co-related packages are available under `Lacus\BrUtils\Cnpj\`
- ✅ **Alphanumeric CNPJ**: Full support for the new alphanumeric CNPJ format (introduced in 2026)
- ✅ **Flexible input**: `format()` and `isValid()` accept `string` or `list`
- ✅ **Configurable defaults**: Set formatter, generator, and validator options on the instance
- ✅ **Per-call overrides**: Override any component option for a single method call
- ✅ **Validator options**: Configure `type` and `caseSensitive` (new in v2; v1 had no validator settings)
- ✅ **Dual API style**: Unified façade (`CnpjUtils`) or standalone components (`CnpjFormatter`, `CnpjGenerator`, `CnpjValidator`) and functional helpers (`cnpj_fmt()`, `cnpj_gen()`, `cnpj_val()`)
- ✅ **Typed error handling**: Dedicated `TypeError` / `Exception` hierarchies from bundled packages

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

[](#installation)

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

This installs **`lacus/cnpj-utils`** together with [`lacus/cnpj-fmt`](https://packagist.org/packages/lacus/cnpj-fmt), [`lacus/cnpj-gen`](https://packagist.org/packages/lacus/cnpj-gen), and [`lacus/cnpj-val`](https://packagist.org/packages/lacus/cnpj-val). You do **not** need separate `composer require` calls for the component packages when using **`lacus/cnpj-utils`**.

Import
------

[](#import)

Pick the API that fits your use case. All symbols below share the namespace **`Lacus\BrUtils\Cnpj\`** and are available after installing **`lacus/cnpj-utils`**.

**Unified façade:**

```
