Skip to content
Converts pinyin with tone numbers to pinyin with tone marks.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

pinyin tone converter 🔢

Converts Mandarin pinyin with tone numbers to pinyin with tone marks.


bao1 guo3

tone marks:
bāo guǒ

how to use

To try out the converter, use the cli tool. This tool prompts the user to input numerical pinyin and returns pinyin with tone marks.

The main function 'convert_from_numerical_pinyin' is found in This function takes a numerical pinyin string ("bao1 guo3") as input and returns a converted string ("bāo guǒ").

from numerical_pinyin_converter import convert_from_numerical_pinyin

convert_from_numerical_pinyin("bao1 guo3") # Returns bāo guǒ

As an example use case, csv_example includes a wrapper for the converter to take a csv file as input and output a new, modified csv file. There are example original and modified csv files included.

what is pinyin

Pinyin is the most commonly used romanization system for Mandarin. Numerical pinyin is often used to avoid issues with utf8 encoding. Where utf8 encoding is not a concern, pinyin with tone marks is generally preferred.

You can’t perform that action at this time.