pypinyin
汉字拼音转换模块/工具.
Decision gist · record as of 2026-08-14
Yes. pypinyin is a mature, actively maintained library with no known vulnerabilities, permissive licensing, and low installation friction. It is the standard tool for Chinese-to-pinyin conversion in Python and handles the complexity of context-aware pronunciation selection well. Install it if you need to work with Chinese character romanization; the only caveat is that accuracy depends on proper word segmentation and may require custom dictionary augmentation for domain-specific or rare characters.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction installation with minimal dependencies.
- The package is actively maintained with a recent commit on 2026-07-20 and has accumulated 5352 stars, indicating stable, long-running community use.
License · maintenance · safety
MIT (permissive) — MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
last release 2025-07-20 (390 days) · last repo commit 2026-07-20 · 5,352 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,782,631 downloads/mo, #3,566 on PyPI
Alternatives
Verify before relying
pip install pypinyin
from pypinyin import pinyin, lazy_pinyin, Style
# Basic conversion
result = pinyin('中心')
# Returns: [['zhōng'], ['xīn']]
# With heteronyms (multiple pronunciations)
result = pinyin('中心', heteronym=True)
# Returns: [['zhōng', 'zhòng'], ['xīn']]
# Different style (first letter only)
result = pinyin('中心', style=Style.FIRST_LETTER)
# Returns: [['z'], ['x']]- Whether the package's pinyin accuracy is sufficient for production use without custom dictionary augmentation
- Performance characteristics when processing large volumes of Chinese text
- Behavior with rare or non-standard Chinese characters not in the bundled dictionaries
What it is and what it does
pypinyin is a Chinese character-to-pinyin conversion library that transliterates hanzi (Chinese characters) into their romanized pronunciation forms. It handles context-aware pronunciation selection for multi-pronunciation characters (heteronyms), supports multiple output styles (tone marks, tone numbers, bopomofo notation, Wade-Giles romanization, initials/finals extraction), and includes a command-line tool for quick conversions.
The library uses embedded pinyin and phrase data to make intelligent decisions about which pronunciation to use based on word context. It supports both simplified and traditional Chinese, offers customizable output formatting, and allows users to override or extend the built-in pronunciation dictionaries. Common use cases include adding pronunciation annotations to Chinese text, sorting Chinese strings phonetically, and enabling search-by-pinyin functionality in applications.
Use it for
- Add pinyin annotations above Chinese characters in educational materials or textbooks
- Implement search-by-pinyin functionality in applications handling Chinese text
- Sort lists of Chinese names or terms alphabetically by their pinyin pronunciation
- Extract initial consonants or final vowel sounds from Chinese characters for linguistic analysis
- Convert Chinese text to Wade-Giles or bopomofo notation for specialized linguistic or historical purposes
- Batch process Chinese documents to generate phonetic transcriptions for accessibility or text-to-speech systems
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
pypinyin is a mature, actively maintained library with no known vulnerabilities, permissive licensing, and low installation friction. It is the standard tool for Chinese-to-pinyin conversion in Python and handles the complexity of context-aware pronunciation selection well. Install it if you need to work with Chinese character romanization; the only caveat is that accuracy depends on proper word segmentation and may require custom dictionary augmentation for domain-specific or rare characters.
Install
pypinyin on PyPI
Before you install
Low friction installation with minimal dependencies. The package is actively maintained with a recent commit on 2026-07-20 and has accumulated 5352 stars, indicating stable, long-running community use.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install pypinyin
from pypinyin import pinyin, lazy_pinyin, Style
# Basic conversion
result = pinyin('中心')
# Returns: [['zhōng'], ['xīn']]
# With heteronyms (multiple pronunciations)
result = pinyin('中心', heteronym=True)
# Returns: [['zhōng', 'zhòng'], ['xīn']]
# Different style (first letter only)
result = pinyin('中心', style=Style.FIRST_LETTER)
# Returns: [['z'], ['x']]
Verify before relying
- Whether the package's pinyin accuracy is sufficient for production use without custom dictionary augmentation
- Performance characteristics when processing large volumes of Chinese text
- Behavior with rare or non-standard Chinese characters not in the bundled dictionaries
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release !=3.0.*,!=3.1.*,!=3.2.*,<4,>=2.6 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagesargparseenum34typing |
| Maintenance | Actively maintained 390 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,782,631 / month, #3,566 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Text ProcessingTopic :: Utilities |
Evidence: pypinyin-0.55.0-py2.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 text pronunciation”
- pypinyinConverts Chinese characters to pinyin (romanized pronunciation) with…
- pypinyin-dictProvides alternative pinyin (romanized Chinese) data sources to…
- pinyinConverts Chinese characters to pinyin (romanized Mandarin…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities 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.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
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.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also pypinyin-dict · xpinyin · zhon · pinyin · hangul-romanize · OpenCC · wetext · zhconv · hanzidentifier · cn2an