pangu.js inserts spaces between Chinese, Japanese, or Korean characters and adjacent Latin letters, digits, and symbols in web pages and plain text. A Chrome extension auto-formats pages; an optional on-device AI mode refines ambiguous cases.
Overview
pangu.js addresses dense mixed-script text by adding whitespace between CJK characters and half-width alphanumeric or symbol runs. The published npm package exposes spacing helpers for Node and a browser build that understands the DOM through functions such as spaceNode and autoSpacePage.
End users can install the official Google Chrome extension, which applies spacing across browsed pages. The extension adds an AI Spacing mode when regex rules are ambiguous: it calls Chrome's built-in Prompt API to run Gemini Nano locally so spacing decisions stay on the device without network calls.
Developers import the library directly or use the documented CLI. Project notes warn against using pangu.js to space Markdown because it targets HTML pages and plain text without markup. Community ports exist for other editors and platforms outside the core repository.
Key features
- CJK-to-Latin automatic spacing
- DOM-aware browser module
- Chrome extension for all pages
- On-device AI spacing option
- Node.js and browser builds
- Plain-text spacing API
- Command-line interface
- TypeScript types for browser build
Use cases
- Fixing mixed Chinese-English blog posts
- Spacing live web pages while browsing
- Embedding spacing in frontend builds
- Batch-spacing plain text in scripts
- Resolving plus-sign semantic ambiguities