String Length Counter

Reports a text's length four ways at once: Unicode character count, UTF-8 byte size, word count, and line count, since 'length' means different things depending on context. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-22

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.

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).

Examples

Measuring a sentence with an emoji

Input

Hi 👋

Output

Characters: 4, Bytes: 7, Words: 2, Lines: 1

The wave emoji counts as 1 character but 4 UTF-8 bytes, illustrating why character and byte counts diverge.

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.

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.

References

Frequently Asked Questions