String Length Counter

Runs in browser Formatting

Understand why "length" differs between systems: this tool reports grapheme clusters, Unicode code points, UTF-16 code units (JavaScript .length) and UTF-8 / UTF-16 byte sizes — essential for database column limits and API validation.

Privacy: This tool runs entirely in your browser. Your input never leaves your device.
Loading tool…

Why do character counts differ between tools?

Because "character" can mean three things: bytes (what a database column or an HTTP body limit measures), code points (what most programming languages count) or grapheme clusters (what a person sees — an emoji with a skin tone, or an Arabic letter with its diacritics, is one grapheme but several code points and even more bytes). Unicode defines grapheme and word boundaries in UAX #29; a length validation that counts one way in the browser and another way on the server will accept or reject different input.

How to use String Length Counter

  1. Paste the string you want to measure.
  2. Compare the five length figures to the limit your system enforces.
  3. Use the breakdown to find hidden or combining characters.

String Length Counter features

  • Grapheme clusters, code points, UTF-16 units and UTF-8 / UTF-16 byte sizes side by side
  • Detects surrogate pairs, combining marks, zero-width and control characters
  • Per-character breakdown with code point, encoded size and Unicode category
  • Script detection (Latin, Arabic, Devanagari, CJK, emoji…)
  • Live results as you type or paste

String Length Counter example

Why an emoji string breaks a VARCHAR(10) column

Input:

🚀👨‍👩‍👧 مرحبا

Output:

Graphemes 8 · Code points 12 · UTF-16 units 16 · UTF-8 bytes 33

Frequently asked questions about String Length Counter

Why does JavaScript report a different length than my database?

JavaScript counts UTF-16 code units, so an emoji is 2. MySQL VARCHAR(n) counts characters (code points) but its byte limit depends on the collation, and PostgreSQL counts characters. This tool shows all of these side by side.

What is a grapheme cluster?

The unit a reader perceives as one character. The family emoji 👨‍👩‍👧 is one grapheme but five code points (three people joined by two zero-width joiners); "é" can be one or two code points depending on normalisation.

How is UTF-8 size calculated?

ASCII characters use 1 byte, most Latin/Arabic/Hebrew letters 2, Devanagari and CJK 3, and emoji or other astral characters 4 bytes.

Does the breakdown show invisible characters?

Yes — zero-width joiners, BOMs, control characters and combining marks are listed with their code points so you can spot hidden characters in copied text.

Technical notes

Graphemes are counted with Intl.Segmenter when the browser provides it, falling back to code points otherwise. UTF-8 size comes from TextEncoder, which is exact for any input including unpaired surrogates (encoded as U+FFFD).

References