Get String Length

Type or paste a string and press Analyze string. You get its length in characters and UTF-8 bytes, plus counts of letters, digits, spaces, punctuation, emoji, words, lines, and sentences.

Try an example

About this string length tool

The length of a string depends on what you count. Programmers often need the number of bytes a value takes in UTF-8, because database columns, HTTP headers, and API fields are limited in bytes, while writers and form designers care about visible characters. This tool reports both. It counts what a reader sees as one character, so an emoji with a skin tone or an accented letter built from two code points counts once, and it also lists the UTF-8 byte size. Below the totals you get a breakdown by character type and case and the ten most frequent characters.

How to get the length of a string

  1. Enter your string. Type or paste text into the box, or press an example to fill it.
  2. Press Analyze string. The results appear below the button.
  3. Read the totals. Total characters counts every visible character including spaces; Characters (no spaces) leaves out all whitespace; Bytes (UTF-8) is the storage size.
  4. Check the breakdown. The tables show how many letters, digits, punctuation marks, and emoji you have, the split between uppercase and lowercase, and your most frequent characters.

Frequently asked questions

Why are characters and bytes different numbers?

UTF-8 stores plain English letters in one byte but uses two bytes for most accented letters, three for most Chinese, Japanese, and Korean characters, and four for emoji. Text with only English letters has equal counts.

How is an emoji counted?

A whole emoji counts as one character, even when it is built from several code points, such as a thumbs up with a skin tone or a family emoji. That is why this count can be lower than JavaScript’s length property.

Do line breaks count as characters?

Yes. Each line break counts as one character and one byte, and it is included in the Spaces count, but Characters (no spaces) leaves it out along with spaces and tabs.

Which characters does the frequency table list?

It lists the ten most frequent characters, ignoring spaces and line breaks. Upper and lower case are separate characters, so E and e are counted on their own. Ties are listed in order of first appearance.

How are letters, symbols, and punctuation told apart?

By the Unicode category of each character: letters, numbers, punctuation such as commas and quotes, and symbols such as currency signs and math operators. Combining marks stay with the letter they belong to.