String Counter

Characters, words, lines and bytes.

About String Counter

A string counter reports characters with and without spaces, UTF-8 bytes, words, unique words, lines and sentences. Counts update as you type.

How to use

  1. Type or paste the text.
  2. Read the seven counts in the grid; they update on every keystroke.
  3. Use Clear to start again.

What it counts

Count How it is measured
Characters (graphemes) User-perceived characters, segmented with Intl.Segmenter; a flag or a family emoji is 1. Older browsers fall back to code points and the label says so
UTF-16 units The same as string.length in JavaScript
Without spaces Characters that are not whitespace
Bytes (UTF-8) Length of the text encoded as UTF-8
Words Runs of non-whitespace separated by spaces, tabs or newlines
Unique words Distinct words, case-sensitive and including attached punctuation
Lines Newline characters plus one; empty text is 0
Sentences Segments ending in ., ! or ? followed by a space or the end
  • An emoji such as 😀 counts as 1 character, 2 UTF-16 units and 4 bytes; "é" counts as 1 character and 2 bytes.
  • "Hello," and "Hello" are different unique words; punctuation is not stripped.
  • "e.g. this" counts as two sentences, because the splitter does not know abbreviations.
  • Does not count paragraphs, syllables or reading time.

Example

Héllo wörld. Hi!
→ Characters 16 · Without spaces 14 · Bytes (UTF-8) 18
→ Words 3 · Unique words 3 · Lines 1 · Sentences 2

Privacy

Counting runs in the browser. No request is made, and nothing is stored.

Frequently asked questions

Why is the byte count higher than the character count?
UTF-8 uses 1 byte for ASCII but 2 bytes for accented Latin letters, 3 for most other scripts and 4 for emoji. Any text with characters outside ASCII therefore has more bytes than characters.
How many characters are in a tweet or SMS?
X (Twitter) allows 280 characters, counting most CJK characters as 2. An SMS holds 160 characters in the GSM-7 alphabet, or 70 characters once any character outside it, such as an emoji, forces UTF-16 encoding.
How is a word counted?
As a run of non-whitespace characters. "state-of-the-art" is one word and "hello,world" is one word, while "hello , world" is three. Word processors use similar rules, so counts usually agree within a few per cent.
Why does an emoji count as two characters?
JavaScript strings are UTF-16, and characters above U+FFFF, which includes most emoji, take two 16-bit code units. Counting Unicode code points instead would give 1.