PHPackages                             lacus/cnpj-val - 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-val

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

lacus/cnpj-val
==============

Utility to validate CNPJ (Brazilian Business Tax ID)

2.0.1(3w ago)0774↑73.3%2MITPHPPHP ^8.2CI passing

Since Oct 12Pushed 3w agoCompare

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

READMEChangelogDependencies (11)Versions (4)Used By (2)

[![cnpj-val for PHP](https://camo.githubusercontent.com/5ccf36eeaa245f9b596d4a9329e64aa8d4314f065bbe8a059338b14ca2792202/68747470733a2f2f62722d7574696c732e76657263656c2e6170702f696d672f636f7665725f636e706a2d76616c2e6a7067)](https://camo.githubusercontent.com/5ccf36eeaa245f9b596d4a9329e64aa8d4314f065bbe8a059338b14ca2792202/68747470733a2f2f62722d7574696c732e76657263656c2e6170702f696d672f636f7665725f636e706a2d76616c2e6a7067)

[![Packagist Version](https://camo.githubusercontent.com/d3d9cd166ac28645335ca17a37412fba4d424357f2d80a283a1bc9640ce1a13b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c616375732f636e706a2d76616c)](https://packagist.org/packages/lacus/cnpj-val)[![Packagist Downloads](https://camo.githubusercontent.com/fdcd63272dd429f79b8524e005b409689807dc6440f38cf8cd932ad98428722f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6c616375732f636e706a2d76616c)](https://packagist.org/packages/lacus/cnpj-val)[![PHP Version](https://camo.githubusercontent.com/7dfe24d7b7ebf2e768f4769944bef372a61c48a222e69346b69e13a50806938e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c616375732f636e706a2d76616c)](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-val/README.pt.md)

A PHP utility to validate CNPJ (Brazilian Business Tax ID) values.

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)

- ✅ **Alphanumeric CNPJ**: Validates 14-character CNPJ in numeric or alphanumeric format
- ✅ **Flexible input**: Accepts `string` or `list`; array elements are concatenated in order
- ✅ **Format agnostic**: Strips non-alphanumeric characters (or non-digits when `type` is `numeric`) and optionally uppercases letters
- ✅ **Optional case sensitivity**: When `caseSensitive` is `false`, lowercase letters are accepted for alphanumeric CNPJ
- ✅ **Per-call override model**: Instance defaults can be overridden for one `isValid()` call only
- ✅ **Typed option validation**: Dedicated `TypeError` / `Exception` subclasses for invalid option or input usage
- ✅ **Dual API style**: Object-oriented (`CnpjValidator`) and functional (`cnpj_val()`)

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

[](#installation)

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

Import
------

[](#import)

```
