https://github.com/pepebecker/pinyin-convert
Convert Hanzi to Pinyin and convert between Pinyin with tone marks and Pinyin with tone numbers.
https://github.com/pepebecker/pinyin-convert
chinese convert hanzi mandarin pinyin tone
Last synced: about 2 months ago
JSON representation
Convert Hanzi to Pinyin and convert between Pinyin with tone marks and Pinyin with tone numbers.
- Host: GitHub
- URL: https://github.com/pepebecker/pinyin-convert
- Owner: pepebecker
- License: mit
- Created: 2017-04-18T23:53:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-06-16T14:37:34.000Z (over 2 years ago)
- Last Synced: 2025-08-12T11:38:04.651Z (2 months ago)
- Topics: chinese, convert, hanzi, mandarin, pinyin, tone
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/pinyin-convert
- Size: 168 KB
- Stars: 18
- Watchers: 2
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pinyin Convert
[](https://www.npmjs.com/package/pinyin-convert)
[](https://travis-ci.org/pepebecker/pinyin-convert)
[](https://greenkeeper.io/)
[](https://david-dm.org/pepebecker/pinyin-convert)
[](https://david-dm.org/pepebecker/pinyin-convert#info=devDependencies)
[](https://opensource.org/licenses/MIT)
[](https://gitter.im/pepebecker)Checkout the [`pinyin-webinterface`](https://github.com/pepebecker/pinyin) which uses this module in the backend.
## Install
```shell
npm install pinyin-convert
```## Usage
```js
const convert = require('pinyin-convert')convert('Test: wǒ de māo xǐhuān hē niúnǎi')
.then(console.log) // Te wo3 de mao1 xi3 huan1 he1 niu2 nai3convert('Test: wo3 de mao1 xi3huan1 he1 niu2nai3')
.then(console.log) // Te wǒ de māo xǐ huān hē niú nǎiconvert('Test: wǒ de māo xǐhuān hē niúnǎi', { everything: true })
.then(console.log) // Test: wo3 de mao1 xi3huan1 he1 niu2nai3convert('Test: wo3 de mao1 xi3huan1 he1 niu2nai3', { everything: true })
.then(console.log) // Test: wǒ de māo xǐhuān hē niúnǎiconvert('我的猫喜欢喝牛奶')
.then(console.log)
// [ 'wǒ ', [ 'de', 'dī', 'dí', 'dì' ], ' māo xǐ huan ', [ 'hē', 'hè' ], ' niú nǎi' ]convert('我的猫喜欢喝牛奶', { segmented: true })
.then(console.log)
// [ 'wǒ ', [ 'de', 'dī', 'dí', 'dì' ], ' māo xǐhuan ', [ 'hē', 'hè' ], ' niúnǎi' ]convert('我的猫喜欢喝牛奶', { numbered: true, segmented: true })
.then(console.log)
// [ 'wo3 ', ['de5', 'di1', 'di2', 'di4'], ' mao1 xǐ5huan1 ', ['he1', 'he4'], ' niu2nai3' ]convert('Test: 我的猫喜欢喝牛奶', { everything: true, segmented: true })
.then(console.log)
// [ 'test: wǒ ', [ 'de', 'dī', 'dí', 'dì' ], ' māo xǐhuan ', [ 'hē', 'hè' ], ' niúnǎi' ]
```## Related
- [`pinyin-utils`](https://github.com/pepebecker/pinyin-utils)
- [`pinyin-split`](https://github.com/pepebecker/pinyin-split)
- [`find-hanzi`](https://github.com/pepebecker/find-hanzi)
- [`hsk-words`](https://github.com/pepebecker/hsk-words)
- [`cedict`](https://github.com/pepebecker/cedict)
- [`mdbg`](https://github.com/pepebecker/mdbg)
- [`pinyin-or-hanzi`](https://github.com/pepebecker/pinyin-or-hanzi)
- [`hanzi-to-pinyin`](https://github.com/pepebecker/hanzi-to-pinyin)
- [`pinyin-rest`](https://github.com/pepebecker/pinyin-rest)
- [`pinyin-api`](https://github.com/pepebecker/pinyin-api)
- [`pinyin-bot-core`](https://github.com/pepebecker/pinyin-bot-core)
- [`pinyin-telegram`](https://github.com/pepebecker/pinyin-telegram)
- [`pinyin-messenger`](https://github.com/pepebecker/pinyin-messenger)
- [`pinyin-line`](https://github.com/pepebecker/pinyin-line)
- [`pinyin-chrome`](https://github.com/pepebecker/pinyin-chrome)
- [`pinyin-cli`](https://github.com/pepebecker/pinyin-cli)
- [`hanzi-cli`](https://github.com/pepebecker/hanzi-cli)## Contributing
If you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/pepebecker/pinyin-convert/issues).