What is a surrogate pair?

Every Unicode character has a number, its code point. UTF-16, the way JavaScript, Java, C# and Windows hold text, writes most characters as one 16-bit code unit, which covers the first 65,536 code points: the Basic Multilingual Plane, home to nearly every letter in everyday use. A character beyond it, such as most emoji, takes two code units instead: a high surrogate from U+D800 to U+DBFF followed by a low surrogate from U+DC00 to U+DFFF. Together they form a surrogate pair, and neither half means anything alone.

Surrogate pairs trip up code that counts or cuts text. In JavaScript, "🎂".length is 2, so one emoji uses up two places of a character limit, and cutting text after a fixed number of code units can split a pair and leave a broken �. The same characters take four bytes in UTF-8, which a MySQL column with the older utf8 character set can't store, while utf8mb4 can. Checking text first tells you whether it holds any.

Tool description

Type or paste text into the Text box, and the result shows as you type: "The text contains surrogate pairs." or "The text has no surrogate pairs." The text is checked exactly as typed: spaces and line breaks count as characters, but they're never part of a pair. An empty box shows no result, and the page has no settings.

What contains surrogate pairs

  • Most emoji, such as 🎂, 🌸 and 🎉, skin tones and flags included
  • Fancy letters from the mathematical alphabets, such as 𝓗𝓮𝓵𝓵𝓸 or 𝐁𝐨𝐥𝐝, which people paste into social media profiles
  • Rare Chinese characters, such as 𠮷, a form of 吉 used in some Japanese family names
  • Musical symbols such as 𝄞, and letters of historic scripts

What doesn't

  • Letters of every modern alphabet, accented letters such as é, and everyday Chinese, Japanese and Korean characters
  • Older emoji and symbols inside the Basic Multilingual Plane, such as ❤️, ☀️, ☕, ⭐, ✨ and ©

Good to know

  • Since some emoji take a single code unit, this isn't an emoji detector: a ☕ alone gives "The text has no surrogate pairs." To take emoji out of a text, use the Emoji Remover.
  • To see how many bytes a text takes in UTF-16, where every pair takes four, use the Text to UTF-16 Bytes Calculator.

Features

  • Finds characters stored as two UTF-16 code units
  • Spots emoji, fancy letters and rare Chinese characters
  • Checks the text exactly as typed
  • Results as you type, with no button to press
  • Runs in your browser, so nothing you type is sent anywhere