piapia123
en

UTF-8 Bytes and Encodings, Side by Side

Encoding

Everything runs locally in your browser — nothing is uploaded

Input
Drop a file here to load its contents
Output

Lay out every representation of a piece of text next to each other: UTF-8 bytes, Unicode code points, the percent-encoding URLs use, HTML entities (decimal and hexadecimal) and the `\u` escapes JavaScript and Java expect. This is not a converter — for any single conversion there is a more focused tool on this site (URL encoder, HTML entities, Unicode escapes). It answers a different question: how do the several forms of the same characters compare. Debugging a protocol, reading someone else's config, working out why non-ASCII text turns into mojibake somewhere, all want these columns at once. The last row deliberately separates the character count from the byte count: when those two numbers differ, UTF-8 is doing its work — a CJK character takes 3 bytes, an emoji 4, while ASCII takes 1.

Features

  • Six representations at once: bytes, code points, percent-encoding, two kinds of HTML entity, and Unicode escapes
  • Each row copies on its own — no hand-selecting a slice out of a long string
  • Split by code point, so emoji are never cut into two orphaned surrogate halves
  • Characters outside the BMP are written as surrogate pairs (\ud83d\ude00) that paste straight into config files
  • Character count and byte count kept separate — the UTF-8 expansion at a glance
  • Runs entirely in the browser; nothing is uploaded

How to use

  1. Paste your text into the input box
  2. Results appear as you type, one row per representation
  3. Click a row's copy button to take just that value
  4. Use Copy all when you want the whole block

FAQ

Why are the character and byte counts different?
Because UTF-8 is a variable-length encoding: ASCII characters (English letters, digits, punctuation) take 1 byte, Latin supplements and Greek take 2, CJK characters 3, and emoji or rare characters 4. So two CJK characters are 2 characters and 6 bytes, while "a" plus one CJK character plus one emoji is 3 characters and 8 bytes. A database `varchar(10)` counts characters and stores ten CJK characters fine — but a field measured or truncated in bytes holds only three. That row is where such problems come from.
How is this different from the URL encoder?
The percent-encoding row is the same thing, but the purpose differs. url-encode is a converter, with options for which characters to encode and whether spaces become + or %20, and its output is the answer. This is a comparison view, showing six forms of the same content at once. Use the focused tool to convert; use this to see what a string actually contains.
Why do emoji escapes come in two halves?
Because an emoji such as U+1F600 sits above the Basic Multilingual Plane, and a single UTF-16 code unit — what JavaScript and Java use — holds only 16 bits, not enough for it. It must therefore be written as a surrogate pair, \ud83d\ude00. The shorter \u{1F600} form exists, but Java properties files, older JSON parsers and many template engines reject it. This tool emits the surrogate pair, because pasting into a config file that works is the most common reason to be here.
Why two kinds of HTML entity?
The decimal form 中 and the hexadecimal form 中 denote the same character, and browsers accept both. It is purely convention: both appear in the wild, and some older editors or template engines accept only one. Listing both saves you a second conversion to satisfy a particular tool.

Related tools