🔡 Character Encoding Viewer

Ad Slot - Top (728×90)

Enter a character or string

Ad Slot - Middle (728×90)

ASCII Table

Click any cell to load that character into the input box for detailed encoding analysis. Red cells are control characters.

How to Use

This Character Encoding Viewer is a professional tool designed for developers and programming learners. It helps you quickly understand how any character is represented across different encoding systems. Here is a detailed guide:

Basic Lookup: Type any character, string, or emoji into the input field and click the "Analyze" button. The tool will parse each character and display its Unicode code point, UTF-8 byte sequence, UTF-16 encoding, HTML entity, JavaScript escape, CSS escape, URL encoding, and more in a table below. You can directly compare how the same character appears across different encodings.

ASCII Table: The page includes a complete ASCII table (0-127). Click any cell to load that character into the input box. Control characters (0-31 and 127) are highlighted in red, while printable characters are in the default style. This helps you quickly understand the ASCII range and the meaning of special control characters.

One-Click Copy: Every value in the results table is clickable to copy. Hover over an encoded value and the cursor will change to a pointer. Click to copy the value to your clipboard with a confirmation toast. This makes it easy to paste query results directly into your code or documentation.

Batch Queries: While querying a few characters at a time gives the best experience, the tool supports up to 200 characters in a single batch. For long strings, the table scrolls horizontally to ensure all information is visible. You can also enter a single character for a precise lookup.

Use Cases

The Character Encoding Viewer is invaluable across many development and everyday scenarios:

Web Development & XSS Prevention: When building web applications, handling user-supplied text data requires careful attention to XSS attacks. With this tool, you can quickly inspect the HTML entity representation of suspicious characters to ensure proper escaping before rendering. For example, entering <script> shows its HTML entity form, letting you verify that the encoding is correct.

Internationalization (i18n): Correctly handling Unicode characters is critical in multilingual web apps. This tool helps developers understand the byte representation of non-ASCII characters like Chinese, Arabic, or emoji across different encodings, making it easier to troubleshoot mojibake (garbled text). For instance, you can verify that the character 中 occupies 3 bytes in UTF-8 (E4 B8 AD) but only 2 bytes in UTF-16 (4E2D).

API Debugging: When debugging REST APIs, you often need to confirm that special characters in request parameters or response payloads are correctly encoded. This tool lets you instantly see the URL encoding and JavaScript escape sequences for any character, helping you track down encoding issues in API communication. For example, a space is %20 in URL encoding and can be written as \\x20 in JavaScript strings.

Learning Programming: For students learning about character encoding, the ASCII table and Unicode are foundational concepts. This tool provides a visual way to see the correspondence between characters and their numeric values, understand how UTF-8 and UTF-16 work, and deepen your grasp of how computers represent text.

Background Knowledge

A Brief History of Character Encoding: In the early days of computing, the United States established the ASCII (American Standard Code for Information Interchange) standard, which used 7-bit binary numbers to represent 128 characters. As computers went global, different languages needed their own encoding schemes, leading to GB2312/GBK (Chinese), Shift-JIS (Japanese), EUC-KR (Korean), and others. These schemes were mutually incompatible, causing frequent "mojibake" (garbled text) issues. Unicode was created to solve this by assigning every character a unique code point, eliminating encoding chaos.

Why UTF-8 Became Dominant: UTF-8 is one implementation (encoding form) of Unicode, designed by Ken Thompson and Rob Pike for the Plan 9 operating system. Its goal was to be fully ASCII-compatible (English letters and digits take only 1 byte) while supporting all the world's characters. For pure English text, UTF-8 is identical in size to ASCII; for Chinese, each character takes 3 bytes. This variable-length design strikes a perfect balance between compatibility and space efficiency, which is why UTF-8 became the de facto standard for the web (HTML5 default), Linux, and JSON.

JavaScript and Encoding: JavaScript internally uses UTF-16 to represent strings, meaning a single character may occupy 1 or 2 code units. Characters in the BMP (U+0000 to U+FFFF) take 1 code unit, while supplementary plane characters (like emoji and rare CJK characters) require 2 code units (a surrogate pair). Understanding this is essential for correctly handling string length and indexing. ES6 introduced codePointAt and String.fromCodePoint to properly handle all Unicode characters.

FAQ

What is a Unicode code point?

A Unicode code point is the unique numerical identifier assigned to each character in the Unicode standard, typically written as U+XXXX in hexadecimal. For example, the letter A has code point U+0041, and the Chinese character 中 has code point U+4E2D. Unicode currently defines over 140,000 characters covering virtually every writing system in the world.

What is the difference between UTF-8 and UTF-16?

UTF-8 uses 1-4 variable-length bytes per character and is fully ASCII-compatible (English letters and digits take only 1 byte), making it the preferred encoding for the web and Linux systems. UTF-16 uses 2 or 4 bytes and is the internal encoding used by JavaScript, Java, and Windows. UTF-8 is more space-efficient for most text, while UTF-16 can be faster for certain languages.

What is HTML entity encoding used for?

HTML entity encoding is used to represent special characters in HTML documents so they are not misinterpreted by the browser. For example, < represents the less-than sign, and & represents the ampersand. Some characters like the copyright symbol © can be written as &copy; for readability. Encoding untrusted input as HTML entities is a standard practice for preventing XSS attacks.

How do JavaScript escape sequences work?

JavaScript supports multiple escape formats: \\xXX for Latin-1 characters (e.g., \\x41 is A), \\uXXXX for Unicode BMP characters (e.g., \\u4E2D is 中), and \\u{X} for any Unicode character including those outside the BMP (e.g., \\u{1F600} is 😀). The brace notation was introduced in ES6 and supports the full Unicode range.

What is the relationship between URL encoding and percent-encoding?

URL encoding and percent-encoding refer to the same encoding mechanism. It converts non-ASCII characters and special characters into the %XX format (where XX is hexadecimal). For example, a space becomes %20 or +, and the Chinese character 中 becomes %E4%B8%AD. RFC 3986 defines which characters require encoding, and RFC 3987 extends this for international characters.

Is this tool safe to use?

Absolutely safe. All processing happens entirely in your browser with no data sent to any server. The characters you enter are only used for local encoding conversion and never leave your device. The pure front-end architecture guarantees complete data privacy.

Ad Slot - Bottom (728×90)
','café ☕','naïve résumé','😀🎉🚀']; const sample=samples[Math.floor(Math.random()*samples.length)]; document.getElementById('charInput').value=sample; analyzeInput(); }); document.getElementById('charInput').addEventListener('keydown',e=>{if(e.key==='Enter')analyzeInput();}); generateAsciiGrid();