Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Python implementation of kakasi - kana kanji simple inversion library

Project description


Documentation Status PyPI version Travis-CI Azure-Pipelines Coverage status

pykakasi is a Python Natural Language Processing (NLP) library to transliterate hiragana, katakana and kanji (Japanese text) into rōmaji (Latin/Roman alphabet).

It is based on the kakasi library, which is written in C.


Transliterate Japanese text to rōmaji:

>>> import pykakasi
>>> text = u"かな漢字交じり文"
>>> kakasi = pykakasi.kakasi()
>>> kakasi.setMode("H","a") # Hiragana to ascii, default: no conversion
>>> kakasi.setMode("K","a") # Katakana to ascii, default: no conversion
>>> kakasi.setMode("J","a") # Japanese to ascii, default: no conversion
>>> kakasi.setMode("r","Hepburn") # default: use Hepburn Roman table
>>> kakasi.setMode("s", True) # add space, default: no separator
>>> kakasi.setMode("C", True) # capitalize, default: no capitalize
>>> conv = kakasi.getConverter()
>>> result =
>>> print(result)
kana Kanji Majiri Bun

Tokenize Japanese text (split by word boundaries), equivalent to kakasi’s wakati gaki option:

>>> wakati = pykakasi.wakati()
>>> conv = wakati.getConverter()
>>> result =
>>> print(result)
かな 漢字 交じり 文

Add furigana (pronounciation aid) in rōmaji to text:

>>> kakasi = pykakasi.kakasi()
>>> kakasi.setMode("J","aF") # Japanese to furigana
>>> kakasi.setMode("H","aF") # Japanese to furigana
>>> conv = kakasi.getConverter()
>>> result =
>>> print(result)
かな[kana] 漢字[Kanji] 交じり[Majiri] 文[Bun]

Input mode values: “J” (Japanese: kanji, hiragana and katakana), “H” (hiragana), “K” (katakana).

Output mode values: “H” (hiragana), “K” (katakana), “a” (alphabet / rōmaji), “aF” (furigana in rōmaji).

There are other setMode switches which control output:

  • “r”: Romanisation table: Hepburn (default), Kunrei or Passport
  • “s”: Separator: False adds no spaces between words (default), True adds spaces between words
  • “C”: Capitalize: False adds no capital letters (default), True makes each word start with a capital letter

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pykakasi, version 1.2
Filename, size File type Python version Upload date Hashes
Filename, size pykakasi-1.2-py2.py3-none-any.whl (2.5 MB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size pykakasi-1.2.tar.gz (1.1 MB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page