
Company News
Socket Has Acquired Secure Annex
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.
Validate zip codes fast and accurate! A Library of JavaScript Regular Expressions for validating if a specific zip code actually exists in a specific Country.
A Library of JavaScript Regular Expressions for validating if a specific Zip-code exists in a specific Country.
Not every 5 digit number is automatically a zip code... As of now Regular Expression seem to be the fastest way of validating if a zip code actually exists. No slow backend validation needed, just some fancy RegExp.
So Why val-zip? Because it is free for commercial use and it is super fast and light weight with only 448kB size.
As of now the Regular Expressions for Germany, Austria, Switzerland, USA (5-Digit version), Belgium, Denmark, Czechia, Finland, Norway, Italy, Spain, Estonia, Iceland, France, Luxembourg are available with more coming asap.
Download via Node Package Manager (NPM):
npm install val-zip
Import via Content Delivery Network (CDN):
<script type="module" src="https://cdn.skypack.dev/val-zip@latest" corossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/val-zip@latest/dist/val-zip.umd.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="module" src="https://unpkg.com/val-zip@1.0.12/dist/va-zip.udm.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
Note: CDN is still wip, so error may occur. In doubt use skypack cdn
import valZip from "val-zip"; // make sure to use type="module" or the ".mjs" file extension
// alternative: const valZip = require("val-zip");
// note: the require function is nodejs specific and is not available in a ESM or Browser environment.
// make sure to use type="commonjs" or the ".cjs" file extension
// let's say a random user puts in a zipcode somehow and you want to validate if the zip code exists.
var userCountry = "US"; // ISO 3166 Country Code; string
var inputZip_1 = "12345"; // fake, this zipcode does NOT exist in the United States
var inputZip_2 = "00601"; // reak, exists
valZip(inputZip_1, userCountry) // returns false
valZip(inputZip_2, userCountry) // returns true
Note: All data is heavily modified and does not resemble the original data base at all
| country | last update | license | source |
|---|---|---|---|
| Austria | 04.01.2023 | none | Ă–sterreichische Post Aktiengesellschaft |
| Belgium | 21.11.2021 | none | Bpost |
| Switzerland | 01.01.2023 | CC-BY | Die Schweizerische Post |
| Czechia | 01.01.2023 | none | Česká pošta |
| Germany | 01.06.2019 | none | Launix |
| Denmark | 22.06.2022 | none | PostNord Danmark |
| United States | 31.12.2020 | none | Internal Revenue Service, US Census |
| Norway | 01.10.2022 | none | Osten Norge AS |
| Finland | 30.01.2023 | none | Posti Group Oy |
| Italy | 26.11.2020 | Eurostat free re-use of data | Eurostat |
| Spain | 26.11.2020 | Eurostat free re-use of data | Eurostat |
| Estonia | 05.02.2023 | none | Republic of Estonia |
| Iceland | 06.02.2023 | none | ĂŤslandspĂłstur |
| France | 06.02.2023 | Open License v2.0 | La Poste Groupe |
| Luxembourg | 06.02.2023 | CC-0 | Portail Open Data |
Some Countries are missing, just because the official zipcode database is either paywalled or entirely copyrighted.
This is the List of countries I am unable to source data from:
| country | limitation | source |
|---|---|---|
| Poland | only with permit | Poczta Polska Spółka Akcyjna |
| Sweden | paid only | Postnummerservice Norden AB |
| Australia | paid only | Australia Post |
MIT License Copyright (c) 2022-today Leonhard Maier
FAQs
Validate zip codes fast and accurate! A Library of JavaScript Regular Expressions for validating if a specific zip code actually exists in a specific Country.
The npm package val-zip receives a total of 51 weekly downloads. As such, val-zip popularity was classified as not popular.
We found that val-zip demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.

Research
/Security News
Socket is tracking cloned Open VSX extensions tied to GlassWorm, with several updated from benign-looking sleepers into malware delivery vehicles.

Product
Reachability analysis for PHP is now available in experimental, helping teams identify which vulnerabilities are actually exploitable.