Regex & Text
JavaScript String Length
JavaScript .length counts UTF-16 code units. That is useful for runtime behavior, but it is not always the number of Unicode code points, visible characters, or encoded bytes.
Published
Live metric comparison
Try a string
Edit the text or choose a preset. The four values are calculated by the same shared logic as String Length Calculator.
Result → explanation
Why the counts differ
Counts UTF-16 code units used by JavaScript strings.
Count Unicode scalar values, but not necessarily visible characters.
Approximate the characters a user perceives on screen.
Measure encoded payload or storage size.
Choose the metric you need
| Metric | API | Useful for |
|---|---|---|
| UTF-16 units | value.length | JavaScript and DOM limits |
| Code points | [...value].length | Unicode scalar values |
| Graphemes | Intl.Segmenter | Visible-character limits |
| UTF-8 bytes | TextEncoder | Payload and storage size |
Practice with the full tool
Measure your own string
Compare JavaScript length, Unicode code points, graphemes and UTF-8 bytes with your own input.