JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 70
  • Score
    100M100P100Q72967F
  • License MIT

Utility function to generate valid CNPJ (Brazilian employer ID)

Package Exports

  • @lacussoft/cnpj-gen

Readme

Lacus :: cnpj-gen

NPM Latest Version Bundle Size Downloads Count Test Status Last Update Date Project License

Utility function to generate valid CNPJ (Brazilian employer ID).

Browser Support

Chrome Firefox Safari Opera Edge IE
Latest ✔ Latest ✔ Latest ✔ Latest ✔ Latest ✔ 11 ✔

Installation

# using NPM
$ npm install --save @lacussoft/cnpj-gen

# using Bun
$ bun add @lacussoft/cnpj-gen

Import

// ES Modules
import cnpjGen from '@lacussoft/cnpj-gen'

// Common JS
const cnpjGen = require('@lacussoft/cnpj-gen')

or import it through your HTML file, using CDN:

<script src="https://cdn.jsdelivr.net/npm/@lacussoft/cnpj-gen@latest/dist/cnpj-gen.min.js"></script>

Usage

let cnpj = cnpjGen()   // returns '65453043000178'

cnpj = cnpjGen({       // returns '73.008.535/0005-06'
  format: true
})

cnpj = cnpjGen({       // returns '45623767000296'
  prefix: '45623767'
})

cnpj = cnpjGen({       // returns '45.623.767/0002-96'
  prefix: '456237670002',
  format: true
})

Generator options

cnpjGen({
  format: false, // indicates if output should be formatted
  prefix: ''     // if you have a CNPJ initials and want to complete it with valid
})               //   digits. The string provided must contain between 1 and 12 digits!

Contribution & Support

We welcome contributions! Please see our Contributing Guidelines for details. But if you find this project helpful, please consider:

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

See CHANGELOG for a list of changes and version history.


Made with ❤️ by Lacus Solutions