String length

This shows the string length of an input, using PHP strlen and mb_strlen


How to count a string's length

  1. Paste or type your text in the Input box.
  2. Press Submit.
  3. Read the three results: String length, MB string length and Encoding detected.

What the numbers mean

  • String length is PHP's strlen(): the number of bytes the text takes up in UTF-8. This is what a database column with a byte limit, a file size or a network protocol cares about.
  • MB string length is mb_strlen(): the number of characters (Unicode code points). This is closer to what a person would count.
  • Encoding detected is ASCII when every character is plain English text, and UTF-8 as soon as there's anything else.

Examples

TextBytesCharactersEncoding
hello55ASCII
héllo65UTF-8
日本語93UTF-8
😀41UTF-8
👍🏽82UTF-8

Accented Latin letters take 2 bytes, most Asian scripts 3, and emoji 4. Some emoji are built from several code points, like the thumbs-up with a skin tone above, so even the character count can be higher than what you see.

Things that count

  • Spaces, tabs and line breaks all count. A line break sent from a browser form is usually two characters (carriage return and line feed).
  • Leading and trailing spaces are not trimmed.

FAQ

Why does my text fit a 280-character limit here but not on a website? Sites count differently: some count bytes, some count code points, and some count emoji or links as a fixed number. Check which one your target uses.

Why do the two numbers differ? Because some characters need more than one byte in UTF-8. If both numbers are the same, your text is plain ASCII.