Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk3 min

How to Convert Numbered Pinyin to Tone Marks in JavaScript

Convert numbered pinyin to tone marks in JavaScript using the vowel-priority rule, with practical guidance on parsing, neutral tone, packages, and Unicode output.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To convert numbered pinyin to tone marks, map tone digits 1–4 to the appropriate accent and place it on the syllable’s vowel in this order: a, then e, then o, otherwise the last vowel. Tone 5 is neutral and usually stays unmarked. For example, Ni3 hao3 ma5? becomes Nǐ hǎo ma?.

This transforms pinyin that already contains tone numbers; it does not convert Chinese characters into pinyin. Here are the implementation choices and details to define before using the conversion in an app.

As an Amazon Associate I earn from qualifying purchases.

What the conversion does

A numbered pinyin syllable ends with a tone digit. The digit determines the tone, while the vowel-placement rule determines which letter receives the mark. The focused JavaScript package pinyin-tone-convert documents this transformation and shows numbered pinyin converted to marked pinyin.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep syllable parsing separate from tone placement. Input may have spaces between syllables, as in Ni3 hao3 ma5?, or may be connected, as in Zhong1guo2ren2. A digit in arbitrary text is not necessarily a pinyin tone, so decide which input forms your function accepts rather than applying conversion indiscriminately.

#1 Best Overall
PATIKIL 2Pcs Chinese Keyboard Stickers Chinese-English Keyboard Stickers
  • This Keyboard Sticker is widely used for a variety of keyboards for Computers, Laptops, Notebooks, and Desktops. They are a good replacement for faded or worn letters key, giving the keyboard a different fresh new look. Converting your keyboard keys to another language is well suited for different language communication, education or language self-learning.
  • Full Size: 180mmx65mm/7.1" x 2.6"(L*W); Each Units Size: 13mm x 11mm/0.5" x 0.4"(L*W); Color: Black Background with Orange White Lettering;
  • The PC keyboard sticker is made of durable PVC material, with a matte texture that will provides a better touching and typing experience close to the original keyboard. Each individual keyboard key sticker is cut neatly, and is easy to apply and remove without glue left.
  • Steps of installation: 1)Wipe the dust off the keyboard with a cloth; 2)Tear each keyboard sticker; 3)Paste it on the corresponding key position; 4)Press hard several times to fully fit.
  • All size above is measured by manual, please allow +/-0.1 inch error.

Implement the tone-mark rule

For each valid syllable, identify its tone digit and choose the marked vowel using this priority:

  1. Mark a if the syllable contains it.
  2. Otherwise, mark e if present.
  3. Otherwise, mark o if present.
  4. If none of those vowels appears, mark the last vowel.

Apply the accent for tones 1–4. Tone 5 conventionally represents neutral tone and remains unmarked in mark notation, so ma5 becomes ma. Dragon Mapper independently documents the same vowel-placement priority: tone number and mark conversion.

Rank #2
2PCS Korean Keyboard Stickers with Tweezer, Replacement Korean-English Keyboard Letters Black Background Orange Lettering for Laptops Notebooks PC Computer Desktop, Korean Keyboard Alphabet Sticker
  • 【Wide Compatibility】 This Korean keyboard stickers specially designed for any laptops, notebooks, PC computers, desktops keyboards, wired keyboard, wireless keyboard, such as Logitech, Apple Macbook iMac, HP, Samsung, Acer, Microsoft Surface, Arteck, DELL, ASUS, Lenovo etc. and other keyboards.
  • 【Premium Materials】 The laptop keyboard stickers are made of durable, long-lasting vinyl material with a matte texture finish. The coating is designed to be durable and will not fade even after prolonged use.
  • 【Renew Worn-Out Keyboards】: These keyboard stickers can adhere firmly, clear and easy to read. They can renew faded or worn-out letters, giving your keyboard a brand-new look while saving you the expense of buying a new keyboard!
  • 【Easy to Install and Remove】: This computer keyboard letter sticker is easy to install and remove, leaving no adhesive residue after removal. You can effortlessly convert your keyboard keys to another language, making it simple and quick to use.
  • 【Package Included】 The Korean keyboard stickers letters set includes 2 x Korean Keyboard Stickers, 1 x Tweezer, and 1 x Microfiber Cleaning Cloth, 1 x Keyboard Cleaning Brush, a complete installation kit set for you to install the keyboard stickers quickly and easily.

A small converter can follow this sequence: parse the accepted syllable or numbered unit, validate its tone, select the target vowel, replace it with the corresponding accented character, and preserve the rest of the input. The vowel rule is compact; the parser and its behavior on malformed input are where applications need an explicit contract.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Define your input and output contract

Before writing a whole-text converter, decide how it should handle these cases:

Rank #3
PATIKIL 3Pcs Chinese English Keyboard Stickers PC Laptop Desktop Computer Clear Background with Black Lettering
  • This Keyboard Sticker is widely used for a variety of keyboards for Computers, Laptops, Notebooks, and Desktops. They are a good replacement for faded or worn letters key, giving the keyboard a different fresh new look. Converting your keyboard keys to another language is well suited for different language communication, education or language self-learning.
  • Full Size: 190mmx70mm/7.5" x 2.8"(L*W); Each Units Size: 13mm x 11mm/0.5" x 0.4"(L*W); Color: Transparent Background with Black Lettering;
  • The PC keyboard sticker is made of durable PVC material, with a matte texture that will provides a better touching and typing experience close to the original keyboard. Each individual keyboard key sticker is cut neatly, and is easy to apply and remove without glue left.
  • Steps of installation: 1)Wipe the dust off the keyboard with a cloth; 2)Tear each keyboard sticker; 3)Paste it on the corresponding key position; 4)Press hard several times to fully fit.
  • All size above is measured by manual, please allow +/-0.1 inch error.
  • Syllable boundaries: Are syllables separated by spaces, or may tone digits mark units in connected text?
  • Accepted digits: Are only tones 1–5 valid? Decide whether invalid values should be rejected, left unchanged, or reported.
  • Malformed units: Specify what happens when a digit has no valid syllable before it, or a unit has no tone digit.
  • Capitalization and punctuation: Preserve capitalization and punctuation if that is part of the desired output. Test cases such as Ni3 hao3 ma5?.
  • Alternative spelling: If your input uses v for ü, define whether and how it is converted.
  • Neutral tone: Decide whether tone 5 is required in input and whether it is removed from marked output.
  • Unicode representation: Choose precomposed accented characters or combining diacritics, and verify the displayed result in the browsers and fonts your application supports.

These are separate formatting and parsing decisions, not changes to the basic vowel-priority rule. PinyinJS documents options for capitalization, punctuation, apostrophes, and grouping, illustrating the kinds of choices a reusable converter may expose: PinyinJS documentation.

Use a package or write a focused function?

Use a package for broader notation support

pinyin-tone-convert documents npm installation, CommonJS usage, conversion of connected pinyin, and the vowel-placement rule. Check its current version and compatibility in the package registry before adding it; the cited documentation does not establish how recently it was released or maintained.

Rank #4
PATIKIL 3Pcs Chinese Keyboard Stickers Chinese-English Keyboard Stickers Black Background with Blue Lettering for Computer Laptop Desktop 4 Type
  • This Keyboard Sticker is widely used for a variety of keyboards for Computers, Laptops, Notebooks, and Desktops. They are a good replacement for faded or worn letters key, giving the keyboard a different fresh new look. Converting your keyboard keys to another language is well suited for different language communication, education or language self-learning.
  • Full Size: 180mmx65mm/7.1" x 2.6"(L*W); Each Units Size: 13mm x 11mm/0.5" x 0.4"(L*W); Color: Black Background with Blue Lettering;
  • The PC keyboard sticker is made of durable PVC material, with a matte texture that will provides a better touching and typing experience close to the original keyboard. Each individual keyboard key sticker is cut neatly, and is easy to apply and remove without glue left.
  • Steps of installation: 1)Wipe the dust off the keyboard with a cloth; 2)Tear each keyboard sticker; 3)Paste it on the corresponding key position; 4)Press hard several times to fully fit.
  • All size above is measured by manual, please allow +/-0.1 inch error.

PinyinJS offers notation helpers including applyToneMark and toneFromNotation. Its syllable utilities can work without loading a Hanzi dictionary: PinyinJS documentation. The project also describes notation formats for marks, trailing numbers, superscript numbers, and no tone, with neutral tone represented without a mark: PinyinJS notation documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Write your own for a tightly controlled input

A custom function is appropriate when you control the input grammar—for example, a known set of space-separated syllables—and can define validation and formatting behavior yourself. Keep parsing, tone validation, vowel selection, and output formatting as distinct steps. This makes it easier to test edge cases without implying that one parser handles every possible pinyin string.

Best Value
Sale
BOGEEL Traditional Chinese Taiwan Phonetic Keyboard Stickers Hongkong Keyboard Label Sticker Background,PVC
  • This is made from of Eco-environment PVC Printing .
  • for Adhesive without harmful
  • Apply for different lapotop and model
  • The sticker is , so keys color is your keyboard color when you sticker. but the is colored like discreption.
  • Easy to use, you do not have to think apply the stickers.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Numbered pinyin is not Hanzi-to-pinyin conversion

A tone-marking function needs pinyin with tone numbers as input. It does not determine the pronunciation of Chinese characters. PinyinJS documents Hanzi conversion separately and notes that readings can depend on word context, which requires lexical data and word-level decisions: PinyinJS documentation.

Check Unicode output in your application

Tone marks can be represented using precomposed accented letters or combining diacritical marks. Pinyin.info discusses historical browser rendering issues and a mixed representation approach, but its browser discussion is not evidence of current compatibility: Pinyin.info on diacritical marks. For a modern web application, verify the chosen output with the browsers and fonts you support; a current compatibility matrix is not established by that historical source.

Quick Recap

Bestseller No. 1
PATIKIL 2Pcs Chinese Keyboard Stickers Chinese-English Keyboard Stickers
PATIKIL 2Pcs Chinese Keyboard Stickers Chinese-English Keyboard Stickers
All size above is measured by manual, please allow +/-0.1 inch error.
$6.89
Bestseller No. 3
PATIKIL 3Pcs Chinese English Keyboard Stickers PC Laptop Desktop Computer Clear Background with Black Lettering
PATIKIL 3Pcs Chinese English Keyboard Stickers PC Laptop Desktop Computer Clear Background with Black Lettering
All size above is measured by manual, please allow +/-0.1 inch error.
$6.99
SaleBestseller No. 5
BOGEEL Traditional Chinese Taiwan Phonetic Keyboard Stickers Hongkong Keyboard Label Sticker Background,PVC
BOGEEL Traditional Chinese Taiwan Phonetic Keyboard Stickers Hongkong Keyboard Label Sticker Background,PVC
This is made from of Eco-environment PVC Printing .; for Adhesive without harmful; Apply for different lapotop and model
$5.04

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.