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

normal-jusho

v0.2.0

Published

TypeScript/JavaScript SDK for the Jusho Japanese address normalization API

Readme

jusho

TypeScript/JavaScript SDK for the Jusho Japanese address normalization API.

Normalize, validate, and look up Japanese addresses with full TypeScript types, zero runtime dependencies, and support for both Node.js and browsers.

日本語版 README はこちら

Features

  • Zero runtime dependencies (uses native fetch)
  • Full TypeScript types included
  • Dual package: ESM and CommonJS
  • Works in Node.js 18+ and modern browsers
  • Typed error classes for precise error handling
  • Configurable timeout and base URL

Installation

npm install normal-jusho
yarn add normal-jusho
pnpm add normal-jusho

Quick Start

import { Jusho } from 'jusho';

const jusho = new Jusho();

const result = await jusho.normalize('東京都千代田区千代田1-1');
console.log(result.address.pref);      // '東京都'
console.log(result.address.city);      // '千代田区'
console.log(result.codes.post_code);   // '1000001'
console.log(result.geo.lat);           // Latitude

Usage

Create a Client

import { Jusho } from 'jusho';

// Default configuration
const jusho = new Jusho();

// Custom configuration
const jusho = new Jusho({
  baseUrl: 'https://api.jusho.dev',
  timeout: 10000, // 10 seconds
  headers: { 'X-Custom-Header': 'value' },
});

Normalize a Single Address

const result = await jusho.normalize('東京都渋谷区道玄坂1-2-3');

// Address components
console.log(result.address.full);     // Full normalized address
console.log(result.address.pref);     // Prefecture
console.log(result.address.city);     // City / ward
console.log(result.address.town);     // Town area
console.log(result.address.banchi);   // Block number
console.log(result.address.go);       // House number
console.log(result.address.building); // Building name

// Codes
console.log(result.codes.post_code);  // Postal code (7 digits)
console.log(result.codes.pref_code);  // Prefecture code
console.log(result.codes.city_code);  // City code

// Kana readings
console.log(result.kana.pref);        // Prefecture reading
console.log(result.kana.city);        // City reading

// Coordinates
console.log(result.geo.lat);          // Latitude
console.log(result.geo.lng);          // Longitude

// Data source variants
console.log(result.address_variants.kokudo.city); // MLIT notation
console.log(result.address_variants.kenall.city); // Japan Post notation

Batch Normalization

const results = await jusho.normalizeBatch([
  '東京都千代田区千代田1-1',
  '大阪府大阪市北区梅田1-1-1',
  '北海道札幌市中央区北1条西2丁目',
]);

console.log(results.total);         // 3
console.log(results.success_count); // Number of successes
console.log(results.error_count);   // Number of failures

for (const item of results.results) {
  if (item.success) {
    console.log(item.result!.address.full);
  } else {
    console.error(`Failed: ${item.input} - ${item.error}`);
  }
}

Postal Code Lookup

const result = await jusho.postal('1500043');
console.log(result.address.pref); // '東京都'
console.log(result.address.city); // '渋谷区'

Address Suggestions

const result = await jusho.suggest('渋谷区道玄');
for (const suggestion of result.suggestions) {
  console.log(suggestion.address, suggestion.postal_code);
}

Address Validation

const result = await jusho.validate('東京都渋谷区道玄坂1-2-3');
console.log(result.valid);       // true
console.log(result.match_level); // 'full'
if (result.normalized) {
  console.log(result.normalized.codes.post_code);
}

Reverse Lookup

const result = await jusho.reverse('東京都渋谷区道玄坂1-2-3');
console.log(result.postal_code); // '1500043'

Error Handling

The SDK provides typed error classes for precise error handling:

import {
  Jusho,
  JushoError,
  NetworkError,
  TimeoutError,
  RateLimitError,
  NotFoundError,
  ValidationError,
} from 'jusho';

const jusho = new Jusho();

try {
  const result = await jusho.normalize('東京都千代田区千代田1-1');
} catch (error) {
  if (error instanceof NotFoundError) {
    // Address not found (HTTP 404)
    console.error('Address not found:', error.message);
  } else if (error instanceof RateLimitError) {
    // Rate limit exceeded (HTTP 429)
    console.error('Rate limited. Retry after:', error.retryAfterSeconds, 'seconds');
  } else if (error instanceof TimeoutError) {
    // Request timed out
    console.error('Timed out after:', error.timeoutMs, 'ms');
  } else if (error instanceof NetworkError) {
    // Network error (DNS failure, connection refused, etc.)
    console.error('Network error:', error.message);
  } else if (error instanceof ValidationError) {
    // Invalid request (HTTP 422)
    console.error('Invalid request:', error.message);
  } else if (error instanceof JushoError) {
    // Other API error
    console.error('API error:', error.statusCode, error.message);
  }
}

Error Classes

| Class | HTTP Status | Description | |-------|-------------|-------------| | JushoError | Any | Base error class for all SDK errors | | NetworkError | N/A | Network failure (DNS, connection, etc.) | | TimeoutError | N/A | Request exceeded timeout | | RateLimitError | 429 | Rate limit exceeded | | NotFoundError | 404 | Address not found | | ValidationError | 422 | Invalid request parameters |

CommonJS Usage

const { Jusho } = require('jusho');

const jusho = new Jusho();
const result = await jusho.normalize('東京都千代田区千代田1-1');

API Reference

new Jusho(options?)

| Option | Type | Default | Description | |--------|------|---------|-------------| | baseUrl | string | https://api.jusho.dev | API base URL | | timeout | number | 30000 | Request timeout (ms) | | headers | Record<string, string> | {} | Custom request headers |

Methods

| Method | Description | |--------|-------------| | normalize(address) | Normalize a single address | | normalizeBatch(addresses) | Normalize up to 100 addresses | | postal(code) | Look up address by postal code | | suggest(query) | Get address suggestions | | validate(address) | Validate an address | | reverse(address) | Reverse lookup (address to postal code) |

License

MIT