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

jpostcode

v0.23.202512

Published

A library for finding Japanese addresses by postal code.

Readme

Jpostcode

Jpostcodeは、郵便番号から日本の住所を検索するためのライブラリです。都道府県、市区町村、町域名を、漢字とカナの両方で詳細に提供します。

インストール

npmを使用してライブラリをインストールします:

npm install jpostcode

使い方

基本的な使用例を以下に示します:

JavaScript

const { Jpostcode } = require('jpostcode');

// 郵便番号から住所を検索
const addresses = Jpostcode.find('0010000');

if (addresses.length > 0) {
  // 1つの郵便番号から複数の住所が見つかる場合があります
  for (const address of addresses) {
    console.log(`都道府県: ${address.prefecture} (${address.prefectureKana})`);
    console.log(`市区町村: ${address.city} (${address.cityKana})`);
    console.log(`町域: ${address.town} (${address.townKana})`);
    console.log(`郵便番号: ${address.zipCode}`);
  }
} else {
  console.log('住所が見つかりませんでした。');
}

TypeScript

import { Address, Jpostcode } from 'jpostcode';

// 郵便番号から住所を検索
const addresses:Address[] = Jpostcode.find('0010000');

if (addresses.length > 0) {
  // 1つの郵便番号から複数の住所が見つかる場合があります
  for (const address of addresses) {
    console.log(`都道府県: ${address.prefecture} (${address.prefectureKana})`);
    console.log(`市区町村: ${address.city} (${address.cityKana})`);
    console.log(`町域: ${address.town} (${address.townKana})`);
    console.log(`郵便番号: ${address.zipCode}`);
  }
} else {
  console.log('住所が見つかりませんでした。');
}

Webブラウザでの使用

Webアプリケーションでは、AJAX版またはBundle版のいずれかを使用できます:

AJAX版(ほとんどのケースで推奨)

<!-- AJAX版を読み込み -->
<script src="https://cdn.jsdelivr.net/npm/jpostcode@latest/dist/jpostcode-web.js"></script>

<script>
// データファイルのベースURLを設定(オプション、デフォルトは './data/json/')
Jpostcode.setBaseUrl('https://your-cdn.com/jpostcode-data/');

// 住所を検索(Promiseを返します)
Jpostcode.find('1000001').then(addresses => {
  if (addresses.length > 0) {
    for (const address of addresses) {
      console.log(`都道府県: ${address.prefecture}`);
      console.log(`市区町村: ${address.city}`);
      console.log(`町域: ${address.town}`);
    }
  }
});
</script>

Bundle版(全データ同梱)

<!-- Bundle版を読み込み(ファイルサイズは大きいですが、オフラインでも動作します) -->
<script src="https://cdn.jsdelivr.net/npm/jpostcode@latest/dist/jpostcode-web-bundle.js"></script>

<script>
// 住所を検索(同期処理)
const addresses = Jpostcode.find('1000001');
if (addresses.length > 0) {
  for (const address of addresses) {
    console.log(`都道府県: ${address.prefecture}`);
    console.log(`市区町村: ${address.city}`);
    console.log(`町域: ${address.town}`);
  }
}
</script>

機能

  • 郵便番号による住所検索: 郵便番号を使用して詳細な住所情報を取得
  • 存在しない郵便番号への対応: 郵便番号が存在しない場合は空の配列を返却
  • Webブラウザ対応: WebアプリケーションのためのAJAX版とBundle版を提供
  • TypeScript対応: 完全なTypeScript型定義を含む
  • データの自動更新: ソースデータが変更されると郵便番号データを自動更新

ビルドとテスト

プロジェクトをビルドするには:

npm run build

テストを実行するには:

npm test

貢献

貢献を歓迎します!GitHubでissueを開くか、プルリクエストを送信してください。

謝辞

このプロジェクトは jpostcode-data ライブラリのデータを使用しています。このライブラリのメンテナと貢献者の皆様に感謝いたします。

GitHub Pagesデモ

このプロジェクトには、ライブラリの機能を日本語で紹介するGitHub Pagesデモサイトが含まれています。

ライブデモ

ライブデモは以下で公開されています: https://matzlika.github.io/jpostcode-js/

GitHub Pagesの設定

  1. リポジトリのSettingsタブに移動
  2. 左サイドバーの"Pages"に移動
  3. "Source"で"GitHub Actions"を選択
  4. mainブランチにプッシュすると自動的にデプロイされます

ローカル開発

デモサイトをローカルで実行するには:

# まずプロジェクトをビルド
npm run build

# データファイルへのシンボリックリンクを作成(まだ作成していない場合)
cd docs && ln -s ../jpostcode-data/data data && cd ..

# 静的ファイルサーバーでdocsディレクトリを配信
# 例: Pythonを使用する場合
python -m http.server 8000 --directory docs

# または Node.js http-serverを使用する場合
npx http-server docs -p 8000

その後、ブラウザで http://localhost:8000 を開きます。

ライセンス

このプロジェクトはMITライセンスの下でライセンスされています。


English version: README.en.md