Civil registry certificate
The 32-digit matrícula of a certidão de registro civil (birth, marriage, death and the other acts of the registro civil das pessoas naturais).
Validate
- JavaScript library
- Python library
- Go library4 cases fail
- Ruby library4 cases fail
- Rust library4 cases fail
- .NET library
- Erlang library
Validates the 32-digit matrícula of a certidão de registro civil (art. 473 of the Código Nacional de Normas da Corregedoria Nacional de Justiça).
- Layout: CNS da serventia (6), acervo (2), serviço (2, always
55), ano (4), tipo do livro (1), livro (5), folha (3), termo (7) and 2 modulus 11 check digits. - The serviço must be
55. The book type must be 1 to 7 (the books of art. 473 V) or 8 (emancipation, Livro E split for emancipações) or 9 (interdiction, Livro E split for interdições), which come from the revoked Provimento CNJ 3/2009, art. 7º V, and are kept because certidões issued under it from 2010 still carry them. The function rejects0, whatever the check digits. options.acceptlimits the valid book types to the listed ones (default: every type).- Accepts the value unmasked or masked. Between the nine groups (6 2 2 4 1 5 3 7 2) any run of whitespace,
.,-or/is allowed, and whitespace around the value is ignored; another separator (#), a letter, or digits grouped differently make the value invalid. - No official source publishes the check-digit algorithm. Art. 473 IX only names the check digits (positions 31 and 32). Provimento CNJ 3/2009 had them generated by a program the CNJ gave to the registrars, and the Caixa's Cadastro NIS layout says only "módulo 11". The modulus 11 weights and remainder rule (a remainder of 10 is read as 1) follow community reference implementations.
- Only a string is accepted. The 32 digits of a matrícula do not fit a number.
options.acceptis a list of book types (birth,marriage,religious-marriage,death,stillbirth,banns,other,emancipation,interdiction). When it is missing or not a list, every type is accepted. An empty list accepts none, so the result isfalse.
| Parameter | Type | Required |
|---|---|---|
value | string | yes |
options | IsValidCertidaoOptions | no |
options.accept | CertidaoType[] | no |
| returns | boolean |
Check if the matrícula of a certidão de registro civil (birth, marriage, death and the other acts of a registro civil das pessoas naturais) is valid. Only a string is accepted: the 32 digits of a matrícula are more than a JavaScript number can hold.
The matrícula has 32 digits, printed as 000000 00 00 0000 0 00000 000 0000000 00:
| Digits | Field |
|---|---|
| 6 | CNS da serventia |
| 2 | acervo |
| 2 | serviço, always 55 |
| 4 | ano |
| 1 | tipo do livro |
| 5 | livro |
| 3 | folha |
| 7 | termo |
| 2 | dígitos verificadores |
- Options (
IsValidCertidaoOptions):acceptnarrows the valid book types (CertidaoType) to the listed ones (default: every type). - The serviço must be
55, and the book-type digit one of the codes 1 to 9: 1 to 7 are the books of art. 473, V (Provimento CNJ nº 149/2023, redação of the Provimento CN nº 182/2024); 8 ("emancipation", Livro E desdobrado for emancipações) and 9 ("interdiction", Livro E desdobrado for interdições) come from the Provimento CNJ nº 3/2009, art. 7º, revoked by the Provimento CNJ nº 63/2017, and are kept so the certidões issued under it from 2010 on still validate.0is rejected. - Accepts the value masked or not, with whitespace between and around the groups.
- No official document publishes the check digit algorithm: art. 473, IX only names the two digits, the revoked Provimento CNJ nº 3/2009 had them computed by a program the CNJ handed to the registrars, and the Caixa's Cadastro NIS layout says only "módulo 11". The weights and the remainder rule follow the community references below.
import { isValidCertidao } from '@brazilian-utils/brazilian-utils';
isValidCertidao('104539 01 55 2013 1 00012 021 0000123 21'); // true
isValidCertidao('09430001552010100020112000012087'); // true
isValidCertidao('104539 01 55 2013 1 00012 021 0000123 22'); // false (invalid check digits)
isValidCertidao('09400301542011100110002005191744'); // false (serviço is not 55)
isValidCertidao('10453901552013900012021000012398'); // true (book code 9, Provimento CNJ nº 3/2009)
isValidCertidao('10453901552013000012021000012387'); // false (book code 0 names no book)
isValidCertidao('123456'); // false (wrong length)
isValidCertidao('104539 01 55 2013 1 00012 021 0000123 21', { accept: ['birth'] }); // true
isValidCertidao('104539 01 55 2013 1 00012 021 0000123 21', { accept: ['death'] }); // falseSource: art. 473 of the Código Nacional de Normas da Corregedoria Nacional de Justiça; check digits per ghiorzi.org and validation-br.
Code: brazilian-utils/javascriptTry it with JavaScript isValidCertidao
Shared test cases (37) and the result in each library certidao.isValid
Format
- JavaScript library
- Python library
- Go library
- Ruby library5 cases fail
- Rust library
- .NET library2 cases fail
- Erlang library
Formats the matrícula of a certidão de registro civil into the printed mask of art. 473 of the Código Nacional de Normas. The mask groups the 32 digits as 6 2 2 4 1 5 3 7 2, separated by spaces.
- The function applies the mask as far as the digits go, so a partial matrícula being typed is masked progressively, and digits beyond the 32nd are dropped.
options.padleft-pads with zeros to 32 digits first. - A full 32-digit matrícula does not fit an integer, so you must give it as a string.
- 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 even with
options.pad. Until 2.4.0 it returned the full zero mask. options.paddefaults tofalse.
| Parameter | Type | Required |
|---|---|---|
value | string | number | yes |
options | FormatCertidaoOptions | no |
options.pad | boolean | no |
| returns | string |
Format the matrícula of a certidão de registro civil into the printed mask of art. 473. The 32 digits are grouped as 6 2 2 4 1 5 3 7 2 and separated by spaces.
- Options (
FormatCertidaoOptions):padleft-pads the value with zeros up to 32 digits (defaultfalse). An empty value, or one without digits, gives''even withpad. - A number is accepted when it is a non-negative safe integer, so a full 32-digit matrícula has to be a string. Any other number returns
''.
import { formatCertidao } from '@brazilian-utils/brazilian-utils';
formatCertidao('10453901552013100012021000012321'); // '104539 01 55 2013 1 00012 021 0000123 21'
formatCertidao('104539.01.55.2013.1.00012.021.0000123-21'); // '104539 01 55 2013 1 00012 021 0000123 21'
formatCertidao('1552010100020112000012087', { pad: true }); // '000000 01 55 2010 1 00020 112 0000120 87'
formatCertidao(104539015520); // '104539 01 55 20' (a number is read as the string of its digits)
formatCertidao(1045390155.2); // '' (not a non-negative safe integer)Source: art. 473 of the Código Nacional de Normas.
Code: brazilian-utils/javascriptTry it with JavaScript formatCertidao
Shared test cases (13) and the result in each library certidao.format
Parse
- JavaScript library
- Python library
- Go library
- Ruby library2 cases fail
- Rust library
- .NET library1 case fails
- Erlang library
Removes the formatting of a certidão matrícula and keeps only digits, capped at 32 digits.
- A value shorter than 32 digits passes through as far as it goes, so the mask of an input still being typed can be stripped. Nothing is padded.
- 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).
| Parameter | Type | Required |
|---|---|---|
value | string | number | yes |
| returns | string |
Remove the formatting of the matrícula of a certidão de registro civil, keep only digits, and cap the result to 32 digits.
import { parseCertidao } from '@brazilian-utils/brazilian-utils';
parseCertidao('104539 01 55 2013 1 00012 021 0000123 21');
// '10453901552013100012021000012321'Try it with JavaScript parseCertidao
Shared test cases (8) and the result in each library certidao.parse
Decode
- JavaScript library
- Python library
- Go library1 case fails
- Ruby library5 cases fail
- Rust library
- .NET library1 case fails
- Erlang library
Parses the matrícula of a certidão de registro civil into its fields. Returns null when it is not valid (same rules as certidao.isValid).
typeis the English name of the book (birth,marriage,religious-marriage,death,stillbirth,banns,other,emancipation,interdiction). Fields: CNS of the serventia (6 digits), acervo, service (always55), year, book type (birth, marriage, religious marriage, death, stillbirth, banns, other, emancipation, interdiction) and its raw code 1 to 9, book, page, term and the 2 check digits.yearandtypeCodeare numbers.registryCns,acervo,service,book,page,termandcheckDigitsare strings that keep their leading zeros. The input is read likecertidao.isValidreads it, so a masked value works and a non-string returnsnull.- Art. 473 V of the Código Nacional de Normas lists book codes 1 to 7. Codes 8 (emancipação) and 9 (interdição) come from Provimento CNJ 3/2009, art. 7º V. That provimento was revoked by Provimento CNJ 63/2017, but certidões issued under it from 2010 carry those codes and are still valid, so both are read, as in 2.4.0.
acervois01for the serventia's own acervo and02and up for each acervo it absorbed. Art. 473, §§ 3º to 5º split the absorbed ones by the date the origin serventia was extinguished or deactivated. Up to 31/12/2009 the CNS is the incorporating unit's and the acervo code runs from02, one per incorporation. From 01/01/2010 the CNS is the incorporated unit's own and the code is01, counted as that unit's own acervo. An acervo split between two or more successor serventias gets each successor's CNS with the code02.
| Parameter | Type | Required |
|---|---|---|
value | string | yes |
| returns | CertidaoInfo | null |
Parse the matrícula of a certidão de registro civil into its fields. Accepts the same input forms as isValidCertidao and returns null when the matrícula is not valid.
- Returns
nullalso for a serviço other than55and for the book code0. - Art. 473, V lists the book codes 1 to 7, from "1: Livro A (Nascimento)" to "7: Livro E (Demais atos relativos ao registro civil)". The codes 8 (emancipação) and 9 (interdição) of the Provimento CNJ nº 3/2009, art. 7º, revoked by the Provimento CNJ nº 63/2017, are not in it but are still read, as
"emancipation"and"interdiction", since the certidões issued under it from 2010 on carry them and remain valid documents.
The CertidaoInfo result carries:
| Key | Description |
|---|---|
registryCns | The 6 digit CNS (Código Nacional de Serventia) of the serventia that issued the act. |
acervo | Acervo the book belongs to: "01" the serventia's own, "02" and up one per acervo it absorbed. Art. 473, §§ 3º to 5º splits the absorbed ones by the date the origin serventia was extinguished or deactivated. Up to 31/12/2009: the CNS of the incorporating unit and an acervo code from "02" up, one per incorporation. From 01/01/2010 on: the CNS of the incorporated unit itself and the code "01", counted as that unit's own acervo. An acervo split between two or more successor serventias gets each successor's own CNS with the code "02". |
service | Service rendered by the serventia, always "55", the registro civil das pessoas naturais. |
year | Four digit year the act was recorded. |
type | The book the act belongs to: "birth", "marriage", "religious-marriage", "death", "stillbirth", "banns", "other", or, for the codes 8 and 9 of the Provimento CNJ nº 3/2009, "emancipation" and "interdiction". |
typeCode | Raw book code, 1 to 9, as printed in the fifteenth position of the matrícula. |
book | The 5 digit book (livro) number, zero padded. |
page | The 3 digit page (folha) number, zero padded. |
term | The 7 digit term (termo) number, zero padded. |
checkDigits | The 2 modulus 11 check digits of the matrícula. |
import { getCertidaoInfo } from '@brazilian-utils/brazilian-utils';
getCertidaoInfo('104539 01 55 2013 1 00012 021 0000123 21');
// {
// registryCns: '104539',
// acervo: '01',
// service: '55',
// year: 2013,
// type: 'birth',
// typeCode: 1,
// book: '00012',
// page: '021',
// term: '0000123',
// checkDigits: '21'
// }
getCertidaoInfo('invalid'); // nullSource: art. 473 of the Código Nacional de Normas da Corregedoria Nacional de Justiça; book codes 8 and 9 per the revoked Provimento CNJ nº 3/2009, art. 7º, still listed by ghiorzi.org and validation-br.
Code: brazilian-utils/javascriptTry it with JavaScript getCertidaoInfo
Shared test cases (10) and the result in each library certidao.getInfo
Official sources
Last updated on
