Package Exports
- @lacussoft/cnpj-gen
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lacussoft/cnpj-gen) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
LacusSoft :: cnpj-gen
Basic function to generate valid CNPJ (Brazilian ID document).
Browser Support
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |
Installation
$ npm install @lacussoft/cnpj-genImport
// 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!




