Free String Length calculator with clear step-by-step results.
String length has at least three legitimate answers and they routinely disagree. Code points are what a user perceives as characters, UTF-16 code units are what JavaScript's length property returns, and UTF-8 bytes are what a database column or network payload actually consumes.
Code points
Count of Unicode scalar values, obtained by iterating the string rather than reading .length
UTF-16 units
The value JavaScript reports as .length; astral characters count as two
Characters outside the Basic Multilingual Plane - emoji, some CJK extensions - occupy two UTF-16 units and up to four UTF-8 bytes while being one code point.
Code points for user-facing limits, UTF-8 bytes for storage limits. Using UTF-16 units silently rejects valid input containing emoji.