Developer Tools
UTF-8 Byte Counter
Count UTF-8 bytes, Unicode code points, and UTF-16 code units.
UTF-8 encoded size
48 B
48 bytes exactly
Unicode code points
23
JS UTF-16 code units
24
| UTF-8 sequence | Code points | Bytes contributed |
|---|---|---|
| 1 byte (ASCII) | 11 | 11 |
| 2 bytes | 0 | 0 |
| 3 bytes | 11 | 33 |
| 4 bytes | 1 | 4 |
Counts Unicode code points, not user-perceived grapheme clusters. A visible character can contain multiple code points, such as a letter plus a combining mark or some emoji sequences.
About This Tool
Text length is not always the same as byte length. ASCII characters use one byte in UTF-8, while many accented letters, scripts, symbols, and emoji require multiple bytes. This tool measures the UTF-8 encoded size of pasted text and separates that result from Unicode code-point count and JavaScript UTF-16 string length. It is useful when checking database, API, message, storage, or protocol limits that are defined in bytes rather than visible characters.
How To Use It
- Paste or type the exact text whose UTF-8 size you need to measure.
- Read UTF-8 encoded size for the exact byte count and a convenient binary-unit display when the text is larger.
- Compare Unicode code points with JavaScript UTF-16 code units when debugging string-length differences around emoji or supplementary characters.
- Use the sequence breakdown to see how many code points contribute one, two, three, or four UTF-8 bytes.
Examples
Plain ASCII text
The text Hanakash contains eight ASCII code points, so its UTF-8 size is eight bytes and its code-point and UTF-16 code-unit counts are also eight.
Emoji in a JavaScript string
A typical emoji such as 😀 is one Unicode code point encoded as four UTF-8 bytes, but JavaScript string length counts its UTF-16 surrogate pair as two code units.
Combining characters
The sequence e followed by a combining acute accent can look similar to a single precomposed é, but the two forms contain different code points and can have different encoded byte sizes.
Useful Notes
How UTF-8 byte length is calculated
UTF-8 encodes Unicode scalar values using one to four bytes. Code points U+0000 through U+007F use one byte; U+0080 through U+07FF use two; U+0800 through U+FFFF use three; and supplementary code points use four bytes. The tool walks the JavaScript string by Unicode code point and sums those sequence lengths.
Bytes, code points, and visible characters differ
A byte is an encoded storage unit, a Unicode code point is a numbered Unicode value, and a user-perceived character can contain one or several code points. Emoji joined with zero-width joiners and letters with combining marks are common cases where visible-character counting requires grapheme segmentation rather than simple code-point counting.
Why JavaScript string length can surprise you
JavaScript strings use UTF-16 code units. Most Basic Multilingual Plane code points occupy one code unit, while supplementary code points such as many emoji occupy a surrogate pair and therefore increase string length by two. That length is not a UTF-8 byte count.
Normalization can change byte size
Unicode can represent some visually equivalent text with different code-point sequences. This tool measures the exact input as entered and does not normalize it, because changing normalization would change the data being measured.
Local and deterministic measurement
The calculation happens in the browser and does not need an API. The tool does not transform the text before counting, so the result reflects the exact JavaScript string in the editor.
FAQ
Is one character always one UTF-8 byte?
No. ASCII code points use one byte, but other Unicode code points commonly use two, three, or four UTF-8 bytes.
Why is an emoji four UTF-8 bytes but JavaScript length says two?
Many emoji are supplementary Unicode code points. UTF-8 encodes such a code point in four bytes, while UTF-16 represents it with two surrogate code units, which JavaScript string length counts separately.
Does this count grapheme clusters or visible characters?
No. It reports Unicode code points and UTF-16 code units because those are useful for encoding and programming diagnostics. A visible grapheme can contain multiple code points.
Does the tool normalize Unicode before counting?
No. It measures the exact entered sequence. NFC or NFD normalization can alter the code-point sequence and byte length, so automatic normalization would make the measurement less faithful to the input.
Is my text uploaded?
No. This byte-count calculation is performed locally in your browser and does not require sending the text to an API.
Related Tools
Word & Character Counter
PopularInstant word, character, line, and reading-time counts.
Base64 Encode / Decode
PopularConvert plain text and Base64 in either direction.
URL Encode / Decode
Convert URL text to and from percent encoding.
Data Size Converter
Convert bits, bytes, kB, MB, GB, KiB, MiB, GiB, and more.