String Length Calculator
Measure string length in characters, code units and UTF-8 bytes.
Text Tools Runs in your browser
How do you find the length of a string?
The string “café🙂” is five code points, six UTF-16 units and nine UTF-8 bytes. This calculator reports all of those measures, plus the count without spaces, because each one matters somewhere: JavaScript’s .length returns UTF-16 units, MySQL VARCHAR limits count characters, and many APIs cap payloads in bytes. Paste a value and read off whichever measure your target system enforces.
How to use the String Length
- 1 Drop the string you need to measure into the field.
- 2 Read the four lengths: code points, no-space count, UTF-16 units, UTF-8 bytes.
- 3 Pick the measure your database column or API actually limits.
- 4 Copy the numbers into your bug report or schema notes.
What you can use it for
- Checking a value against a database column limit.
- Validating input length in an API contract.
- Measuring byte size of a token or key.
- Debugging why .length disagrees with what you see.
Frequently asked questions
Why are there several length numbers?
Because systems disagree. JavaScript’s .length counts UTF-16 code units, Python’s len() counts code points, and byte-limited storage counts UTF-8 bytes. For plain ASCII all three match; add an emoji and they diverge.
Which length should a database field use?
Check the column definition. MySQL’s VARCHAR(50) means 50 characters, but an index limit like 767 bytes is a byte constraint. The report shows both so you can test against the right one.
Does it handle emoji correctly?
Yes. 🙂 is one code point but two UTF-16 units and four UTF-8 bytes, and each figure reflects that. Sequences built from several code points, like some family emoji, count per code point.
Related tools
More Text Tools
More tools like this:
All Text Tools