01What is String Length Analyzer?
Ask three developers how long a string is and you can get three different answers. Once your text leaves plain ASCII, they can all be right. This analyzer puts every common answer next to each other so you can see which one your limit actually means. Characters (.length) is what JavaScript reports. It counts UTF-16 code units, so any emoji outside the Basic Multilingual Plane takes two. Code Points spreads the string into an array, which walks it by Unicode code point and gives you the count the Unicode Standard uses. Grapheme Clusters runs the text through Intl.Segmenter with grapheme granularity. That follows the extended grapheme cluster rules in Unicode Standard Annex #29, so a flag or a family emoji counts as one, the way a reader sees it. If a browser has no Intl.Segmenter, the tool quietly falls back to the code point count. UTF-8 Bytes comes from TextEncoder, which is the size your text takes in a UTF-8 file, database column or HTTP body. UTF-16 Code Units repeats the .length figure so you can compare the two encodings at a glance. Words splits the trimmed text on runs of whitespace, and Lines splits on LF or CRLF. Here is a quick worked case. Paste the family emoji built from man, woman and girl with two zero-width joiners. You get 8 characters, 5 code points, 1 grapheme cluster and 18 UTF-8 bytes. That one glyph would eat 8 slots of an HTML maxlength and 18 bytes of a byte-limited field. The built-in Emoji example, a family of four plus the word Hello and a US flag, reads 22, 16, 9 and 40. Copy Stats puts all seven numbers on your clipboard as labelled lines, ready for a bug report. The counting happens in your own tab with standard browser APIs, and the text you paste is never uploaded. A few limits are good to keep in mind. Grapheme results depend on the Unicode data shipped with your browser, so a very new emoji sequence can split differently in an older one. The tool does not normalize input, so é typed as one code point and é built from e plus a combining accent give different counts. Words is a simple whitespace split, so Chinese or Japanese text without spaces counts as a single word. Lines counts a trailing newline as the start of an extra empty line, which means "line" followed by Enter shows 2. It also reports UTF-8 and UTF-16 only, with no Latin-1 or other legacy encodings.
Front-end and backend developers, database designers and QA testers who need to know exactly how a length limit treats emoji, accents and CJK text. The tool runs entirely in your browser, so your data never leaves your device.
02How to use String Length Analyzer
- Type or paste your text into Input Text, or pick the Hello World, Emoji or Unicode example
- Compare Characters (.length), Code Points and Grapheme Clusters to see how the text splits
- Read UTF-8 Bytes when your limit is about storage or network size
- Check the Words and Lines counts underneath
- Click Copy Stats to copy all seven figures, or the reset button to clear the box
03Worked examples
- Input:
café (é typed as one character) - Result:
Characters 4, Code Points 4, Grapheme Clusters 4, UTF-8 Bytes 5 - é is one code point but two bytes in UTF-8.
- Input:
café with e plus a combining acute accent (U+0301) - Result:
Characters 5, Code Points 5, Grapheme Clusters 4, UTF-8 Bytes 6 - Looks identical to the line above. The tool does not normalize, so the counts differ.
- Input:
👍🏽 - Result:
Characters 4, Code Points 2, Grapheme Clusters 1, UTF-8 Bytes 8 - Thumbs-up plus a skin-tone modifier. Two code points, each a UTF-16 surrogate pair, shown as one glyph.
- Input:
👨👩👧 - Result:
Characters 8, Code Points 5, Grapheme Clusters 1, UTF-8 Bytes 18 - Three people joined by two zero-width joiners make one family glyph.
- Input:
Built-in Emoji example: 👨👩👧👦 Hello 🇺🇸 - Result:
Characters 22, Code Points 16, Grapheme Clusters 9, UTF-8 Bytes 40, Words 3, Lines 1 - Input:
a, b, c on separate lines, the second break being CRLF - Result:
Characters 6, Grapheme Clusters 5, Words 3, Lines 3 - \r\n is two characters but one grapheme cluster.
04Common use cases
- Checking whether a username with emoji fits a MySQL VARCHAR(50) column, which limits characters, or a byte-limited key elsewhere
- Working out why your SMS or social post counter disagrees with String.length on the same message
- Testing maxlength on a form input that will receive accented, CJK or emoji text
- Estimating the UTF-8 payload size of a push notification title before it hits a provider's byte limit
- Showing a teammate in code review why slicing a string by index broke a flag emoji
- Confirming that a CRLF file from Windows still counts the same number of lines as its LF copy
05Tips
- Truncating with str.slice() can cut an emoji or accent in half. Split by graphemes with Intl.Segmenter before you shorten user-visible text.
- MySQL's old utf8 charset stores at most 3 bytes per character, so 4-byte emoji fail to insert. Use utf8mb4.
- The same-looking é can be one code point or two. Run String.prototype.normalize('NFC') on both sides before comparing lengths.
- HTML maxlength counts UTF-16 code units, so each emoji outside the BMP uses two of the allowed characters.
- If Lines looks one too high, check for a trailing newline at the end of your paste.
06Related concepts
UTF-8, UTF-16, grapheme clusters, Unicode code points, Intl.Segmenter.
Frequently Asked Questions
What is String Length Analyzer?
String Length Analyzer is a free, browser-based developer tool on AIDToolStack. Analyze string length in bytes/chars/graphemes It requires no installation or sign-up and works entirely in your browser.
Is String Length Analyzer free to use?
Yes. No sign-up, no fees and no usage cap.
Does String Length Analyzer store my data?
No. It runs in your browser; nothing is uploaded.