Skip to main content

handwritten kanji recognition

Project description

GitHub Release PyPI Version Python Versions CI AGPLv3+ Sponsor

kanjidraw - handwritten kanji recognition

kanjidraw is a simple Python library + GUI for matching (the strokes of a) handwritten kanji against its database.

You can use the GUI to draw and subsequently select a kanji from the list of probable matches, which will then be copied to the clipboard.

The database is based on KanjiVG and the algorithms are based on the Kanji draw Android app.


Jiten Japanese Dictionary uses kanjidraw with a JavaScript frontend.


  • Python >= 3.5 (w/ Tk support for the GUI).


$ apt install python3-tk


Using pip

$ pip install kanjidraw

NB: depending on your system you may need to use e.g. pip3 --user instead of just pip.

From git

NB: this installs the latest development version, not the latest release.

$ git clone
$ cd kanjidraw
$ pip install -e .

NB: you may need to add e.g. ~/.local/bin to your $PATH in order to run kanjidraw.

To update to the latest development version:

$ cd kanjidraw
$ git pull --rebase


Kanji Input on Linux


Opens kanjidraw to select one (--oneshot) or multiple (--multiple) kanji, and afterwards pastes the selected kanji in the active window. Requires xclip and xdotool.

set -e
pid="$( xdotool getactivewindow getwindowpid )"
pids() { xdotool search --classname "$1" getwindowpid %@; }
if pids urxvt | grep -q "^$pid$"; then
elif pids terminal | grep -q "^$pid$"; then
kanjidraw -s "$@" | tr -d '\n' | xclip -i -selection clipboard
xdotool key --delay 250 "$key"

i3 config

Keybindings for i3. Creating custom keybindings for kanjidraw-paste --oneshot and/or kanjidraw-paste --multiple should work similarly with other window managers and desktop environments.

for_window [title="Kanji Draw"] floating enable
bindsym $mod+Control+k exec --no-startup-id kanjidraw-paste --oneshot
bindsym $mod+Control+m exec --no-startup-id kanjidraw-paste --multiple


GUI Options

$ kanjidraw --help
usage: kanjidraw [-h] [-s] [-o | -m] [-d] [--version]

optional arguments:
  -h, --help      show this help message and exit
  -s, --stdout    print kanji to stdout instead of copying to clipboard
  -o, --oneshot   quit after one kanji
  -m, --multiple  queue kanji and copy/print after pressing 'c' or quitting
  -d, --dark      use dark theme
  --version       show program's version number and exit

Additional keybindings: q to quit, <esc> to go back.

Enabling Dark Mode


Disabling the Grid




© Felix C. Stegerman


KanjiVG (stroke data)

© Ulrich Apel


Project details

Download files

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

Source Distribution

kanjidraw-0.2.3.tar.gz (519.3 kB view hashes)

Uploaded source

Built Distribution

kanjidraw-0.2.3-py3-none-any.whl (542.8 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page