Generator · Polish data

Polish passport number

Endpoint GET /v1/pl/passport

What it covers

Returns a valid Polish passport number (numer paszportu) with a correct checksum. Use `format` to choose between compact and space-separated rendering. Set `invalid=true` to get a passport number with a deliberately wrong check digit, for testing checksum validators.

How it’s calculated

A single decimal check digit sits at position 3 of the nine-character passport number (right after the two series letters); it is chosen so the weighted sum over all nine characters, with letters valued A=10…Z=35, is congruent to 0 modulo 10.

Algorithm

  1. A Polish passport number has nine characters: two uppercase series letters, then seven digits. Positionally (zero-based) that is [L1, L2, C, d3, d4, d5, d6, d7, d8], where C at index 2 is the check digit and d3..d8 are the six remaining digits.
  2. Assign each of the nine positions a fixed weight from the vector [7, 3, 9, 1, 7, 3, 1, 7, 3] (index 0 through 8). Note the check position (index 2) carries weight 9.
  3. Convert each character to a numeric value: an uppercase letter A–Z maps to 10–35 (value = codePoint - codePoint('A') + 10, i.e. A=10, B=11, …, Z=35); a digit 0–9 maps to its own numeric value. Any other character is an error.
  4. To find the check digit, try each candidate c from 0 to 9. For each candidate, place c at index 2 and compute the weighted sum: sum over all nine positions of weight[index] * characterValue(character at that index).
  5. The correct check digit is the candidate c for which the weighted sum is congruent to 0 modulo 10. Exactly one such digit exists because the check position's weight (9) is coprime with 10.
  6. Equivalently and directly: let S = the weighted sum of the eight non-check positions (the two letters and the six trailing digits, using their own weights). Then choose C so that (S + 9*C) mod 10 == 0, i.e. solve 9*C ≡ (-S) mod 10.
  7. Emit the number as the two series letters, the check digit, then the six trailing digits: e.g. AA C d3 d4 d5 d6 d7 d8 (nine characters total).

Worked example

Passport series AB, trailing digits 123456, check digit ? → AB?123456

Nine-character layout with placeholder at the check position: A, B, C, 1, 2, 3, 4, 5, 6 (indices 0..8).
Weights by index: [7, 3, 9, 1, 7, 3, 1, 7, 3].
Character values: A=10, B=11, then digits 1,2,3,4,5,6 keep their own values.
Weighted contributions of the eight non-check positions: A(10)*7=70; B(11)*3=33; d3=1*1=1; d4=2*7=14; d5=3*3=9; d6=4*1=4; d7=5*7=35; d8=6*3=18.
Sum of non-check contributions S = 70+33+1+14+9+4+35+18 = 184.
Check position weight is 9, so we need (184 + 9*C) mod 10 == 0. Since 184 mod 10 = 4, we need (4 + 9*C) mod 10 == 0, i.e. 9*C ≡ 6 (mod 10).
Scanning C=0..9: C=4 gives 9*4=36 ≡ 6 (mod 10). Total = 184 + 36 = 220, and 220 mod 10 = 0. So C = 4.
No smaller candidate works: C=0→184(4), C=1→193(3), C=2→202(2), C=3→211(1), C=4→220(0) ✓.

The check digit is 4, giving the full passport number AB4123456 (compact) or AB 4123456 (with space).

Edge cases

  • The check digit is not appended at the end — it is the third character of the nine-character string, immediately after the two series letters (zero-based index 2).
  • Both series letters participate in the checksum with their alphabetic values (A=10 … Z=35), not just the digits, so the two leading letters affect the required check digit.

Gotchas

  • characterValue throws on any character that is not an uppercase A–Z letter or a single digit, so malformed input fails fast rather than silently producing a wrong sum.
  • Because the check position's weight (9) is coprime with 10, exactly one check digit in 0–9 satisfies the mod-10 congruence; the generator finds it by a simple 0–9 scan rather than a closed-form complement.
  • The mod-10 rule means the full weighted sum (including the check digit) is ≡ 0 mod 10 — there is no 10-minus-remainder complement step and no residue that maps to a non-digit, so every position is always fillable with a plain 0–9 digit.

Parameters

ParameterTypeDescription
countinteger1–1000Number of records to return, 1–1000 (your plan may lower this). Omitted returns a single record; set it for a batch.
edgebooleanRestrict output to edge-case passports from the rare corners.
extremebooleanReturn a correct value wrapped in a hostile encoding (untrimmed whitespace, invisible/zero-width characters, BOM, or bidi/combining marks). Homoglyphs are excluded so the value stays machine-parseable; it still validates after normalisation.
format"compact" | "with-space"Passport-number rendering: compact or with a space. Default compact.
invalidbooleanReturn a number with a deliberately wrong check digit.
seedintegerInteger seed for reproducible output: the same seed always yields the same record.

Response fields

FieldTypeDescription
valuestringThe passport number in the requested format.
seriesstringThe two uppercase series letters, e.g. "AA".
numberstringThe seven digits including the check digit, e.g. "1234567".

Other generators for Poland

See all generators for Poland →

The same kind of identifier elsewhere

Try it

Generate a live example below — every response is valid by format and entirely synthetic.