Introduction
To match a Brazilian name reliably, normalize both sides before comparing them: remove accents, convert to the same case, drop particles such as "da", "de" and "dos", and then compare name tokens with rules for abbreviations and missing middle names. An exact string comparison between what the user typed and what the CPF (Brazil's individual taxpayer ID) lookup returns will reject many legitimate users.
This matters because name matching is the core of CPF verification. A lookup confirms that the number exists and tells you who holds it. Your code decides whether that holder is the person filling in the form.
Why Brazilian names break exact matching
Long names with several surnames
Most Brazilians carry more than one surname, often one from the mother and one from the father, and many have compound first names such as "Maria Eduarda" or "João Pedro". A full name with five or six words is common. Users rarely type all of them in a signup form. They type the name they use day to day.
Accents and the cedilla
Portuguese uses acute, circumflex and grave accents, the tilde and the cedilla: "José", "Antônio", "João", "Conceição". Users on foreign keyboards, or in a hurry, often leave them out. Some legacy systems store names without them. "JOAO" and "João" must count as the same token.
Particles
The connectors "da", "de", "do", "das", "dos" and "e" appear between name parts, as in "Fulano de Tal" or "Ana dos Santos e Silva". People drop them or add them freely, so they should not weigh in the comparison.
Abbreviations and suffixes
Middle names are often abbreviated ("Fulano T. de Tal"), and some names end in "Filho", "Júnior", "Neto" or "Sobrinho". A user may write "Jr." or leave the suffix out.
Social name
Brazil lets people use a social name (nome social) in many public services, which may differ from the civil name tied to the registry. If your product accepts a preferred name, keep it separate from the legal name field that you verify. Confirm with Brazilian counsel how your sector must handle social names.
A normalization pipeline that works
Normalize the typed name and the name returned by the API with the same function:
- Unicode normalization. Decompose characters with Unicode Normalization Form D and strip the combining marks, so "ã" becomes "a" and "ç" becomes "c".
- Case folding. Convert to uppercase or lowercase.
- Clean characters. Replace hyphens and apostrophes with spaces, collapse repeated spaces, trim.
- Remove particles. Drop "da", "de", "do", "das", "dos" and "e".
- Tokenize. Split on spaces.
In JavaScript, String.prototype.normalize handles step 1. In Python, the unicodedata module does the same.
Scoring the match instead of comparing strings
After normalization, compare tokens with simple rules:
| Rule | Example | Suggested treatment |
|---|---|---|
| First name must match | "Fulano" vs "Fulano" | Required |
| Last surname must match | "Tal" vs "Tal" | Required, or flag for review |
| Middle names may be missing | "Fulano Tal" vs "Fulano Silva de Tal" | Accept |
| Initial matches a full token | "S." vs "Silva" | Accept |
| Suffix present on one side only | "Fulano de Tal Filho" vs "Fulano de Tal" | Accept |
| Extra token absent from the registry | "Fulano Souza Tal" vs "Fulano de Tal" | Flag for review |
A practical outcome has three levels: match (continue), partial (ask the user to confirm the full name, or route to review) and no match (reject or escalate to a document check). Keep the thresholds in configuration so your risk team can tune them.
Avoid fuzzy distance alone as the rule. A small edit distance between "Fulano" and "Fulana" can mean a different person. Distance helps catch typos inside a token, but the token rules above should decide.
Example: matching against the Simple Lookup
The Simple Lookup of CPFHub.io returns name and nameUpper for a CPF. The call runs on your server, with the key read from an environment variable. Your frontend calls your own route and never sees the API key.
curl --max-time 10 \
-H "x-api-key: YOUR_API_KEY" \
-H "Accept: application/json" \
https://api.cpfhub.io/cpf/00000000000
// Server side only (Node.js 18+). The API key never reaches the browser.
const PARTICLES = new Set(['da', 'de', 'do', 'das', 'dos', 'e']);
const SUFFIXES = new Set(['filho', 'junior', 'jr', 'neto', 'sobrinho']);
function tokens(name) {
return name
.normalize('NFD')
.replace(/[̀-ͯ]/g, '')
.toLowerCase()
.replace(/[^a-z\s]/g, ' ')
.split(/\s+/)
.filter((t) => t && !PARTICLES.has(t) && !SUFFIXES.has(t));
}
function matchName(typed, registry) {
const a = tokens(typed);
const b = tokens(registry);
if (!a.length || !b.length) return 'no_match';
if (a[0] !== b[0]) return 'no_match';
if (a.at(-1) !== b.at(-1)) return 'partial';
// Every middle token typed must exist in the registry, in full or as an initial
const ok = a.slice(1, -1).every((t) =>
b.some((r) => r === t || (t.length === 1 && r.startsWith(t)))
);
return ok ? 'match' : 'partial';
}
async function verifyName(cpf, typedName) {
const res = await fetch(`https://api.cpfhub.io/cpf/${cpf}`, {
headers: { 'x-api-key': process.env.CPFHUB_API_KEY, Accept: 'application/json' },
signal: AbortSignal.timeout(10000),
});
if (res.status === 404) return { result: 'cpf_not_found' }; // no credit used
if (!res.ok) throw new Error(`Lookup failed with HTTP ${res.status}`);
const body = await res.json();
return { result: matchName(typedName, body.data.name) };
}
A CPF that is not found returns 404 and does not use a credit. Treat it as a separate outcome from a name mismatch, since it usually means a made-up number. Full field reference in the CPF lookup documentation.
Practical tips
- Store the normalized form next to the original. Show users the name as they typed it, and use the normalized version for comparisons and duplicate checks.
- Compare the date of birth too. A name match with a different date of birth is a stronger signal than either field alone.
- Do not show the registry name to the user. Displaying who holds a CPF to whoever types it leaks personal data. Return only the result of the match.
- Log the outcome, not the data. Record "match", "partial" or "no_match" for audits and keep personal data to what the LGPD (Brazil's data protection law) allows for your purpose.
- Escalate instead of blocking. A partial match is a good trigger for Identity Verification with document and selfie, rather than an outright rejection.
Frequently asked questions
Should I require users to type their full legal name?
You can ask for it, but expect many users to type a shorter version. A matching rule that accepts missing middle names keeps conversion high while still checking the first name and the last surname.
How do I handle names typed without accents?
Normalize both sides with Unicode decomposition and strip the combining marks before comparing. "JOAO" and "João" then become the same token.
Is fuzzy matching enough for Brazilian names?
Not on its own. Edit distance helps with typos inside a word, but it can accept a different person whose name differs by one letter. Use token rules first and distance only as a secondary signal.
What does the CPF lookup return for name matching?
The CPFHub.io Simple Lookup returns the holder's name (name and nameUpper), gender and date of birth. Compare the name and the date of birth with what the user typed on your server.
Read also
- How to Verify a Brazilian CPF Number
- How to Use a CPF Lookup API in Node.js
- Onboarding Brazilian Customers: A Fraud Prevention Checklist
- Brazil Identity Verification API: What Data You Can Get from a CPF
Conclusion
Brazilian names are long, accented and full of particles, so exact matching fails real users. Normalize both sides, ignore particles and suffixes, require the first name and the last surname, accept initials and missing middle names, and send partial matches to review instead of rejecting them.
Test your matching rules with 50 free credits and no credit card at cpfhub.io.
CPFHub.io
Ready to integrate the API?
50 free credits to test now. No credit card. Instant access to the documentation.




