String Length Calculator

Show length in characters, UTF-16 units, code points and UTF-8 bytes.

The String Length tool shows how long a piece of text is in several different ways at once: graphemes, code points, UTF-16 units, UTF-8 bytes and UTF-16 bytes. This matters for emoji, accents and non-Latin text, where the answer to how long is it depends on what you measure.

Why does a string have several lengths?

A string can be measured at different levels. A grapheme is what a reader sees as one character, such as a letter, an emoji or a flag. A code point is a single Unicode value, and one grapheme can be made of several. UTF-16 is the encoding JavaScript uses internally, and the length property counts its 16-bit code units, so any code point above U+FFFF takes two. UTF-8 is the encoding used on the web and in files, and it uses one to four bytes per code point. Databases, APIs and form fields may count in any of these. A family emoji is one grapheme but five code points, eight UTF-16 units and 18 UTF-8 bytes, which explains why a limit check that looks fine in one unit fails in another.

How to use String Length Calculator

  1. Enter your text Type or paste into the Text box. An emoji is a good test.
  2. Read the cards Check Graphemes (what users see), Code points, UTF-16 units (JS .length), UTF-8 bytes, UTF-16 bytes and Lines.
  3. Compare with your limit Pick the card that matches how your system counts and compare.
  4. Compare normal and combined forms Try e followed by a combining accent against the single character é to see how code points differ while graphemes match.

Frequently asked questions

Which number should I use for a character limit?

It depends on the system. Users usually think in graphemes, JavaScript string.length uses UTF-16 units, and many databases and protocols count bytes or code points. Check the documentation of the system that enforces the limit.

Why is a thumbs-up emoji length 2 in JavaScript?

It is a single code point above U+FFFF, so UTF-16 stores it as a surrogate pair of two code units.

Why are UTF-8 bytes bigger than the number of characters?

UTF-8 uses one byte for ASCII and two to four bytes for other code points.

Does it count a byte order mark?

No BOM is added. A BOM character inside your text would count like any other code point.

Is the text sent anywhere?

No. Measuring happens in the page and the text stays on your device.