Validates the AHV 13 Number (swiss social security number)

Downloads in past


2102.0.16 months ago6 years agoMinified + gzip package size for ahv13-validator in KB


npm version ci release


Helps you to check ahv13 numbers (swiss social security numbers) for their validity. See also this article (in german) for more information about the form.


To install using npm:
npm install --save ahv13-validator

If you are using yarn:
yarn add ahv13-validator


The SSN can be passed with or without dots.
import { AHV13 } from 'ahv13-validator';

const ahv13validator = new AHV13();
const isValid = ahv13validator.isValid('756.9217.0769.85');

console.log('valid', isValid)



If you want to improve one of these images, your will need the following software installed on your system:
  • node (10 or higher) with npm

You can then install the dependencies by running npm ci.

Test the code

Code can be tested using Jest by running npm run test.
You can use npm run watch:test to watch for files and run the test on every change.


Project can be transpiled from TypeScript to JavaScript by running npm run build.
You can use npm run watch:build to watch for files and build on every change.

Build the documentation

Documentation can be build with TypeDoc by running npm run doc.
You can use npm run watch:doc to watch for files and build the documentation on every change.
Note: This mode will only detect changes to files watched by the TypeScript compiler. Changes to other files (README.md) will not cause a rebuild.

Publish the documenation

Documentation can be published on GitHub Pages by running npm run doc && npm run doc:publish.

Testing GitHub Actions locally

GitHub Actions pipeline can be run locally using act.
Once installed just run act to run the pipeline locally.

External links

Here are a few extra links documenting how swiss social security number are checked:


Made with contrib.rocks.