Processed locally

String Length Calculator Online

Calculate string length, Unicode code points, graphemes, UTF-8 bytes and words in your browser. Leading and trailing whitespace is trimmed; internal spaces and line breaks are counted.

What this tool does

String Length Online counts JavaScript UTF-16 code units, Unicode code points, visible graphemes, UTF-8 bytes and words as you type. Compare these totals before applying a character or byte limit. Measurements use trimmed input: leading and trailing whitespace is removed, while internal whitespace stays in the text.

How to use

Follow the core workflow below. Use “Show in tool” to locate the real control in the live tool above.

  1. Paste the string you want to measure

    Enter the text in Text to analyze. The metrics update live as you type or paste.

    Text to analyze
  2. Read the basic text counts

    Use Total characters, Characters, and Word count for the basic view. The current tool ignores leading and trailing whitespace before calculating the metrics.

    Total charactersCharactersWord count
  3. Choose the developer metric that matches your problem

    JavaScript length counts UTF-16 code units. Unicode code points and Visible graphemes give Unicode-aware views, while UTF-8 bytes shows encoded byte size.

    JavaScript lengthUnicode code pointsVisible graphemesUTF-8 bytes
Success

You can now use the measurement that matches the runtime, UI, storage, or payload limit you are debugging.

Examples

ASCII: hello

The text hello has 5 UTF-16 code units, 5 Unicode code points, 5 graphemes and 5 UTF-8 bytes. For this ASCII example, all four measurements agree.

Emoji: 😀

One 😀 has JavaScript length 2, but only 1 Unicode code point and 1 grapheme. Its UTF-8 encoding uses 4 bytes. Choose the measurement that matches your limit.

Common errors

  • Leading and trailing whitespace is trimmed by the current calculator; internal spaces and line breaks still contribute to the relevant metrics.
  • Emoji and combining characters may be represented by multiple JavaScript UTF-16 code units.
  • Copied text can contain invisible whitespace that changes the result.

AI workflow

Use the measured value with the target runtime or storage limit when asking a coding agent to diagnose truncation, validation, encoding, or normalization behavior.

Learn with this tool

Understand the concept, inspect a testable example, then open it in the tool above.

Regex & TextJavaScript String Length

Frequently asked questions about String Length Calculator