npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nordic-id-validator

v2.0.0

Published

A light-weight library for verifying Nordic personal identification numbers (SNNs) with accuracy and ease.

Readme

nordic-id-validator

npm version license node

Lightweight, zero-dependency validator for Nordic personal identification numbers (SSN / personnummer / fødselsnummer / CPR / HETU).

Supports Sweden, Norway, Denmark, and Finland with format, date, and checksum validation.

Installation

npm install nordic-id-validator

Quick start

const Validator = require('nordic-id-validator');
const validator = new Validator();

validator.isValid('860101-3496', 'SE'); // true
validator.isValid('21103426631', 'NO'); // true

Usage

Generic API

Use isValid(input, countryCode) when the country is dynamic:

validator.isValid('860101-3496', 'SE'); // true
validator.isValid('0105949021',  'DK'); // true
validator.isValid('010594Y9021', 'FI'); // true

Country-specific API

Use the country-specific methods when the country is known up front:

validator.isValidSE('860101-3496');  // Sweden
validator.isValidNO('21103426631');  // Norway
validator.isValidDK('0105949021');   // Denmark
validator.isValidFI('010594Y9021');  // Finland

API

| Method | Returns | Description | | ------------------------------- | --------- | --------------------------------------------- | | isValid(input, countryCode) | boolean | Validates against the given country code. | | isValidSE(input) | boolean | Validates a Swedish personnummer. | | isValidNO(input) | boolean | Validates a Norwegian fødselsnummer. | | isValidDK(input) | boolean | Validates a Danish CPR-nummer. | | isValidFI(input) | boolean | Validates a Finnish HETU. |

Supported country codes: SE, NO, DK, FI.

Input types: string (recommended) or number. Number input is supported for convenience but will silently drop leading zeros — prefer strings.

Accepted formats

| Country | Length | Example | Separator | | ------- | ---------- | ---------------- | -------------------------------------- | | SE | 10 digits | 860101-3496 | Optional - between date and serial. | | SE | 12 digits | 19860101-3496 | Optional - between date and serial. | | NO | 11 digits | 21103426631 | None. | | DK | 10 digits | 030594-9031 | Optional - between date and serial. | | FI | 11 chars | 010594Y9021 | Century marker is part of the format. |

Validation rules per country

  • Sweden — length, date of birth, and Luhn check digit.
  • Norway — length, date of birth, and both mod-11 check digits.
  • Denmark — length and date of birth. The mod-11 checksum was phased out in 2007 and is not validated.
  • Finland — HETU format, date of birth, and check character (modulo 31).

Error handling

isValid throws on unknown country codes:

try {
    validator.isValid('860101-3496', 'XX');
} catch (error) {
    console.error(error.message);
    // -> "Invalid country code. Valid country codes are: SE, NO, DK, FI"
}

All methods throw a TypeError if the input is neither a string nor a number:

validator.isValidSE({}); // throws TypeError

Otherwise, validation returns false for malformed input — no exceptions for ordinary invalid numbers.

Contributing

Issues and pull requests are welcome. Please include test cases for any new validation rules or bug fixes.

npm install
npm test
npm run lint

License

MIT — A project by Fiive.