Swedish personal number generator

Version per: 2022-02-23 Revision history:
- bug fix for generated Luhn checksum.

- Added overflow management to output.

- Implemented duplicate check for generated personnummers.
- Refactor of person creation into new function.
- Added note discouraging from use of Personnummer for gender classification.
- Added promotion link to Organisationsnummer generator.
- Added JSON and XML result export buttons.

- Added backlog item for generation count validation.

- Queries to SKV now stops if no more records returned.
- Refactored generate() function heavily.
- Improved some copys (=texts).
- Included this version history and backlog.
- Bugfixes for unchecked Personnummer display checkbox.
- Expandable/colapsable info text to create ease of overview of the utility.
- Inserted promotion links to other test data generators.
- Show/close tooltip on click for use on touch devices.
- Substituted all element titel attributes with proper tooltips.
- Removed ugly single quotation marks around tooltip for result set PNR heading.
- Center page content as beautification.
. Clarified that randomization is at generation, not for full result set.
- Bug fix for bug where clicked tooltip text renders tooltip un-usable.
- Changed format dropdown to radiobuttons to decrease visual complexity.
- Included query for Samverkansnummer in SKV result set.
- Export mechanism for CSV

- Initial version created and published.

* Make click on circled I tooltip icons not change checkbox status/value.
* Buttons to set date values for often-used ages (18 minus one day, 18 plus one day, 26, 65).
* Make saving settings to browser local storage possible for ease of use.
* Create (separate) gateway API with extended query parameters (dates, gender) for Skatteverket Personnummer API.
* Results from SKV populated to results as they are accepted, not after query.
* Enable use of known seed for randomization engine for robustly re-generated test data.
* Fix bug with needing two clicks for text expand.
* Center generated data result set data presentation.
* Identify limit for generation count and introduce validation.
* Include query for gender in SKV result set.
* Append more names to name lists.
* Refactor person presentation from person generation, re-use of createPerson() with SKV-results.
* Include support for Reservnummer (as used in medical emergency).

What's this?

A lot of times you'll need to use personal identification numbers for testing.
This generator gets you faked Swedish personal identification numbersKnown by the name of 'Personnummer' to ease your testing.

Use of Personnummer (Personal Identification Number)

Swedish personal identification numbers are widely used throughout the society to identify people. It works much like the social security number in the USA. The Swedish personal identification number consist of the date you are born, followed by three identification digits (the third identification number is odd for people identified as male at birth, and even for women) and a trailing checksum from the Luhn algorithm (based on six number date format and the three identification numbers).


Most of the time the personal identification numbers are used with 10 digits; six for birth date and the four last digits for identification and checksum. Since a two-number birth year representation would make it possible to confuse people older than 100 years with young people with the same two-number birth year representation some means of distinction between these are sometimes required. The official way of doing this is by substituting the regular dash between the birth date and the four trailing digits with a plus sign instead.


People that are not residents of Sweden don't have personal identification numbers, but to enable authorities to coordinate their work to help the individual a Samordningsnummer is used. It's like a regular Personnummer, but with 60 added to the day in the month.

Use of Personnummer for gender identification discouraged

Many decades ago a part of the Personnummer was used for identification of what hospital/region a person was born in. However, that became obsolete as the praxis was abandoned.

The same thing seem to be happening to the gender digit of the Personnummer. Nowadays gender classification is not easily squeezed into the binary format of the Personnummer odd/even categories. Opinion is closing in on removing the use of Personnummer for gender classification, as has already been decided in for example Norway.


GDPR is a law that states that you as an individual should know how your personal information is being used. Depending on who you ask, this may be interpreted so that you cannot use any personal identification number that someone else has, even if there is no connection at all to the task you are performing. Hence, this utility also has the ability to fetch un-used Personnummer from Skatteverket, the authority in charge of Swedish Personnummer. Since no-one is using them they are safe to use. However, since the API to Skatteverekt is a bit limited in its query parameters, some other utility functionality then has had to be disabled when used with GDPR safe Personnummer.

Generation settings

Person identification number type ratio

PersonnummerSamordningsnummerUsed to coordinate government for people without personnummer
0% samordningsnummer
Number indicate percent chance of converting the acquired
personummer to a samordningsnummer for each identity generated.

Gender ratio

50% male
Number indicate percent chance of generating a
male identity for each identity generated.

Date filter

Display settings

Display columns

Personal identity number format