Cnchar is a versatile Hanzi toolkit designed to handle pinyin, stroke order, radicals, idioms, and voice synthesis. It is built for high portability and runs in almost any JavaScript environment.
Key Advantages
Installation
Installing via npm
To get started, install the core library:
npm i cnchar
You can then add optional plugins based on your needs:
npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy cnchar-radical cnchar-words cnchar-explain cnchar-voice cnchar-random cnchar-code cnchar-input cnchar-info cnchar-name
Alternatively, install the entire suite at once:
npm i cnchar-all
Using a CDN
To include the core library:
<script src="https://fastly.jsdelivr.net/npm/cnchar/cnchar.min.js"></script>
To add specific plugins:
<script src="https://fastly.jsdelivr.net/npm/cnchar-poly/cnchar.poly.min.js"></script>
<script src="https://fastly.jsdelivr.net/npm/cnchar-order/cnchar.order.min.js"></script>
Or use the all-in-one package:
<script src="https://fastly.jsdelivr.net/npm/cnchar-all/cnchar.all.min.js"></script>
Implementation
Modern Environments (Webpack/Vite)
import cnchar from 'cnchar';
import 'cnchar-poly'; // Import additional plugins as required
console.log('汉字'.spell()); // Using the prototype method
console.log(cnchar.spell('汉字')); // Using the API call
Node.js
var cnchar = require('cnchar');
var poly = require('cnchar-poly');
cnchar.use(poly);
console.log('汉字'.spell());
console.log(cnchar.spell('汉字'));
Direct Browser Integration
<script src="https://fastly.jsdelivr.net/npm/cnchar/cnchar.min.js"></script>
<script src="https://fastly.jsdelivr.net/npm/cnchar-poly/cnchar.poly.min.js"></script>
<script>
console.log('汉字'.spell());
console.log(cnchar.spell('汉字'));
</script>
Core Capabilities
Pinyin Processing – Retrieve pinyin for Chinese characters with support for first-letter extraction, case sensitivity, array output, and polyphone (multi-pronunciation) detection. It also manages tone marks and multi-syllable words.
Stroke Data – Access stroke counts, stroke order, and official stroke names. When used in a browser, the library can visually render stroke-order animations.
Character Conversion & Lookup – Convert text between Simplified, Traditional, and "Martian" (stylized/leet-speak) Chinese. You can also search for characters by pinyin, stroke count, or specific stroke order.
Extended Features
OpenThoughts-Agent: Train Small AI Models with HPC Scale
Sora 2 AI Watermark Remover: Remove Sora Watermarks Cleanly
CrewAI Stock Analysis: Multi-Agent Investment Tool with AkShare & GPT
VibeVoice: Long-Form Multi-Speaker TTS for Natural Dialogue Generation
RunAgent: Build AI Agents in Python, Invoke Them Natively from Any Language
12306-mcp: Query China Train Tickets via MCP Server and LLMs
NetBird Setup Guide: Building a WireGuard Mesh VPN
mRemoteNG Setup: Manage RDP, SSH, and VNC in One Tabbed Console
Chinese Kinship Calculator: Instantly Decode Family Relationship Terms
Paperless GPT: Smarter OCR and Auto-Tagging for Paperless-NGX
QSV: Slice, Query, and Clean Massive CSV Files with High Performance
LiebaoVPN: Fast, Private, and Ad-Free – The Top VPN for 2025