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
Lanjing VPN Review: Unlimited Traffic, CN2 Lines, and Smart Routing
LiveMCPBench: Benchmark AI Agents on Real-World MCP Tool Tasks
Duck VPN Review: Stream Netflix & Unblock Social Apps Without Logs
VibeVoice: Long-Form Multi-Speaker TTS for Natural Dialogue Generation
FossFLOW: Offline-Ready Isometric Diagram Builder for the Browser
NotebookLlama: An Open-Source NotebookLM Alternative with AI Voice
QSV: Slice, Query, and Clean Massive CSV Files with High Performance
NPS Proxy: A Powerful Self-Hosted Tunnel to Expose Local Servers
Notes MCP Guide: Connect Apple Notes to Claude, Cursor, and LLMs
Crawl4AI RAG MCP Server: Web Crawling and Vector Search for AI Agents
XMIF VPN Free Trial & $0.70/Month Plan – No Logs, 4K Speed
Shendeng VPN: Genuine Unlimited Data & High-Speed Gaming Acceleration