About the Unicode Converter
Every character has a Unicode code point, but each programming language and format writes it differently, which causes confusion when copying text between systems. This Unicode converter turns text into U+ code points, JavaScript and JSON escapes, Python escapes, CSS escapes, HTML entities or UTF-8 bytes, and decodes any of those back into text: é is U+00E9. It helps when debugging garbled characters or writing non-English text and emoji into code.
Encoding works character by character, using full code points, so emoji and other characters outside the Basic Multilingual Plane are handled correctly: they become a single \u{…} escape in modern JavaScript and HTML, or a surrogate pair of two \u escapes in classic JavaScript and JSON. You can escape only non-ASCII characters, which keeps text readable, or every character. Decoding recognizes U+XXXX, \uXXXX (including surrogate pairs), \u{…}, \UXXXXXXXX, &#x…; and &#…; and leaves everything else as it is.
Example: café 😀 becomes caf\u00e9 \ud83d\ude00 in JavaScript form, café 😀 in HTML form and U+0063 U+0061 U+0066 U+00E9 U+0020 U+1F600 as code points. Decoding caf\u00e9, 😀 and U+0041 gives café, 😀 and A.
For bytes in other forms, see the text to hex converter, text to binary converter and text to ASCII converter. To escape whole strings for JSON use JSON escape, and for HTML special characters the HTML encoder.
How to use the Unicode Converter
- Choose encode or decodeText to escapes, or escapes back to text.
- Pick the formatU+ code points, JavaScript, ES6, Python, CSS, HTML hex or decimal, UTF-8 or UTF-16.
- Choose which charactersOnly non-ASCII characters, or every character.
- Copy the resultPaste it into your code, stylesheet or document.
Unicode Converter features
- U+XXXX code points
- JavaScript and JSON \u escapes with surrogate pairs
- ES6 \u{…}, Python \U and CSS escapes
- HTML hex and decimal entities
- UTF-8 and UTF-16 code units
- Decodes mixed escapes back to text
- Escape all or only non-ASCII
Common uses
- Escaping text for JavaScript and JSON
- CSS content values and icon fonts
- HTML entities for special characters
- Debugging mojibake and encoding errors
- Looking up code points of emoji
Unicode in practice: Urdu letters and their code points, normalisation, the Pakistan flag emoji, joining controls and right-to-left tricks
Unicode is what lets Urdu, English, emoji and every other script share the same text. Looking at code points explains many puzzling behaviours: words that look identical but do not match, flags made of two invisible letters, characters that change how Urdu letters join and file names that appear to end in the wrong extension. This guide examines Urdu letters and covers each of these cases.
A worked example: پاکستان
The word پاکستان is seven code points: U+067E peh, U+0627 alef, U+06A9 keheh, U+0633 seen, U+062A teh, U+0627 alef again and U+0646 noon. Urdu uses the Arabic block of Unicode, with letters added for sounds Arabic lacks, such as ٹ U+0679, ڈ U+0688, ڑ U+0691, ں U+06BA, ے U+06D2, ہ U+06C1 and ھ U+06BE. Knowing these code points helps when searching, validating and debugging Urdu text.
Look-alike letters
Some Urdu letters have Arabic look-alikes with different code points: Urdu keheh U+06A9 and Arabic kaf U+0643, Urdu yeh U+06CC and Arabic yeh U+064A, and heh goal U+06C1 and Arabic heh U+0647. Text typed on different keyboards may mix them, so searches and duplicate checks fail. Normalising these letters to the Urdu forms before storing or comparing text solves the problem.
Normalisation
The same visible character can sometimes be written in more than one way. The letter é can be a single code point, U+00E9, or e followed by a combining accent, U+0065 U+0301. Unicode normalisation forms, such as NFC, convert text to one consistent form. Some systems, including older Mac file systems, stored names in the decomposed form, which caused files to appear duplicated or missing when copied elsewhere.
The Pakistan flag emoji
Flag emoji are made from two regional indicator letters. The Pakistan flag is U+1F1F5 U+1F1F0, the indicators for P and K, which apps display together as a single flag. In JavaScript the flag has a length of 4, because each indicator needs two UTF-16 code units, which is why counting characters in emoji-rich text gives surprising results.
Joining controls in Urdu
The zero-width non-joiner, U+200C, prevents two letters from joining, and the zero-width joiner, U+200D, forces a connection. In Urdu and Persian typing, the non-joiner controls word shapes where letters would otherwise connect wrongly. In emoji, the joiner combines several emoji into one, such as family groups. These invisible characters explain why some text has more code points than visible letters.
Right-to-left tricks
The right-to-left override, U+202E, reverses the display of the text that follows. Attackers have used it to make a file named with a hidden override look like it ends in .txt when it really ends in .exe. Mail systems and security tools now flag such names, but checking code points of suspicious file names reveals the trick immediately.
Missing glyphs
When a font lacks a character, it shows an empty box, sometimes called tofu. The text is still correct; only the font is missing the glyph. For Urdu, choosing a font with good Nastaliq or Naskh coverage, and providing fallbacks in CSS, avoids boxes for less common letters.
Counting characters
What people see as one character may be several code points, and in JavaScript each code point above U+FFFF counts as two. For limits such as usernames and messages, decide whether to count bytes, code points or visible characters, called grapheme clusters, and use functions that match that choice.
Common mistakes
- Mixing Arabic and Urdu look-alike letters in stored text.
- Comparing text without normalising it first.
- Counting emoji with string length in JavaScript.
- Ignoring invisible control characters in file names.
Related tools
To count characters in text, use Character Counter. To find or insert invisible characters, try Invisible Text Generator, and to browse emoji by name, Emoji Picker.
Finding characters by name
Every Unicode character has an official name, such as ARABIC LETTER YEH BARREE for ے. Searching for a name, or browsing with Windows Character Map or the macOS Character Viewer, finds characters that are hard to type and shows their code points, which can then be converted into any escape format here.
Storing emoji in databases
MySQL's older utf8 character set stores at most three bytes per character, which is not enough for emoji and some rarer characters. Saving them causes errors or silently truncated text. Databases and tables should use utf8mb4 so every Unicode character, including the Pakistan flag, can be stored.
Sorting Urdu text
Code point order does not match Urdu alphabetical order, because letters added for Urdu sit later in the Unicode block than their alphabetical position. Sorting Urdu names by code point therefore misplaces letters such as ٹ. Locale-aware sorting, for example with JavaScript's Intl.Collator set to Urdu, orders words as readers expect.
Privacy
Conversion runs in your browser. Your text is not uploaded or stored.
Frequently asked questions
What is a Unicode code point?
The number Unicode assigns to a character, written as U+ followed by at least four hex digits: U+0041 is A, U+00E9 is é and U+1F600 is 😀. There are 1,114,112 possible code points.
How do I write Unicode in JavaScript?
Use \uXXXX for characters up to U+FFFF, such as \u00e9, and either a surrogate pair (\ud83d\ude00) or the ES6 form \u{1F600} for characters beyond. JSON allows only the \uXXXX form.
How do I write Unicode in HTML?
Use a numeric character reference: 😀 in hexadecimal or 😀 in decimal. With UTF-8 pages you can usually type the character directly instead. Named references such as é also work for many common characters.
How do I use Unicode in CSS?
Write a backslash and the hex code point, such as content: "\1F600"; add a space after the code if the next character is a hex digit, so it is not read as part of the code.
What is a surrogate pair?
UTF-16, used by JavaScript strings, stores characters above U+FFFF as two 16-bit units, a high and a low surrogate. 😀 (U+1F600) is D83D DE00.
What is the difference between UTF-8 and UTF-16?
Both can encode every Unicode character. UTF-8 uses one to four bytes and matches ASCII for English text, which is why it dominates the web. UTF-16 uses two or four bytes and is used inside JavaScript, Java and Windows.
Can it decode mixed escapes?
Yes. A string such as caf\u00e9 😀 U+0041 is decoded in one go. Text that is not an escape is left unchanged. Surrogate pairs are joined into one character, so the two escapes for an emoji give the emoji itself.
How do I find the code point of an emoji?
Paste the emoji and choose U+ code points. Some emoji are several code points joined together, such as flags or family emoji, and each part is listed.