PIS/PASEP
The PIS/PASEP/NIT worker registration number (PIS: Programa de Integração Social).
Validate
- JavaScript library
- Python library6 cases fail
- Go library5 cases fail
- Ruby library5 cases fail
- Rust library5 cases fail
- .NET library5 cases fail
- Erlang library6 cases fail
Validates a PIS/PASEP/NIT: 10 base digits and a modulus 11 check digit.
- No official source publishes the check-digit weights. The eSocial MOS gives 11 digits with the check digit, and the SIRC manual says the check digit uses modulus 11; the Caixa layouts ask only for a "Número de PIS/PASEP válido". The weights follow a community reference (brutils).
- The function ignores whitespace and the characters
.,-,/,(,),,and*, in any number and position. Any other character makes the value invalid. Exactly 11 digits are required once they are removed, and the check digit must match. - The check-digit weights are 3, 2, 9, 8, 7, 6, 5, 4, 3 and 2 over the first 10 digits, with modulus 11.
- Only a string is read. Any other type returns
false.
Pending decision
The reference (JS) rejects a value whose digits are all the same as a reserved number. The other libraries accept them when the check digit matches. See the open decision in docs/findings.md.
Pending decision
The reference (JS) ignores those formatting characters and whitespace. Other libraries accept digits only. See the open decision in docs/findings.md.
| Parameter | Type | Required |
|---|---|---|
pis | string | yes |
| returns | boolean |
Check if a PIS is valid. Accepts the value masked or not.
- A value whose digits are all the same is rejected.
- The check digit uses the weights 3, 2, 9, 8, 7, 6, 5, 4, 3 and 2 and módulo 11. No official document found publishes them: the eSocial and SIRC manuals say only that the number has 11 digits and a módulo 11 check digit, and the Caixa layouts ask for a "Número de PIS/PASEP válido" without saying how it is computed. The weights follow brutils.
import { isValidPis } from '@brazilian-utils/brazilian-utils';
isValidPis('12056412847'); // true
isValidPis('12056412547'); // falseTry it with JavaScript isValidPis
Shared test cases (31) and the result in each library pis.isValid
Format
- JavaScript library
- Python library54 cases fail
- Go library30 cases fail
- Ruby library55 cases fail
- Rust library31 cases fail
- .NET library31 cases fail
- Erlang library54 cases fail
Formats a PIS as 000.00000.00-0.
options.padleft-pads the value with zeros to 11 digits first.options.obfuscate(defaultfalse) hides the first 3 digits and the check digit with*, after padding:***.45678.90-*. It works withpadand on a partial value. Likepad, it is read for truthiness: a non-boolean such as1hides the digits too, and0does not.- No authority publishes a masking rule for the PIS. The rule is an analogy with the one the Leis de Diretrizes Orçamentárias set for publishing a CPF ("ocultar os três primeiros dígitos e os dois dígitos verificadores", Lei nº 12.309/2010, art. 87, § 5º, repeated up to the LDO 2026, Lei nº 15.321/2025, art. 163), not a published norm.
cns.formatandpassport.formathave noobfuscateoption.- A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number returns an empty string (2.4.0 read the digits of any number, sign and decimal point dropped).
- A value with no digits (empty, or only letters and symbols) returns an empty string even with
options.pad. Until 2.4.0padreturned the full zero mask (000.00000.00-0). - Digits after the 11th are dropped.
Pending decision
The reference (JS) formats only the characters an incomplete value has and returns an empty string for empty or invalid input. Other libraries return null. See the open decision in docs/findings.md.
| Parameter | Type | Required |
|---|---|---|
value | string | number | yes |
options | FormatPisOptions | no |
options.pad | boolean | no |
options.obfuscate | boolean | no |
| returns | string |
Format a PIS.
- Options (
FormatPisOptions):padleft-pads the value with zeros to 11 digits before masking (defaultfalse);obfuscatehides the first 3 digits and the check digit. An empty value, or one without digits, gives''even withpad. obfuscateis applied afterpad.- No authority publishes a masking rule for the PIS, so
obfuscateapplies the one the Leis de Diretrizes Orçamentárias set for publishing a CPF ("ocultar os três primeiros dígitos e os dois dígitos verificadores", Lei nº 14.194/2021, art. 149, first set by Lei nº 12.309/2010, art. 87, § 5º), a number with the same structure.
import { formatPis } from '@brazilian-utils/brazilian-utils';
formatPis('12345678901'); // 123.45678.90-1
formatPis('123456789', { pad: true }); // 001.23456.78-9
formatPis('12345678901', { obfuscate: true }); // ***.45678.90-*Try it with JavaScript formatPis
Shared test cases (70) and the result in each library pis.format
Parse
- JavaScript library
- Python library
- Go library
- Ruby library1 case fails
- Rust library
- .NET library
- Erlang library
Removes PIS formatting and keeps only digits, capped at 11 digits (the digits after the 11th are dropped).
- A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number returns an empty string (2.4.0 read the digits of any number, sign and decimal point dropped).
- A value with no digits returns an empty string.
| Parameter | Type | Required |
|---|---|---|
value | string | number | yes |
| returns | string |
Remove PIS formatting, keep only digits, and cap the result to 11 digits.
import { parsePis } from '@brazilian-utils/brazilian-utils';
parsePis('123.45678.90-1'); // 12345678901Try it with JavaScript parsePis
Shared test cases (18) and the result in each library pis.parse
Generate
Generates a valid random PIS: 11 digits, unformatted.
- No official source publishes the check-digit weights. The eSocial MOS gives 11 digits with the check digit, and the SIRC manual says the check digit uses modulus 11; the Caixa layouts ask only for a "Número de PIS/PASEP válido". The weights follow a community reference (brutils).
| Parameter | Type | Required |
|---|---|---|
| returns | string |
Generate a valid random PIS.
import { generatePis } from '@brazilian-utils/brazilian-utils';
generatePis(); // '91077906857'Source: Lei nº 14.194/2021, art. 149, the CPF masking rule obfuscate borrows, first set by Lei nº 12.309/2010, art. 87, § 5º and repeated by the later LDOs (Lei nº 15.321/2025, art. 163, the one for 2026, repeats it).
Try it with JavaScript generatePis
Shared test cases (1) and the result in each library pis.generate
Official sources
- gov.br/inss/pt-br/…/inscricao
- gov.br/esocial/pt-br/…/mos-manual-de-orientacao-do-esocial-vs-2-4.pdf
- sirc.gov.br/wp-content/uploads/…/manual_sirc_recomendacoes_tecnicas_v7.pdf
- caixa.gov.br/Downloads/fgts-grrf-aplicativo-arquivos/…/Leiaute_Folha_Pgto_GRRF_v204.pdf
- planalto.gov.br/ccivil_03/_ato2007-2010/…/l12309.htm
- planalto.gov.br/ccivil_03/_ato2023-2026/…/L15321.htm
Last updated on
