FormatterHQ

String Utility

Inspect any string: length in characters, UTF-16 units and UTF-8 bytes, word, line, letter, digit and space counts, plus case, reversed and trimmed versions.

Input TEXT
Output TEXT
Ready.

How to use the String Utility

  1. Paste or type the string you want to inspect, including any leading or trailing spaces.
  2. Read the length, byte size and character counts.
  3. Copy the uppercase, lowercase, reversed or trimmed version you need.

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 .length in JavaScript, length() in Java and .Length in 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.

Frequently asked questions

Why is the byte count larger than the character count?
UTF-8 stores ASCII in 1 byte but needs 2 to 4 bytes for other characters, such as accented letters, symbols and emoji. The byte size matters for storage, network limits and some database indexes.
Why does an emoji count as 2 in JavaScript?
JavaScript strings use UTF-16, and characters beyond U+FFFF, including most emoji, are stored as two code units called a surrogate pair. The UTF-16 length shows the number .length reports.
Does the space count include tabs?
No. Only the regular space character is counted. Tabs, line breaks and non-breaking spaces are left out of that number, though they still count toward the total length.
Why does reversing break some accented letters or emoji?
Reversal works on Unicode code points. A letter followed by a combining accent, or an emoji built from several code points, gets split and reordered, so the visible result can differ from what you expect.

Last updated October 3, 2026

Related tools

JSON Multiline String Converter Convert multi-line text into a valid JSON string with \n escapes, a JSON array of lines, or concatenated string literals. JSON to String Converter Convert JSON to a single escaped string you can paste into code, databases or other JSON documents. Choose double, single or no quotes. Reverse String Reverse text by characters, words or lines, or flip the letters of each word individually. String Builder Turn multi-line text into StringBuilder / string concatenation code for Java, C#, JavaScript, Python, PHP or Go. String Byte Size Counter Count how many bytes a string uses in UTF-8, UTF-16 and UTF-32, plus characters, code points and Base64/URL-encoded size. String to JSON Converter Convert an escaped JSON string back into formatted JSON. Handles quoted literals, backslash-escaped text and double-encoded JSON. Text Cleaner Clean messy text: remove invisible characters, straighten smart quotes, collapse spaces and strip HTML. Text Formatter Clean up messy text: trim and collapse spaces, fix punctuation spacing, capitalize sentences, normalize quotes, blank lines and line endings. Text Minifier Compress plain text by collapsing whitespace and removing blank lines. Text Repeater Repeat a text or emoji up to 10,000 times, separated by new lines, spaces, commas or nothing. Text Replacer Find and replace text online with case-sensitive, whole-word and regular expression options. Text to Speech Read text aloud with the voices in your browser. Choose a voice and language, set speed, pitch and volume, and follow the highlighted words.