Open source

pinyin-to-bopomofo

pinyin-to-bopomofo offers a lightweight way to translate between pinyin (commonly used in mainland China) and bopomofo/zhuyin (commonly used in Taiwan).

Published July 31, 2025 (Updated July 31, 2025)

Translate between pinyin with tone marks (i.e. zhào), pinyin with numbers (i.e. zhao4), and bopomofo/zhuyin (i.e. ㄓㄠˋ).

This package is used in MandoFlow, the best way to learn Mandarin Chinese online by turning your favorite YouTube videos into interactive language learning lessons.

Repository: https://github.com/AustinShelby/pinyin-to-bopomofo

JSR: https://jsr.io/@austinshelby/pinyin-to-bopomofo

Installation

You can use pinyin-to-bopomofo with both Deno and Node.js.

Deno

deno add jsr:@austinshelby/pinyin-to-bopomofo

Node.js

npx jsr add @austinshelby/pinyin-to-bopomofo

Quickstart

Translate between pinyin and bopomofo.

import {
bopomofoToPinyin,
pinyinToBopomofo,
} from "@austinshelby/pinyin-to-bopomofo";

const bopomofo = pinyinToBopomofo("zhào"); // ㄓㄠˋ

const pinyin = bopomofoToPinyin("ㄓㄠˋ"); // zhào

Translate between pinyin (tone numbers) and bopomofo.

import {
bopomofoToPinyin,
pinyinToBopomofo,
} from "@austinshelby/pinyin-to-bopomofo";

const bopomofo = pinyinToBopomofo("zhao4", "NUMBER"); // ㄓㄠˋ

const pinyin = bopomofoToPinyin("ㄓㄠˋ", "NUMBER"); // zhao4

Changelog

1.0.0

Release!


Austin Shelby

Austin Shelby

I am a product engineer, instructor, and public speaker with over half a decade of hands-on experience in the entire software development process. I am passionate about building high-performing web applications and sharing what I have learned along the way.