How it works
This string length counter shows what a length call returns for your text: UTF-16 code units first, then code points, characters and UTF-8 bytes. The sample is 16 long by the first and 13, 11 or 26 by the others.
Read the full guide
Which length your code reports
JavaScript and Java report UTF-16 code units, the first number. Python’s len counts code points. Swift’s count gives characters. Where a length is counted in bytes, read the last number, which is true for text stored as UTF-8.
Why an emoji has a length of 2
The smiling face is one code point and one character. UTF-16 stores any code point above U+FFFF as a pair of units, so its length reads 2, and UTF-8 spends 4 bytes on it.
Accents and styled letters
An é is 1 unit and 2 bytes. A letter from the bold text generator sits above U+FFFF, so a four-letter word in it has a length of 8 and takes 16 bytes.
Questions and answers
Is this an online strlen?
Yes: read UTF-8 bytes. In C, strlen returns the number of bytes before the first null character, and in PHP it returns the length of the string in bytes, not characters. For the sample, stored as UTF-8, both give 26.
How do I calculate the length of a string online?
Paste or type the string and this string length calculator shows all four lengths as you type. Quotation marks pasted with it are counted too, so leave them out unless they are part of the string.
Does string length count spaces?
Yes. A space or a tab adds 1 to all four numbers, at the ends of the string as well as inside it. An empty string has a length of 0.
Is a string length checker the same as a character counter?
For most everyday text the two numbers match. They part at emoji and joined characters: a length check counts what is stored, the character counter counts what a reader sees, and the astronaut is 1 character with a length of 5.