
Users paste ๐๐จ๐ฅ๐, โฌโฏโฏ๐ and ๏ผจ๏ฝ ๏ฝ๏ฝ๏ฝ text into forms, and your search or duplicate check treats each one as a different string. Here is a small, tested way to turn most of it back into plain text.
The problem
Styled text is made of different Unicode characters, not fonts. So "๐๐๐ฅ๐ฅ๐จ" === "Hello" is false, and a search for "hello" will not match.
Step 1: NFKC normalization
JavaScript has String.prototype.normalize. The "NFKC" form converts many compatibility characters to their plain equivalents:
"๐๐๐ฅ๐ฅ๐จ".normalize("NFKC"); // "Hello" (math bold)
"โ๐๐๐๐".normalize("NFKC"); // "hello" (math italic, with the U+210E "h")
"โฌโฏโฏ๐".normalize("NFKC"); // "Beer" (math script)
"๏ผจ๏ฝ
๏ฝ๏ฝ๏ฝ".normalize("NFKC"); // "Hello" (fullwidth)
"โฝโโโโ".normalize("NFKC"); // "Hello" (circled)
Step 2: what NFKC does not fix
Two common styles are left alone:
- Strikethrough and "glitch" text use combining marks placed after each letter. NFKC keeps them.
- Small caps such as
แดสแดcome from a different block and are not mapped back.
For combining marks, decompose the string first and then remove the marks in the combining range:
const stripMarks = (s) =>
s.normalize("NFKD").replace(/[\u0300-\u036f]/g, "");
stripMarks("s\u0336t\u0336r\u0336i\u0336k\u0336e\u0336"); // "strike"
Putting it together
export function toPlain(input) {
return input
.normalize("NFKD") // split letters from their marks
.replace(/[\u0300-\u036f]/g, "") // drop combining marks
.normalize("NFKC"); // map styled letters to plain ones
}
toPlain("๐๐๐ฅ๐ฅ๐จ"); // "Hello"
toPlain("โฌโฏโฏ๐"); // "Beer"
toPlain("s\u0336t\u0336r\u0336i\u0336k\u0336e\u0336"); // "strike"
Caveats
- Accents are removed too.
"cafรฉ"becomes"cafe". UsetoPlainonly for search keys and comparisons, never for the text you store or show. - Small caps and other lookalikes stay. If you need to block lookalike characters, you need a separate list.
- Keep the original. Store what the user typed, and use the normalized copy only to compare and index it.
Try it on real examples
To get some styled text to test with, I use the FilesSnap font generator, which converts plain text into many of these styles.
About the author
- I run FilesSnap, a free tool that turns plain text into hundreds of fancy font styles. I write about fonts, Unicode and small web tools.
Comments
Join the discussionNo comments yet. Be the first to comment.


