xpinyin
Translate Chinese hanzi to pinyin (拼音) by Python, 汉字转拼音
Decision gist · record as of 2026-08-14
Yes, if you need reliable Chinese-to-pinyin conversion. The package is stable, dependency-free, and covers the core use cases well. The aging maintenance status (438 days since last release) is not a blocker—the code is mature and the repository remains active—but monitor it if you depend on ongoing feature development or rapid bug fixes.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction installation with no runtime dependencies.
- Maintenance is aging—last release was 438 days ago—but the repository remains active with recent commits and the package has been stable since its 2011 inception.
License · maintenance · safety
MIT (permissive) — MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
last release 2025-06-02 (438 days) · last repo commit 2025-06-02 · 831 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 73,649 downloads/mo, #14,955 on PyPI
Alternatives
Verify before relying
pip install xpinyin
from xpinyin import Pinyin
p = Pinyin()
p.get_pinyin("上海")
# Returns: 'shang-hai'
p.get_pinyin("上海", tone_marks='marks')
# Returns: 'shàng-hǎi'- Whether the package handles simplified vs. traditional Chinese character variants consistently
- Performance characteristics when processing large documents or streams of text
- Completeness of the pinyin database for rare or archaic characters
What it is and what it does
xpinyin is a Python library that translates Chinese characters into pinyin (the standard romanization system for Mandarin). It provides methods to extract the full phonetic spelling of characters, their initial consonants, and tone information in multiple formats—tone marks, tone numbers, or unmarked. The library also supports generating all possible pinyin combinations for characters with multiple readings, which is useful for disambiguation in mixed-reading contexts.
The package has no external dependencies and installs cleanly on modern Python versions. It's designed for developers building Chinese text processing pipelines, search systems, or applications that need to work with phonetic representations of Chinese text. The API is straightforward: instantiate a Pinyin object and call methods like get_pinyin(), get_initial(), or get_initials() with optional parameters to control output format.
Use it for
- Building search indexes that allow users to find Chinese text by typing pinyin instead of characters
- Generating phonetic guides or furigana-style annotations for Chinese text in educational applications
- Implementing text-to-speech systems that need to convert hanzi to romanized pronunciation
- Sorting or organizing Chinese text alphabetically by pinyin for catalogs or directories
- Disambiguating characters with multiple pronunciations in natural language processing pipelines
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need reliable Chinese-to-pinyin conversion.
The package is stable, dependency-free, and covers the core use cases well. The aging maintenance status (438 days since last release) is not a blocker—the code is mature and the repository remains active—but monitor it if you depend on ongoing feature development or rapid bug fixes.
Install
xpinyin on PyPI
Before you install
Low friction installation with no runtime dependencies. Maintenance is aging—last release was 438 days ago—but the repository remains active with recent commits and the package has been stable since its 2011 inception.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install xpinyin
from xpinyin import Pinyin
p = Pinyin()
p.get_pinyin("上海")
# Returns: 'shang-hai'
p.get_pinyin("上海", tone_marks='marks')
# Returns: 'shàng-hǎi'
Verify before relying
- Whether the package handles simplified vs. traditional Chinese character variants consistently
- Performance characteristics when processing large documents or streams of text
- Completeness of the pinyin database for rare or archaic characters
Package facts
| License | MIT permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Aging 438 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 73,649 / month, #14,955 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.0Programming Language :: Python :: 3.1Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.2Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules |
Evidence: xpinyin-0.7.7-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “chinese hanzi to pinyin conversion”
- xpinyinConverts Chinese characters (hanzi) to their phonetic romanization…
- pypinyinConverts Chinese characters to pinyin (romanized pronunciation) with…
- zhonZhon provides character constants and regular expression patterns for…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also pinyin · pypinyin · zhon · pypinyin-dict · hanzidentifier · hangul-romanize · anyascii · sea-g2p · uroman · orthography2ipa