{"id":30948236,"url":"https://github.com/lacussolutions/br-utils-js","last_synced_at":"2026-03-08T05:01:59.961Z","repository":{"id":311256093,"uuid":"1040825411","full_name":"LacusSolutions/br-utils-js","owner":"LacusSolutions","description":"JavaScript/TypeScript utility functions and resources for Brazilian-related data.","archived":false,"fork":false,"pushed_at":"2026-02-27T15:06:15.000Z","size":2899,"stargazers_count":0,"open_issues_count":15,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-27T20:14:43.818Z","etag":null,"topics":["br","bun","cep","cnpj","cpf","formatter","generator","geoinformation","helpers","javscript","node","npm","typescript","utils","validator"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/br-utils","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LacusSolutions.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-19T15:02:20.000Z","updated_at":"2026-01-12T12:55:21.000Z","dependencies_parsed_at":"2025-09-18T23:12:26.208Z","dependency_job_id":"e4a1e439-884f-4a44-b18a-2b765793bfd4","html_url":"https://github.com/LacusSolutions/br-utils-js","commit_stats":null,"previous_names":["juliolmuller/br-utils-js","lacussolutions/br-utils-js"],"tags_count":66,"template":false,"template_full_name":null,"purl":"pkg:github/LacusSolutions/br-utils-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LacusSolutions%2Fbr-utils-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LacusSolutions%2Fbr-utils-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LacusSolutions%2Fbr-utils-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LacusSolutions%2Fbr-utils-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LacusSolutions","download_url":"https://codeload.github.com/LacusSolutions/br-utils-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LacusSolutions%2Fbr-utils-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30246626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T00:58:18.660Z","status":"online","status_checked_at":"2026-03-08T02:00:06.215Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["br","bun","cep","cnpj","cpf","formatter","generator","geoinformation","helpers","javscript","node","npm","typescript","utils","validator"],"created_at":"2025-09-11T02:02:18.649Z","updated_at":"2026-03-08T05:01:59.942Z","avatar_url":"https://github.com/LacusSolutions.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![br-utils for JavaScript](https://br-utils.vercel.app/img/cover_br-utils.jpg)\n\n[![NPM Latest Version](https://img.shields.io/npm/v/br-utils)](https://npmjs.com/package/br-utils)\n[![Bundle Size](https://img.shields.io/bundlephobia/min/br-utils?label=bundle%20size)](https://bundlephobia.com/package/br-utils)\n[![Downloads Count](https://img.shields.io/npm/dm/br-utils.svg)](https://npmjs.com/package/br-utils)\n[![Test Status](https://img.shields.io/github/actions/workflow/status/LacusSolutions/br-utils-js/ci.yml?label=ci/cd)](https://github.com/LacusSolutions/br-utils-js/actions)\n[![Last Update Date](https://img.shields.io/github/last-commit/LacusSolutions/br-utils-js)](https://github.com/LacusSolutions/br-utils-js)\n[![Project License](https://img.shields.io/github/license/LacusSolutions/br-utils-js)](https://github.com/LacusSolutions/br-utils-js/blob/main/LICENSE)\n\n\u003e 🚀 **Full support for the [new alphanumeric CNPJ format](https://github.com/user-attachments/files/23937961/calculodvcnpjalfanaumerico.pdf).**\n\n\u003e 🌎 [Acessar documentação em português](https://github.com/LacusSolutions/br-utils-js/blob/main/packages/br-utils/README.pt.md)\n\nA JavaScript/TypeScript toolkit to handle the main operations with Brazilian-related data: CPF (personal ID) and CNPJ (employer ID). It exposes a unified API that wraps [`cpf-utils`](https://www.npmjs.com/package/cpf-utils) and [`cnpj-utils`](https://www.npmjs.com/package/cnpj-utils) in a single entry point.\n\n## Platform Support\n\n| ![Node.js](https://cdn.jsdelivr.net/gh/devicons/devicon/icons/nodejs/nodejs-original.svg) | ![Bun](https://cdn.jsdelivr.net/gh/devicons/devicon/icons/bun/bun-original.svg) | ![Deno](https://cdn.jsdelivr.net/gh/devicons/devicon/icons/denojs/denojs-original.svg) | ![Chrome](https://cdn.jsdelivr.net/gh/devicons/devicon/icons/chrome/chrome-original.svg) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![Firefox](https://cdn.jsdelivr.net/gh/devicons/devicon/icons/firefox/firefox-original.svg) | ![Safari](https://cdn.jsdelivr.net/gh/devicons/devicon/icons/safari/safari-original.svg) | ![Opera](https://cdn.jsdelivr.net/gh/devicons/devicon/icons/opera/opera-original.svg) | ![IE](https://cdn.jsdelivr.net/gh/devicons/devicon/icons/ie10/ie10-original.svg) |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- |\n| v16+ ✔ | v1.0+ ✔ | ⚠️ untested | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |\n\n## Features\n\n- ✅ **Unified API**: One default instance with `cpf` and `cnpj` sub-modules; each sub-module offers `format`, `generate`, and `isValid`\n- ✅ **Single entry point**: Install one package for both CPF ([demo](https://cpf-utils.vercel.app/)) and CNPJ ([demo](https://cnpj-utils.vercel.app/)) operations\n- ✅ **Reusable instance**: `BrUtils` class with optional default settings for the CPF and CNPJ utils (options or instances)\n- ✅ **Full re-exports**: All classes, options, errors, and types from `cpf-utils` and `cnpj-utils`\n- ✅ **TypeScript support**: Full type definitions and strict-mode compatible\n- ✅ **Error handling**: Same errors and exceptions as the underlying packages\n\n## Installation\n\n```bash\n# using NPM\n$ npm install --save br-utils\n\n# using Bun\n$ bun add br-utils\n```\n\n## Quick Start\n\n```ts\n// ES Modules — default instance\nimport brUtils from 'br-utils'\n\n// Or named exports (tree-shaking)\nimport { BrUtils, cpfUtils, cnpjUtils } from 'br-utils'\n\n// Common JS\nconst brUtils = require('br-utils')\n```\n\nBasic usage:\n\n```ts\n// CPF (personal ID)\nbrUtils.cpf.format('47844241055')           // '478.442.410-55'\nbrUtils.cpf.generate({ format: true })      // e.g. '478.442.410-55'\nbrUtils.cpf.isValid('123.456.789-09')      // true\n\n// CNPJ (employer ID)\nbrUtils.cnpj.format('03603568000195')      // '03.603.568/0001-95'\nbrUtils.cnpj.generate({ format: true })   // e.g. '03.603.568/0001-95'\nbrUtils.cnpj.isValid('98765432000198')    // true\n```\n\nFor legacy frontends, include the UMD build (e.g. minified) in a `\u003cscript\u003e` tag; `brUtils` is exposed globally:\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/br-utils@latest/dist/br-utils.min.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\n### `brUtils` (default instance)\n\nThe default export is a pre-built `BrUtils` instance. Use it for quick one-off calls:\n\n- **`cpf`**: Access the CPF utilities (`CpfUtils`). Use `brUtils.cpf.format()`, `brUtils.cpf.generate()`, `brUtils.cpf.isValid()` and the same options as in [cpf-utils](https://github.com/LacusSolutions/br-utils-js/tree/main/packages/cpf-utils#readme).\n- **`cnpj`**: Access the CNPJ utilities (`CnpjUtils`). Use `brUtils.cnpj.format()`, `brUtils.cnpj.generate()`, `brUtils.cnpj.isValid()` and the same options as in [cnpj-utils](https://github.com/LacusSolutions/br-utils-js/tree/main/packages/cnpj-utils#readme).\n\n### `BrUtils` (class)\n\nFor custom default CPF or CNPJ utils, create your own instance:\n\n```ts\nimport { BrUtils } from 'br-utils'\n\n// Default settings (all optional)\nconst utils = new BrUtils({\n  cpf: {\n    formatter: { hidden: true, hiddenKey: '#' },\n    generator: { format: true },\n  },\n  cnpj: {\n    formatter: { hidden: true },\n    generator: { type: 'numeric', format: true },\n  },\n})\n\nutils.cpf.format('47844241055')        // '478.###.###-##'\nutils.cpf.generate()                  // e.g. '005.265.352-88'\nutils.cnpj.format('03603568000195')   // '03.603.***/****-**'\nutils.cnpj.generate()                // e.g. '73.008.535/0005-06'\n\n// Access or replace internal instances\nutils.cpf   // CpfUtils\nutils.cnpj  // CnpjUtils\n```\n\n- **`constructor(defaultSettings?)`**: Optional `BrUtilsSettingsInput` — `cpf` and `cnpj` can each be a `CpfUtils` / `CnpjUtils` instance or an options object (`CpfUtilsSettingsInput` / `CnpjUtilsSettingsInput`). Omitted keys use default instances.\n- **`cpf`**: Getter/setter for the CPF utilities instance. Setter accepts `CpfUtils`, `CpfUtilsSettingsInput`, or `null`/`undefined` to reset to defaults.\n- **`cnpj`**: Getter/setter for the CNPJ utilities instance. Setter accepts `CnpjUtils`, `CnpjUtilsSettingsInput`, or `null`/`undefined` to reset to defaults.\n\n### Using the underlying helpers and re-exports\n\nYou can use the re-exported CPF and CNPJ helpers and classes directly:\n\n```ts\nimport {\n  cpfFmt,\n  cpfGen,\n  cpfVal,\n  CpfUtils,\n  cnpjFmt,\n  cnpjGen,\n  cnpjVal,\n  CnpjUtils,\n} from 'br-utils'\n\ncpfFmt('47844241055', { dashKey: '_' })   // '478.442.410_55'\ncpfGen({ prefix: '123456' })              // e.g. '12345678901'\ncpfVal('123.456.789-09')                  // true\n\ncnpjFmt('03603568000195', { slashKey: '|' })  // '03.603.568|0001-95'\ncnpjGen({ type: 'numeric' })                  // e.g. '65453043000178'\ncnpjVal('98.765.432/0001-98')                 // true\n```\n\nSee [cpf-utils](https://github.com/LacusSolutions/br-utils-js/blob/main/packages/cpf-utils/README.md) and [cnpj-utils](https://github.com/LacusSolutions/br-utils-js/blob/main/packages/cnpj-utils/README.md) for full option and error details.\n\n## API\n\n### Exports\n\n- **`brUtils`** (default): Pre-built `BrUtils` instance with `cpf` and `cnpj`; for CommonJS and UMD, the object also carries all re-exports from `cpf-utils` and `cnpj-utils`.\n- **`BrUtils`**: Class to create an instance with optional default CPF and CNPJ utils settings.\n- **`BrUtilsSettingsInput`**, **`BrUtilsSettingsType`**: Types for the constructor settings.\n- **CPF**: All exports from [cpf-utils](https://github.com/LacusSolutions/br-utils-js/tree/main/packages/cpf-utils#readme) (e.g. `cpfUtils`, `CpfUtils`, `cpfFmt`, `cpfGen`, `cpfVal`, formatter/generator/validator classes, options, errors, types).\n- **CNPJ**: All exports from [cnpj-utils](https://github.com/LacusSolutions/br-utils-js/tree/main/packages/cnpj-utils#readme) (e.g. `cnpjUtils`, `CnpjUtils`, `cnpjFmt`, `cnpjGen`, `cnpjVal`, formatter/generator/validator classes, options, errors, types).\n\n### Errors \u0026 Exceptions\n\nErrors and exceptions are the same as in `cpf-utils` and `cnpj-utils`. The `BrUtils` constructor and the `cpf`/`cnpj` setters can throw the same errors as the underlying package constructors. See each package’s README for the full list.\n\n## Contribution \u0026 Support\n\nWe welcome contributions! Please see our [Contributing Guidelines](https://github.com/LacusSolutions/br-utils-js/blob/main/CONTRIBUTING.md) for details. If you find this project helpful, please consider:\n\n- ⭐ Starring the repository\n- 🤝 Contributing to the codebase\n- 💡 [Suggesting new features](https://github.com/LacusSolutions/br-utils-js/issues)\n- 🐛 [Reporting bugs](https://github.com/LacusSolutions/br-utils-js/issues)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/LacusSolutions/br-utils-js/blob/main/LICENSE) file for details.\n\n## Changelog\n\nSee [CHANGELOG](https://github.com/LacusSolutions/br-utils-js/blob/main/packages/br-utils/CHANGELOG.md) for a list of changes and version history.\n\n---\n\nMade with ❤️ by [Lacus Solutions](https://github.com/LacusSolutions)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flacussolutions%2Fbr-utils-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flacussolutions%2Fbr-utils-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flacussolutions%2Fbr-utils-js/lists"}