WanaKana is a JavaScript utility library designed for detecting and transliterating Japanese text between Hiragana, Katakana, Romaji, and handling Kanji. It provides a comprehensive set of functions for checking the type of script (e.g., `isJapanese`, `isKana`, `isRomaji`), converting between them (e.g., `toKana`, `toHiragana`, `toRomaji`), and includes DOM helpers for real-time input conversion (`bind`, `unbind`). The library is currently at version 5.3.1 and maintains an active release cadence, with minor updates and bug fixes occurring every few months. Its key differentiators include robust input method editor (IME) simulation capabilities for HTML text fields, comprehensive handling of various kana and romaji mapping rules, and support for custom mappings. WanaKana ships with TypeScript definitions, making it highly compatible with modern TypeScript-driven web development workflows.
npm install wanakanaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic Romaji to Hiragana/Katakana conversion, checks for Japanese text, and illustrates how to bind WanaKana to a DOM input element for real-time conversion.
Review calls to `stripOkurigana()` and update options according to the new API. For example, to strip all kana, use `[...text].filter(isKana)` manually.
Update any logic that relies on the previous classification of `々`, especially in custom character type detection or processing pipelines.
Ensure that your application explicitly manages custom mapping states, passing the desired mapping every time if it might change, rather than relying on a potentially stale or implicitly set mapping.
Ensure `bind()` is called only once per element. If you need to re-bind with new options, `unbind()` first. Review applications for any dependencies on attributes `unbind()` might have previously left untouched.
Use `import { toKana } from 'wanakana';` for specific functions or `import * as wanakana from 'wanakana';` to import all named exports under a namespace.For browser use without a bundler, ensure `<script src="https://unpkg.com/wanakana"></script>` is in your HTML. For module environments, ensure you have `import * as wanakana from 'wanakana';` or appropriate named imports.
Verify that the DOM element you are passing to `bind()` actually exists and is not `null` or `undefined`. Also, confirm that `wanakana` has been correctly imported and is accessible in the current scope.
No dependency data recorded yet.