How to generate furigana for Japanese text 🇯🇵
Furigana are small hiragana characters added above or beside kanji to show their pronunciation. They are very useful for Japanese learners because they make texts containing unfamiliar kanji easier to read.
I recently wrote an essay for my Japanese class and wanted to print it so I could bring it to the lesson and read it more easily. For that, I needed to add furigana to some of the kanji I had not yet learned.
Several online tools can add furigana, but they all add hiragana to every kanji regardless of the reader’s knowledge. I did not want furigana added to simple JLPT N5 and N4 kanji that I already knew. None of the available tools offered that option, so I wrote my own script.
My furigana generator
I created a Python script that uses SudachiPy to analyse text and generate furigana intelligently.
- Preserves formatting: It processes the text line by line so that paragraphs remain intact.
- Focuses on what you need to learn: It analyses words and adds furigana only to kanji above your selected JLPT level, keeping the text clean and readable.
- Ignores katakana: It does not add furigana to words written in katakana.
- Reusable as you improve: You can easily choose your JLPT level, such as N5, N4 or N3, so the tool remains useful as your knowledge grows.
The complete script and instructions are available in my GitHub repository: furigana-generator.
How to use the script
Install the required libraries:
pip install sudachipy sudachidict-core
Put your text in a file named text.txt.
Run the script:
python furigana_generator.py text.txt
The result is saved as text.html, ready to open in a browser and print.
Example
As an example, I will use a sentence from my essay:
今年の3月に日本に行きました。これは二回目の日本の旅行でした。ホテルは東京にだけ泊まりましたが、横浜と長野にも行きました。
With furigana for every kanji, as produced by most online tools:
今年の3月に日本に行きました。これは二回目の日本の旅行でした。ホテルは東京にだけ泊まりましたが、横浜と長野にも行きました。
With furigana only for kanji above JLPT N4, using my script:
今年の3月に日本に行きました。これは二回目の日本の旅行でした。ホテルは東京にだけ泊まりましたが、横浜と長野にも行きました。
If you are learning Japanese and want to prepare a neatly formatted text with furigana for printing or a presentation, I recommend trying the tool.