String Length Calculator

Characters, bytes (UTF-8/UTF-16/ASCII), codepoints, graphemes, URL-encoded length, and Base64 length - all at once.

Last reviewed: June 2026

New to this tool? Click here for instructions

Input String
Type or paste a string above to measure its length.

How to Use the String Length Calculator

Paste text into the input area and the metrics update instantly. Summary mode shows the headline counts, Encoding mode shows a per-character byte breakdown, and Compare mode helps explain why two strings that look similar can have different codepoints.

When to Use the Tool in Real Workflows

Use it when checking database field limits, API payload sizes, SMS or push-message limits, URL query length, Base64 expansion, Unicode normalization issues, or emoji-aware UI counters.

How It Works

The calculator runs in local browser JavaScript. It uses String.length for UTF-16 code units, TextEncoder for UTF-8 byte length, Array.from() for codepoints, Intl.Segmenter for grapheme clusters when available, and encodeURIComponent() for URL-encoded length. Your string is not uploaded to an external tool.

Useful references: MDN String.length, MDN TextEncoder, MDN Intl.Segmenter, and Unicode UAX #29 text segmentation.

Tips, Edge Cases, or Limitations

  • JavaScript .length counts UTF-16 code units, so a single emoji can count as 2.
  • Grapheme count is usually the best user-facing character limit because it tracks visible characters more closely.
  • Byte limits depend on encoding. UTF-8 and UTF-16 can produce very different sizes for the same text.
  • Normalize text before strict storage validation when accents or combining marks are possible.

Frequently Asked Questions

Character count refers to the number of characters in a string, while byte count refers to the number of bytes used to store the string in a specific encoding (e.g., UTF-8, UTF-16).
JavaScript counts emoji as having length 2 because they are represented by two UTF-16 code units in the JavaScript string format.
UTF-8 uses a variable number of bytes (1-4) per character, while UTF-16 uses 2 bytes for most characters and 4 bytes for supplementary characters.
URL-encoded length is the length of a string after it has been encoded using percent-encoding, which is commonly used in query strings and form data.
A grapheme cluster is the smallest unit of text that a human would perceive as a single character, including combining characters and emoji.