Count characters, bytes and words

Report UTF-16 units, Unicode code points, UTF-8 bytes, whitespace tokens, and physical lines separately.

freeworks offlinenothing uploaded
ToolString Length
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

JavaScript length measures UTF-16 code units, iteration measures code points, and TextEncoder supplies RFC 3629 byte length. Words split on whitespace and lines split on LF with an optional preceding CR; a non-empty string starts with one line.

  • All units remain visible because a database, API, and UI may enforce different size limits.
  • Unicode UAX #29 grapheme clusters are not counted, so a displayed symbol can contain several reported code points.

Worked example

Measure a plain ASCII string
For ASCII text, characters, code points, and bytes all match
Input
											Hello, World!
										
Output
												Characters (UTF-16): 13
Code points: 13
Bytes (UTF-8): 13
Words: 2
Lines: 1
											

When to use this

Database checks compare storage bytes with field limits, API clients diagnose emoji length mismatches, and import fixtures verify CRLF or LF line counts.

Edge cases

  • 😀 measures two UTF-16 units, one code point, and four UTF-8 bytes.
  • e plus a combining acute accent measures two code points despite rendering as one accented grapheme.
  • Chinese prose with no spaces is one whitespace token regardless of its linguistic word boundaries.

References