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

easy-zipcode-jp

v0.1.0

Published

郵便番号から住所を簡単に取得できるライブラリ

Readme

easy-zipcode-jp

easy-zipcode-jp は、日本の郵便番号を用いた住所検索を簡単に行えるライブラリです。

特徴

  • TypeScript 対応でシンプルな API のみを提供する軽量ライブラリ
  • 住所データを全て含むため外部依存なしにインストールするだけで利用可能
  • 郵便番号の前半3桁(郵便局番号)から対応する住所リストが取得可能
  • データはエリア単位で動的にインポート、キャッシュされ、必要な部分のみ読み込むことで軽量化

インストール

npm install easy-zipcode-jp

使い方

import { search, lookup, resolve } from 'easy-zipcode-jp'

// [
//   { city: '千代田区', pref: '東京都' },
//   { city: '千代田区', pref: '東京都' },
//   { city: '丸の内', pref: '東京都' },
//   ...
// ]
console.log(await search('100-100'))

// {
//   1000000: [{ city: '千代田区', pref: '東京都' }],
//   1000001: [
//     { city: '千代田区', pref: '東京都' },
//     { city: '丸の内', pref: '東京都' },
//   ],
//   1000011: [{ city: '千代田区', pref: '東京都', town: '内幸町' }],
//   ...
// }
console.log(await lookup('100'))

// [
//   { city: '千代田区', pref: '東京都' },
//   { city: '丸の内', pref: '東京都' },
// ]
console.log(await resolve('100-0001'))

API

Address

このライブラリで扱う住所データは、都道府県 pref 、市区町村 city 、町域名 town (存在する場合)です。 Address 型として参照されます。

type Address = {
  pref: string
  city: string
  town?: string
}

search(zipcode: string): Promise<Address[]>

zipcode として指定した郵便局番号(郵便番号の前半3桁)以上の部分的な郵便番号から該当する全ての住所を配列で返します。 zipcode にはハイフンを含めることができます。
部分的に該当する住所を単純な配列で返すため、ユーザー入力などに対する段階的な検索に適しています。

使用例

await search('100')
await search('1001')
await search('100-10')

返り値の例

[
  { city: '千代田区', pref: '東京都' },
  { city: '千代田区', pref: '東京都' },
  { city: '丸の内', pref: '東京都' },
  // ...
]

lookup(areacode: string): Promise<Record<string, Address[]> | null>

areacode として指定した郵便局番号(郵便番号の前半3桁)に該当する郵便番号に対する住所の一覧を取得します。 areacodeに該当するデータがない場合は null を返します。
郵便番号は対応する住所が複数存在しうるため、返り値は郵便番号をキーとした住所の配列となります。

使用例

await lookup('100')
await lookup('101')

戻り値の例

{
  1000000: [{ city: '千代田区', pref: '東京都' }],
  1000001: [
    { city: '千代田区', pref: '東京都' },
    { city: '丸の内', pref: '東京都' },
  ],
  1000011: [{ city: '千代田区', pref: '東京都', town: '内幸町' }],
  // ...
}

resolve(zipcode: string): Promise<Address[] | null>

zipcode として指定した郵便番号に該当する住所を取得します。 zipcode はハイフンを含んだ 100-0001 と含まない 1000001 がともに使用できます。

使用例

await resolve('100-0001')
await resolve('1000002')

戻り値の例

[
  { "city": "千代田区", "pref": "東京都" },
  { "city": "丸の内", "pref": "東京都" },
]

テスト

本ライブラリは vitest を用いてテストされています。

npm test

また検証用に examples/vite-node/ に簡単なサンプルコードが含まれています。

ライセンス

MIT