Overview
Introduction
'How long is this text?' has more than one right answer depending on whether you mean characters, bytes, words, or lines.
This tool reports all four at once.
What Is String Length Counter?
A statistics panel showing a text's Unicode character count, UTF-8 byte size, word count, and line count simultaneously.
It runs entirely client-side as part of this site's String Tools collection, so nothing you paste is ever uploaded to a server.
How String Length Counter Works
Characters are counted via code-point-aware iteration, bytes via UTF-8 encoding, words by splitting trimmed text on whitespace runs, and lines by splitting on newline characters.
The transformation happens synchronously in JavaScript the moment you type, with no network round trip involved.
When To Use String Length Counter
Use it when a size or length limit is specified in a particular unit, characters for a tweet, bytes for a database column, and you need to check text against it precisely.
It's a fast way to get the answer without opening a code editor, a REPL, or writing a one-off script just to check.
Often used alongside Newline Counter and String Truncator.
Features
Advantages
- Shows all four common length measures at once instead of requiring separate tools.
- Character count is code-point-aware, not skewed by surrogate pairs.
- Counts bytes by actually UTF-8 encoding the text rather than estimating from the character count, so emoji and accented letters are measured accurately.
Limitations
- Word counting via whitespace splitting is a simple heuristic and may not match every language's notion of a 'word' (e.g. languages without spaces between words).
- Reports one figure for the whole input, so it cannot show which line or section is pushing a total past a limit.
Examples
Best Practices & Notes
Best Practices
- Check byte count specifically when a limit is enforced by a database column or network protocol, since those typically constrain bytes, not characters.
- Check the character count against a social platform's limit but the byte count against a database column's, since the two constrain different things.
- Measure the exact text you intend to submit, because trailing whitespace and line endings both count towards the totals.
Developer Notes
Character count uses `[...input].length` (code-point aware) rather than `input.length` (UTF-16 code units), and byte count uses `new TextEncoder().encode(input).length`; the two diverge for any text containing characters outside the ASCII range.
String Length Counter Use Cases
- Checking text against a character-limited field like a tweet or title
- Verifying a value fits a byte-limited database column
- Getting a quick word count for a piece of writing
Common Mistakes
- Assuming character count and byte count are always the same.
- Expecting word count to perfectly match languages without space-separated words.
Tips
- Use the byte count specifically when working with network payloads or byte-limited storage fields.
- A character count lower than the byte count means the text contains non-ASCII characters, which is the fastest way to detect them.