Privacy and Security

Latvian Personal Codes: Old Format, New Format and Validation

How Latvian personal codes work: the old DDMMYY-CNNNC format with a check digit, the anonymous codes starting with 32 since 2017 and how to accept both.

Saizul Amin
Saizul Amin29 Oct 2026 · 3 min read
Latvian Personal Codes: Old Format, New Format and Validation

Latvian Personal Codes: Old Format, New Format and Validation

Latvia is one of the few countries that has already moved to anonymous personal codes. Since July 2017, new codes reveal nothing about the person, while older codes still contain the date of birth. Systems built for the old format often break on the new one. The Latvia Personal Code Validator handles both; this guide explains the difference.

The old format

Codes issued until 30 June 2017 look like DDMMYY-CNNNC:

  • DDMMYY: date of birth.
  • C: century: 0 for the 1800s, 1 for the 1900s, 2 for the 2000s.
  • NNN: serial number.
  • Last digit: check digit.

The old check digit

Multiply the first ten digits by 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 and add the products. The check digit is (1101 minus the sum) modulo 11. For 161175-1999, the check digit is 7, so 161175-19997 is valid: born on 16 November 1975.

The new format

From 1 July 2017, newly issued codes have the form 32XXXX-XXXXX:

  • they start with 32,
  • the remaining digits carry no date of birth or other personal data.

People with old codes could apply to change to a new-format code, and many did for privacy reasons. As a result, a person's age cannot be derived from every Latvian code.

Why systems break

Software written before 2017 often:

  • tries to read a date of birth from every code and rejects 32 codes as invalid dates,
  • calculates age from the code for discounts or age checks,
  • applies the old check digit to new codes.

The fix is simple: accept codes that start with 32 as new-format codes without date checks, and ask for the date of birth in a separate field when it is needed.

Where personal codes are used

Identity cards and passports, the State Revenue Service, the State Social Insurance Agency, healthcare, banks and the eParaksts electronic signature.

Privacy

Old codes reveal the date of birth; all codes are personal data. Latvian law encouraged the move to anonymous codes partly to reduce misuse. The validator runs in your browser, so lists are not uploaded.

Foreigners

Foreign residents receive personal codes from the Office of Citizenship and Migration Affairs. Since 2017, these are issued in the new format.

A worked example

161175-19997 is a valid old code for someone born on 16 November 1975. 321010-25036 is a new-format code: it starts with 32 and carries no date of birth, so the validator only checks its format.

Using the validator

Paste codes one per line. The tool identifies the format, checks old codes with the check digit and date, and lists new codes as new format. Export the results as CSV.

Practical checklist for developers

  • Accept 11 digits with or without the hyphen.
  • If the code starts with 32, treat it as new format: no date, no check digit test.
  • Otherwise, check the date, the century digit and the check digit.
  • Never compute age or sex from the personal code.
  • Store the code as text, not as a number.

Data protection

The State Data Inspectorate oversees the processing of personal codes. Organisations should explain why they need the code and keep it only as long as necessary.

Companies in Latvia

Latvian companies have an 11-digit registration number starting with 4 or 5 for most entities, and the VAT number is LV plus that number. It is a different identifier from the personal code and should be stored in its own field. Mixing the two in one field is a frequent source of errors in customer databases.

Limits

The tool does not confirm that a code was issued. The Population Register is the authority. This guide is general information.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages