WuseBox ← Back to tools

For developers, QA testers, and analysts

PESEL Generator

Generate valid Polish PESEL numbers with a chosen gender and date of birth, and use the decoder to read the birth date, gender, and check digit from any number. Everything runs locally in your browser.

Generate PESEL numbers

Validate and decode a PESEL

Paste a number to check its check digit and read the encoded data.

Important: This generator is intended for software development, testing (QA), and education only. The numbers are generated randomly according to publicly known rules and do not come from the PESEL register. A valid format and check digit do not rule out an accidental match with a real person's number - do not use generated data to identify people or in real transactions.

How a PESEL number is built and how to validate it

PESEL is the 11-digit Polish national identification number. It contains the date of birth, a serial number, a gender marker, and a check digit. Its structure is defined in Article 15(2) of the Polish Act on Population Records (ustawa o ewidencji ludności). Knowing these rules helps when you write form validators, prepare test data for systems that serve Polish users, or debug imports in which PESEL numbers end up in a database.

The generator above creates numbers that follow these rules, and the decoder shows how to read the birth date and gender from an existing number and how to calculate the check digit. If you also need Polish NIP, REGON, bank account, or ID card numbers, use the test data generator.

What each digit means

DigitsMeaningExample: 92031504785
1-2last two digits of the birth year92
3-4birth month with the century encoded03 - March, 1900-1999
5-6day of birth15
7-10serial number; the 10th digit encodes gender (even, including 0 - female, odd - male)0478 - 8 is even, so female
11check digit5

The example number was generated only for this explanation.

How the century is encoded in the month

Two digits of the year are not enough to tell someone born in 1905 from someone born in 2005. That is why the act encodes the century in the month number:

Birth yearsAdded to the monthMonths in the numberJuly written as
1800-18998081-9287
1900-1999001-1207
2000-20992021-3227

For example, 05270803625 belongs to a woman born on 8 July 2005: month 27 means July (27 - 20 = 7) in the years 2000-2099. Many descriptions and libraries also use 40 and 60 for 2100-2299, but the current text of the Act on Population Records does not include them, so this generator and decoder support the years 1800-2099.

The check digit step by step (weights 1-3-7-9)

The act only says that the 11th digit is a check digit. In practice, it is calculated with the weights 1, 3, 7, 9, 1, 3, 7, 9, 1, 3 applied to the first ten digits in order. For 9203150478_:

  1. Multiply each of the first ten digits by its weight: 9×1, 2×3, 0×7, 3×9, 1×1, 5×3, 0×7, 4×9, 7×1, 8×3.
  2. Add the products: 9 + 6 + 0 + 27 + 1 + 15 + 0 + 36 + 7 + 24 = 125.
  3. Take the last digit of the sum: 125 mod 10 = 5.
  4. Subtract it from 10: 10 - 5 = 5. If the last digit of the sum is 0, the check digit is also 0.

The check digit is 5, so the full number is 92031504785. The check digit catches any error in a single digit, but it does not confirm that the number has been issued to anyone. The decoder above shows the same calculation for any number you enter.

Validating and decoding a PESEL in code

Both functions check the format, the check digit, and whether the date exists, then return the birth date and gender. For an invalid number, they return null (JavaScript) or None (Python). They were tested on 100,000 numbers and give the same results as the decoder on this page.

JavaScript

function decodePesel(pesel) {
  if (!/^\d{11}$/.test(pesel)) return null;
  const weights = [1, 3, 7, 9, 1, 3, 7, 9, 1, 3];
  const sum = weights.reduce((total, weight, i) => total + weight * Number(pesel[i]), 0);
  if ((10 - (sum % 10)) % 10 !== Number(pesel[10])) return null;

  const centuries = { 80: 1800, 0: 1900, 20: 2000 };
  const encodedMonth = Number(pesel.slice(2, 4));
  for (const [offset, firstYear] of Object.entries(centuries)) {
    const month = encodedMonth - Number(offset);
    if (month < 1 || month > 12) continue;
    const year = firstYear + Number(pesel.slice(0, 2));
    const day = Number(pesel.slice(4, 6));
    const birthDate = new Date(Date.UTC(year, month - 1, day));
    if (birthDate.getUTCMonth() !== month - 1 || birthDate.getUTCDate() !== day) return null;
    return { birthDate, gender: Number(pesel[9]) % 2 === 1 ? "M" : "F" };
  }
  return null;
}

Python 3.10+

from datetime import date

WEIGHTS = (1, 3, 7, 9, 1, 3, 7, 9, 1, 3)
CENTURIES = {80: 1800, 0: 1900, 20: 2000}


def decode_pesel(pesel: str) -> dict | None:
    if len(pesel) != 11 or not (pesel.isascii() and pesel.isdigit()):
        return None
    total = sum(weight * int(digit) for weight, digit in zip(WEIGHTS, pesel))
    if (10 - total % 10) % 10 != int(pesel[10]):
        return None

    encoded_month = int(pesel[2:4])
    for offset, first_year in CENTURIES.items():
        if 1 <= encoded_month - offset <= 12:
            try:
                birth_date = date(first_year + int(pesel[:2]), encoded_month - offset, int(pesel[4:6]))
            except ValueError:
                return None
            return {"birth_date": birth_date, "gender": "M" if int(pesel[9]) % 2 else "F"}
    return None

The functions do not check whether the birth date is in the future. If your system requires that, compare the returned date with today's date.

Frequently asked questions (FAQ)

Does a generated PESEL belong to a real person?

The numbers are not taken from the PESEL register or assigned to specific people. They are generated randomly according to the PESEL structure and check digit rules, so they may coincide with an existing number by chance. Use them for testing only.

Why does a PESEL of someone born in 2005 have a month greater than 12?

For people born between 2000 and 2099, 20 is added to the month. Someone born in July 2005 has month 27 in their PESEL, while someone born in July 1905 has month 07.

Does a valid check digit mean the PESEL exists?

No. The check digit catches typos, but it does not confirm that the number has been issued to anyone. Only the PESEL register, which authorised institutions can access, can confirm that a number exists.

How many PESEL numbers can be issued for people born on the same day?

The serial number has four digits, and the last one encodes gender. That gives 5,000 possible numbers for women and 5,000 for men born on the same day.

Is the number I enter in the decoder sent anywhere?

No. The generator and decoder run entirely in your browser, and the number you enter is not sent to the WuseBox server or stored anywhere.

Use the tool ↑