Check string length, byte size and more
The string utility measures string length in the three ways programmers actually run into, counts the kinds of characters in the text, and shows common transformations side by side. It helps when a database column, API field or SMS limit rejects text that looked short enough.
What it reports
- Length (characters) – the number of Unicode code points.
- Length (UTF-16 units) – the value of
.lengthin JavaScript,length()in Java and.Lengthin C#. Characters outside the Basic Multilingual Plane, such as most emoji, count as two. - Size (UTF-8 bytes) – the storage and transfer size. ASCII takes 1 byte, most accented Latin letters 2, many symbols 3 and emoji 4.
- Words, lines, letters, digits – letters and digits from any script are counted.
- Spaces – regular spaces (U+0020) only; tabs and non-breaking spaces are not included.
Below the counts you get the string in UPPERCASE, lowercase, reversed and trimmed forms, ready to copy.
Worked example
Input: café 👍
Length (characters): 6
Length (UTF-16 units): 7
Size (UTF-8 bytes): 10
The byte total is c, a and f (1 byte each) + é (2 bytes) + the space (1) + 👍 (4 bytes) = 10. In UTF-16 every character is one unit except 👍, which needs a surrogate pair, giving 7. The sample string " Hello, World! Ünïcode ✓ " has 27 characters but takes 31 bytes, because Ü and ï take 2 bytes each and ✓ takes 3.
Why the three lengths differ
Limits are defined in different units. MySQL's VARCHAR(255) counts characters, while index size limits and many network protocols count bytes. An HTML maxlength attribute counts UTF-16 code units. If an emoji-heavy post is rejected even though it "looks" short, the UTF-16 or byte count is usually the reason.
Characters that look like one
What a reader sees as one character can be several code points. An é typed as e plus a combining accent is two characters, and the family emoji 👨👩👧 is five: three people joined by two zero-width joiners. The reversed output works on code points, so reversing can detach a combining accent from its letter or reorder the parts of a joined emoji.
Case conversion details
Uppercase and lowercase follow the general Unicode rules, not a specific language. Some conversions change the length: the German ß becomes "SS" in uppercase. The trimmed version removes spaces, tabs, line breaks, non-breaking spaces and byte order marks from both ends.
For a fuller view of words, sentences and reading time, use the word counter. To see the actual bytes, try string to byte array or UTF-8 encode, and for more reversal options there is reverse string.
Privacy
The processing runs entirely in your browser. The text you enter is not uploaded to a server.
Get string length in Python
String length in Python is len(text); strings have no .length property or size() method. The result is the number of Unicode code points, which trips people up when a limit is defined in other units. For the size in bytes, encode first and measure the result: len(text.encode("utf-8")). For the UTF-16 length that JavaScript, Java and C# report, encode as UTF-16 and halve the byte count. Spaces at either end are counted, and an emoji with a skin tone is two code points.
text = "naïve café 👍🏽"
print(len(text)) # 13 code points
print(len(text.encode("utf-8"))) # 21 bytes
print(len(text.encode("utf-16-le")) // 2) # 15 UTF-16 units (JavaScript's .length)
# Leading and trailing spaces count too
padded = " hello "
print(len(padded), len(padded.strip())) # 9 5
# One visible character can be several code points
print(len("e\u0301")) # 2: e plus a combining accent
The three numbers printed for the sample string are the same ones this tool reports as characters, UTF-8 bytes and UTF-16 units.