1001Ferramentas
Validators

Brazilian Voter ID Validator

Validate Brazilian voter ID (Título de Eleitor) numbers using the official TSE algorithm. No data sent to servers.

How does Voter ID validation work?

What the TSE algorithm checks are digits 11 and 12, the two check digits. The first comes from the 8 sequential digits; the second, from the state code together with that first check digit. SP and MG follow a variation of the calculation.

All of the checking happens right in your browser.

Voter ID validation: the 8 + UF + DV structure

The Brazilian Titulo de Eleitor (voter registration card) is the document that authorizes a citizen to vote and is regulated by the Codigo Eleitoral (Law 4.737/1965). It is issued by the TSE (Tribunal Superior Eleitoral) through the 27 state TREs (Tribunais Regionais Eleitorais). Validating it client-side is a deterministic operation: the 12 digits include two modulo 11 check digits and a 2-digit UF code that limits which combinations are legal.

This page covers strict validation logic, the special SP / MG rule, the UF code table, regex pre-checks, library options and integration patterns. For generating synthetic voter IDs to seed a database, see the dedicated generator tool.

Anatomy: 8 sequence + 2 UF + 2 check digits

  • Digits 1 to 8: sequential number assigned by the TSE registry within the UF.
  • Digits 9 and 10: UF code (state of voter registration).
  • Digit 11: DV1, computed from the first 8 digits.
  • Digit 12: DV2, computed from the 2-digit UF code plus DV1.

DV1 and DV2 algorithm

Both check digits use modulo 11 with a special rule for SP (UF=01) and MG (UF=02): when the remainder is 0, the digit becomes 1 instead of 0. Other states keep the remainder.

function validateTituloEleitor(value) {
  const d = String(value).replace(/\D/g, '').padStart(12, '0');
  if (d.length !== 12 || /^(\d)\1+$/.test(d)) return false;
  const uf = d.slice(8, 10);
  if (uf < '01' || uf > '28') return false;
  const specialUF = uf === '01' || uf === '02';

  // DV1 from first 8 digits, weights 2..9
  let sum = 0;
  for (let i = 0; i < 8; i++) sum += Number(d[i]) * (i + 2);
  let dv1 = sum % 11;
  if (dv1 === 10) dv1 = 0;
  else if (dv1 === 0 && specialUF) dv1 = 1;
  if (dv1 !== Number(d[10])) return false;

  // DV2 from UF + DV1, weights 7,8,9
  const dv2Input = uf + String(dv1);
  let sum2 = 0;
  for (let i = 0; i < 3; i++) sum2 += Number(dv2Input[i]) * (i + 7);
  let dv2 = sum2 % 11;
  if (dv2 === 10) dv2 = 0;
  else if (dv2 === 0 && specialUF) dv2 = 1;
  return dv2 === Number(d[11]);
}

UF code table (digits 9 and 10)

The TSE encodes the state of registration as a 2-digit code:

01 SP   02 MG   03 RJ   04 RS   05 BA   06 PR   07 CE
08 PE   09 SC   10 GO   11 MA   12 PB   13 PA   14 ES
15 PI   16 RN   17 AL   18 MT   19 MS   20 DF   21 SE
22 AM   23 RO   24 AC   25 AP   26 RR   27 TO   28 Exterior

Code 28 covers voters registered abroad through Brazilian consulates. Any UF outside the 01-28 range is automatically invalid — a useful syntactic filter before the modulo 11 step.

The SP and MG special rule explained

When SP and MG started electronic registration in the 1970s, the TSE adopted a rule that prevents a check digit of 0 by forcing it to 1 instead. The motivation was operational: early printers rendered 0 and O indistinguishably, and validation kiosks confused them. The rule remains in the algorithm to this day. Validators that ignore it produce false negatives on perfectly legal SP and MG voter IDs.

Pre-validation regex and form mask

// 12 digits, allow optional separators
const TITULO_RE = /^\d{4}\s?\d{4}\s?\d{4}$/;
const clean = input.replace(/\D/g, '');
if (clean.length < 10 || clean.length > 12) return 'invalid length';
const padded = clean.padStart(12, '0');

The physical card shows the number in three groups of four digits separated by spaces. UI masks usually follow the same grouping for readability.

Libraries: JavaScript, Python, PHP

  • brazilian-values (npm): isTituloEleitor(value).
  • validation-br (npm): isTituloEleitor() and fakeTituloEleitor().
  • validate-docbr (PyPI): TituloEleitoral().validate(num).
  • geekcom/validator-docs (Laravel): 'titulo_eleitor' rule.

e-Titulo: the official digital voter ID

Since 2017 the TSE issues e-Titulo, an app available on iOS and Android. It carries a QR Code that contains the 12-digit number plus a TSE digital signature. When validating in the field, election officials scan the QR Code and the app cross-checks against the TSE server in real time, removing the need for the citizen to memorize the number. As of the 2024 election cycle, e-Titulo is the recommended format and biometric data is required for new registrations since 2020.

Where the voter ID still matters in 2026

  • Voting in federal, state and municipal elections (mandatory 18-70 years old).
  • Public procurement (CGU and TCU require certidao de quitacao eleitoral).
  • Civil service entry exams and federal scholarship programs.
  • Some banks accept it as a complementary ID alongside RG and CPF.
  • Social welfare registries (CadUnico, Bolsa Familia) accept it as optional supporting document.
  • Renewing a passport or applying for a CIN at federal police.

Cancellation: 3 missed elections without justification

Under Law 13.165/2015, a voter who fails to vote and fails to file a justification (online via e-Titulo or in person at a TRE) for three consecutive turns has the registration automatically cancelled. The number does not disappear — it remains in the TSE database — but it loses validity for any official use until the citizen requests regularizacao in person at a Cartorio Eleitoral, paying any pending fines.

FAQ

Is the voter ID always 12 digits? Yes, since the unification in the 1980s. Older 10-digit cards must be left-padded with zeros for validation.

Why do some SP and MG numbers end with DV=1 when the algorithm gives 0? Because of the special rule: when the modulo 11 remainder is 0 for UF=01 or 02, the digit is forced to 1.

Does the e-Titulo app replace the physical card? Yes, the TSE recognizes e-Titulo as the official digital version and accepts it at polling stations.

Is there an official TSE lookup API? Public access is very limited. Only the citizen, after logging in with CPF on the gov.br portal, can see their own registration data.

Can a person have more than one voter ID? No. Double registration is a crime under Article 350 of the Electoral Code and the TSE biometric system since 2020 actively detects and cancels duplicates.

Voter ID validator

The voter ID has check digits calculated by the TSE algorithm. Redoing that math confirms the number is well formed. The validator runs the official calculation and tells you right after whether the ID is mathematically valid.

You can use it to check a registration, validate a form or clean up a database that holds this document. The check verifies the number's structure and digits, catching typos, without touching the TSE base, which isn't public.

The whole validation happens in the browser, with no data sent to servers. It's free and private, and nothing you type leaves your device.

Related Tools