Inspect Unicode · browser-local

UTF-8 Byte Counter

Measure the encoded size of text and see why a single visible character can occupy multiple bytes or code points. This is useful for APIs, databases, payloads, and fields whose limits are not human-visible character counts.

Works on up to 5,000 characters and 20,000 code points per field (at most 64 code points per character), processed in your browser.

7 graphemes13 code points35 bytes

Live result

Output

35UTF-8 bytes
7Graphemes
13Code points
18UTF-16 units

Good fit

Use this tool when

  • An API or database field has a UTF-8 byte limit.
  • Emoji make a string larger than expected.
  • You need to explain different definitions of character length.

Keep the original

Avoid it when

  • The destination limit is explicitly measured in graphemes.
  • You need compressed, encrypted, or transport-framed size.
  • The target encoding is not UTF-8.
01

Reviewed truth vectors

Examples that expose the edge cases

InputA
Output1 byte · 1 code point · 1 grapheme

ASCII uses one UTF-8 byte.

Inputé
Output2 bytes · 1 code point · 1 grapheme

The precomposed letter needs two UTF-8 bytes.

Input👨‍👩‍👧‍👦
Output25 bytes · 7 code points · 1 grapheme

A visible family emoji is a sequence.

02

Transparent implementation

How it works

  1. 01

    Encode the string with the browser TextEncoder.

  2. 02

    Segment user-perceived graphemes with Intl.Segmenter.

  3. 03

    Count code points and UTF-16 units separately for comparison.

03

Known limitations

What the result cannot promise

The count excludes HTTP, JSON escaping, compression, and protocol overhead.

A platform may document characters without defining its counting model.

Ill-formed UTF-16 is replaced during UTF-8 encoding.

04

Questions before copying

Frequently asked questions

Why is an emoji four bytes?

Most single emoji code points are outside the Basic Multilingual Plane and encode as four UTF-8 bytes.

Why can one grapheme have many bytes?

A grapheme can combine several code points, such as a family emoji joined by zero-width joiners.

Does JSON have the same size?

Not always. Escaping, quotes, property names, and the transport envelope add bytes beyond the text itself.

What is the difference between characters and bytes?

A character is one user-perceived symbol, while a byte is a unit of its UTF-8 encoding. An ASCII letter is one byte, an accented letter such as é is two, most CJK characters are three, and many emoji are four.

05

Testing and sources

How this tool is tested

GlyphSift Editorial — Text-engine notes written and reviewed by Hommer Zhao, Founder & General Manager

GlyphSift Editorial is the site's writing and review process, led by Hommer Zhao, who is accountable for every tool page and correction. Each tool's examples are written against real Unicode edge cases and checked against the engine before the page is published.

Each tool page is reviewed against the same six input classes the engine is tested with — ASCII, emoji, combining marks, non-Latin scripts, empty input, and 5,000-grapheme input — and cannot become eligible if it is only a parameter variation of another page.

Automated evidence

  • Tool-contract & coverage suiteShared suite · 37 cases across all tools it covers

    tests/tools-30.test.mjs mirrors the ToolRunner dispatch and asserts every registered engineId returns the contracted output shape, plus a coverage guard: every style keeps one output character per input character with unmapped characters passed through in place, and strikethrough, zalgo and upside-down never drop or split a grapheme cluster.

    Run in: node --test after a production build (vinext build)
  • Rendered-HTML suiteShared suite · 26 cases across all tools it covers

    tests/rendered-html.test.mjs renders the deployed server bundle and asserts the Unicode-version manifest and each wave's tool markup are present in the server-rendered HTML.

    Run in: node --test against the built dist/server bundle
  • Unicode inspection suiteShared suite · 21 cases across all tools it covers

    tests/unicode-inspection.test.mjs verifies grapheme/code-point/byte counting and hidden-control detection using explicit \u escapes for combining and bidirectional characters.

    Run in: node --test against the runtime's Unicode data
  • Compatibility risk suiteShared suite · 13 cases across all tools it covers

    tests/compatibility.test.mjs checks that bidirectional controls, invisible characters, mixed scripts, and NFKC-changing input raise the documented risk status, and that safe-text stripping preserves ordinary content.

    Run in: node --test, deterministic analyzer

Standards this tool follows