devtools

String Length Calculator

Measure string length by Unicode code points, UTF-16 units, and UTF-8 bytes, plus words, lines, and graphemes. Emoji-aware and runs in your browser.

Runs entirely in your browser — your data never leaves your device.

How to use String Length Calculator

What it does & when you need it

"How long is this string?" has more than one answer, and picking the wrong one causes real bugs. A database column capped at 255, a UTF-8 byte budget, a form that limits input, and a person counting glyphs on screen are all measuring different things. This tool reports every measure at once — Unicode code points, UTF-16 code units, UTF-8 bytes, words, lines, and user-perceived graphemes — and updates them live as you type.

It is handy when you are checking whether a value fits a column, debugging why a length check rejects an emoji, sizing a payload against a byte limit, or just confirming what an editor's character count really means. Everything is computed in your browser, so nothing you paste is uploaded.

How to use

  1. Type or paste text into the text buffer, press Sample for an example mixing emoji and accents, or Upload a file.
  2. The stat tiles update on every keystroke — no button to press. Read Characters, UTF-16 units, UTF-8 bytes, Words, Lines, and Graphemes at a glance.
  3. Press Copy summary (or Ctrl/Cmd + Enter) to copy a plain-text breakdown to paste into a ticket.

Things worth knowing

Characters here means code points. JavaScript's String.length counts UTF-16 code units, so the rocket emoji is two and an astral character is two. This tool counts by code point using Array.from, so that emoji is one — closer to what a person means by "one character".

A code point still is not a grapheme. An emoji with a skin-tone modifier, a flag built from two regional indicators, or a family emoji joined with zero-width joiners is several code points that render as a single glyph. The grapheme count uses Intl.Segmenter to report those visible units, which is usually the number a reader would give.

Bytes depend on the encoding. The byte figure is UTF-8, computed with TextEncoder — the encoding used by almost every file and network request. An ASCII character is one byte, most accented Latin letters are two, most CJK characters are three, and many emoji are four.

Need to reshape the text next? Try the word counter, case converter, or whitespace cleaner.

Examples

Emoji counts as one character

Hi 👋

The waving hand is one code point but two UTF-16 units and four UTF-8 bytes.

Accented and CJK text

café 日本

Accented letters cost two UTF-8 bytes and CJK characters three, though each is one code point.

Plain ASCII

password123

For ASCII every measure agrees: characters, UTF-16 units, and bytes are all the same.

Frequently asked questions

What is the difference between characters, code units, and bytes?

Characters here counts Unicode code points, so an emoji is one. UTF-16 code units is JavaScript's raw String.length, where that emoji is two. UTF-8 bytes is how many bytes the string takes when saved to a file or sent over the network. The three agree for plain ASCII and diverge for emoji, accents, and CJK text.

Why does my emoji count as two, or even more?

An emoji outside the basic range is a surrogate pair — two UTF-16 code units that together encode one code point. Some emoji are built from several code points joined together: a flag is two regional-indicator symbols, and a family emoji uses zero-width joiners. Those render as one glyph, which the grapheme count reports.

How is the byte count calculated?

It encodes the string as UTF-8 using the browser's TextEncoder and counts the resulting bytes. In UTF-8 an ASCII character is one byte, most accented Latin letters are two, most CJK characters are three, and many emoji are four. This is the figure to check against a byte-limited column or payload.

What is a grapheme, and why might it be missing?

A grapheme cluster is a user-perceived character — what a reader would point to as "one character" even when it is several code points, like an accented letter or a skin-toned emoji. The count uses Intl.Segmenter; on the rare older browser without it, the grapheme figure is simply omitted.

Is my text sent to a server?

No. Every measurement is computed locally in your browser, so a password, token, or private string you are sizing never leaves your machine.