---
title: "Text statistics"
description: "Count characters, words, graphemes, and lines. Metrics run when you press Run locally."
---

> HTML: https://trendalyzer.app/tools/text-statistics/
> Index: https://trendalyzer.app/llms.txt

# Text statistics

Text statistics counts UTF-16 characters, Unicode code points, grapheme clusters, whitespace-delimited words, and line breaks after you press Run locally. Use it to compare JavaScript string length with user-perceived characters and to inspect multi-line structure before publishing copy or page metadata.

Readiness: experimental

Input types: text

Output types: text

## Limits

- Limits word boundary detection to basic whitespace matching.

## Warnings

- Memory use scales linearly with input size.

## Example

Input: Trendalyzer

Output: {
  "characters": 11,
  "codePoints": 11,
  "graphemes": 11,
  "words": 1,
  "lines": 1
}

## Steps

1. **Paste the sample text** — Drop the string whose length metrics you need — including emoji and multi-line content.
2. **Press Run locally** — Counts are computed when you run the tool, not while you type. Results cover characters, code points, graphemes, words, and lines.
3. **Read the JSON metrics** — Compare UTF-16 length (`characters`) with grapheme clusters when UI or database limits disagree.

## Three length layers

1. **UTF-16 code units (`characters`)** — JavaScript `.length`; surrogate pairs count as two.
2. **Code points (`codePoints`)** — Unicode scalar values; most emoji are one code point but two UTF-16 units.
3. **Grapheme clusters (`graphemes`)** — what a reader sees as one character, including ZWJ sequences.

## When to run

Paste the text, then press **Run locally**. Counts update after that action, not on every keystroke.

## FAQ



### What is the difference between UTF-16 code units, code points, and grapheme clusters?

UTF-16 code units reflect standard JavaScript string length (where surrogate pairs count as 2). Code points represent individual Unicode scalar values. Grapheme clusters represent human-perceived visual characters (e.g. complex emojis with skin-tone modifiers or zero-width joiners).

### How are words counted?

Words are calculated by trimming whitespace and splitting on consecutive whitespace sequences (\s+). Hyphenated compounds (e.g. 'state-of-the-art') count as a single word.

### How does the tool count multi-line text and different newline formats?

The line counter handles Unix (\n), Windows (\r\n), and classic Mac (\r) line terminators consistently, reporting the total number of non-empty and empty lines.
