Repolode
theajack

theajack/cnchar

A JavaScript/TypeScript utility library for Chinese characters, covering pinyin, stroke counts, radicals, idioms, stroke-order drawing and speech.

Stars
3,107
Forks
341
Open issues
50
Last commit
27 days ago

What is it?

cnchar is a Chinese character toolkit for JavaScript that lets developers look up pinyin (with tones, initials and finals), stroke counts, stroke order and radicals for characters. It also supports polyphonic characters and words, conversion between simplified, traditional and stylized Chinese text, and lookup of characters by pinyin or stroke count.

Beyond basic lookups, it provides plugins for idioms, two-part allegorical sayings (歇后语), word composition, dictionary explanations, and character drawing with animated stroke-by-stroke display built on HanziWriter. Speech synthesis and recognition are available through browser APIs, and pinyin/IME-related helpers are included.

The core library is split into optional plugin packages so projects can install only what they need. It runs in browsers, Node.js, WeChat mini programs and React Native-style environments, and is written in TypeScript.

Key features

  • 01Get pinyin with tones, initials, finals and polyphonic character handling
  • 02Look up stroke counts, stroke order and radicals for Chinese characters
  • 03Convert between simplified, traditional and stylized Chinese text
  • 04Find characters by pinyin or stroke count
  • 05Query idioms, two-part sayings, word composition and explanations via plugins
  • 06Draw characters stroke by stroke in the browser

Use cases

  • Adding pinyin annotations to Chinese text in a web or Node.js app
  • Sorting contact lists by pinyin or stroke count
  • Building a Chinese character learning or typing game
  • Creating a stroke-order practice tool for handwriting learners

Quick start

  1. 1

    Install the core library with npm

    npm i cnchar
  2. 2

    Use it in your code to get pinyin and strokes

Things to know

  • Many advanced features need separate plugin packages to be installed.
  • Dictionary data comes from online sources and the README admits it may contain errors or omissions.

In collections

Topics

#chinese-characters#pinyin#javascript#typescript#nlp#chinese-text#stroke-order#draw#speak#spell-stroke

FAQ

What is cnchar?
A JavaScript/TypeScript utility library for Chinese characters, covering pinyin, stroke counts, radicals, idioms, stroke-order drawing and speech. cnchar is a Chinese character toolkit for JavaScript that lets developers look up pinyin (with tones, initials and finals), stroke counts, stroke order and radicals for characters. It also supports polyphonic characters and words, conversion between simplified, traditional and stylized Chinese text, and lookup of characters by pinyin or stroke count.
Is cnchar free to use? What license does it have?
cnchar is open source under the MIT license. Check the license terms before using it in commercial products.
Is cnchar still maintained?
Actively maintained. The last commit to cnchar was on Oct 11, 2026.
What can I use cnchar for?
Adding pinyin annotations to Chinese text in a web or Node.js app Sorting contact lists by pinyin or stroke count Building a Chinese character learning or typing game Creating a stroke-order practice tool for handwriting learners
How do I install cnchar?
Install the core library with npm: npm i cnchar Use it in your code to get pinyin and strokes
Where can I get cnchar?
The source code and installation instructions are on GitHub: https://github.com/theajack/cnchar

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects

A single-page web tool that shows a Chinese character's oracle bone, small seal, traditional and simplified forms, plus pronunciation, Shuowen definition and phonetic family.

Learning Resources#chinese-characters#etymology#oracle-bone-script
131+7 this week26HTMLMITUpdated 12 days ago