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

@tortaruga/kanaji

v1.0.0

Published

A lightweight JavaScript library for converting between romaji and Japanese kana

Readme

@tortaruga/kanaji

A lightweight JavaScript library to convert between Roumaji script and Japanese Kana.


⚡ Features

  • Convert Roumaji ↔ Hiragana/Katakana
  • Convert Hiragana ↔ Katakana
  • Support basic punctuation and digits
  • Support both Hepburn romanization system and Nihon-Shiki (view notes on transliteration for more details)

📦 Installation

npm install @tortaruga/kanaji

💻 Usage

Import the functions:

import { 
  toHiragana, 
  toKatakana, 
  toRoumaji,
  hiraganaToKatakana, 
  katakanaToHiragana 
} from '@tortaruga/kanaji';

All functions take a string as input.

  • Latin inputs support basic punctuation and digits.
  • Japanese inputs support full-width punctuation and digits only.

Supported punctuation

The following punctuation and digits are supported in Roumaji input:

Digits: 0 1 2 3 4 5 6 7 8 9
Punctuation: , . - ! ?

The following full-width punctuation and digits are supported in Kana input:

Digits: 0 1 2 3 4 5 6 7 8 9
Punctuation: 、 。 - ! ?

Conversion from Roumaji

toHiragana('Ohisashiburi desu!') // Output: おひさしぶりです!
toKatakana('resutoran') // Output: レストラン

Conversion to Roumaji

toRoumaji('にほんご を はなします か?'); // Output: nihongo wo hanashimasu ka?
toRoumaji('エート。。。'); // Output: eeto... 

Converion between Kana

hiraganaToKatakana('ありがとう'); // Output: アリガトウ 
katakanaToHiragana('アリガトウ'); // Output: ありがとう 

⚠️ Notes on transliteration

This library supports both the Hepburn and Nihon-shiki romanization systems, with a few practical exceptions to reduce ambiguity:

  • Because the converter doesn't include a grammar parser, is always romanized as "ha" (never "wa"), including when used as a particle; to produce when converting from roumaji, use "ha" ("wa" maps to ).

  • is always romanized as "he" (never "e"), including when used as a particle; to produce when converting from roumaji, use "he" ("e" maps to ).

  • the particle is always romanized as "wo" (never "o"); to produce when converting from roumaji, use "wo" ("o" maps to ).

  • Japanese text typically does not include spaces. Since the converter cannot recognize word boundaries, the romanized output will also omit spaces (unless provided in the kana input).

  • Only valid Japanese syllables will be converted. For foreign words, the converter cannot automatically adapt them into appropriate Japanese phonetic equivalents. You’ll need to manually adjust the input to match valid syllables (e.g., use "Makudonarudo" for "McDonald's").

  • When entering roumaji, use "ei" for long e sounds and "ou" for long o sounds.

  • Other long vowels are doubled: "aa", "ii", "uu". This avoids the need for macrons (e.g., ā, ī, ū, ē, ō), which are less convenient to type.

  • じ / ジ is romanized as "ji", while ぢ / ヂ is romanized as "di".

  • ず / ズ is romanized as "zu", while づ / ヅ is romanized as "du".