String Length Calculator (Character Count)

Word Counter โ†’Writing Tools

Paste a string and see every length at once: characters, UTF-16 units, code points and UTF-8 bytes.

0

Characters (graphemes)

0

UTF-16 units (JS .length)

0

Code points (Python len)

0

UTF-8 bytes

0

Without spaces

0

Lines

LanguageExpressionResultCounts
JavaScript / TypeScriptstr.length0UTF-16 code units
Javas.length()0UTF-16 code units
C#s.Length0UTF-16 code units
Python 3len(s)0code points
Golen(s)0UTF-8 bytes
Goutf8.RuneCountInString(s)0code points
Rusts.len()0UTF-8 bytes
C++s.size() // std::string, UTF-80bytes
PHPmb_strlen($s)0code points
Swifts.count0grapheme clusters
MySQL / PostgreSQLCHAR_LENGTH(s)0characters (code points)

Processed in your browser. A copy of each run is saved to your past runs so you can reopen it. Privacy

About

What the String Length Calculator does

The String Length Calculator measures a string the ways different software does. Characters counts what people see, so an emoji with a skin tone is one; UTF-16 units is what JavaScript's length and Java's length() return; code points is Python's len(); UTF-8 bytes is what a database or an API limit usually means. A table shows the result of each language's length function.

Steps

How to use it

  1. 1Paste or type the string.
  2. 2Read the lengths in the tiles; they update as you type.
  3. 3Check the table for the exact value your language or database will report.

Example

A real run

Input

hรฉllo ๐Ÿ‘‹๐Ÿฝ

Output

Characters (graphemes): 7
UTF-16 code units (JavaScript .length, Java .length()): 10
Code points (Python len()): 8
UTF-8 bytes: 15
Without spaces: 6

Seven visible characters, but the waving hand with a skin tone is two code points, four UTF-16 units and eight UTF-8 bytes, and รฉ takes two bytes.

Options

Every setting, and when to use it

Characters (graphemes)
What a person counts: รฉ is one character and so is ๐Ÿ‘‹๐Ÿฝ, even though the emoji is built from two code points. Use it for user-facing limits such as display names.
UTF-16 units and code points
UTF-16 units are what JavaScript, Java and C# measure; emoji and some rare characters take two. Code points are what Python 3, PHP's mb_strlen and SQL CHAR_LENGTH count.
UTF-8 bytes, without spaces and lines
UTF-8 bytes is the storage and transfer size: English letters take 1 byte, accented letters 2, most emoji 4. The tiles also count characters without spaces and the number of lines.

Good to know

Common problems and limits

Grapheme counting uses your browser's Intl.Segmenter, so very new emoji sequences may count as several characters in older browsers.

The table shows what each language's standard length function returns for a correctly decoded string; byte counts assume UTF-8.

For words, sentences and reading time, use the Word Counter; to see the escape codes behind each character, use Unicode Escape.

Audience

Who uses it

  • DevelopersCheck why a validation rule rejects a string that looks short enough, usually because of emoji or accented letters, and strip hidden characters with Remove Extra Spaces.
  • Database administratorsSize VARCHAR columns and index limits in characters or bytes before migrating data in many languages.
  • Product and content teamsTest names, titles and messages against character limits in apps, SMS gateways and ad platforms.

FAQ

Frequently asked

Why do JavaScript and Python give different lengths for the same string?

They count different units. JavaScript's .length counts UTF-16 code units, so an emoji outside the basic plane counts as 2. Python's len() counts code points, so it counts 1. Neither counts what a person sees when several code points form one symbol, such as ๐Ÿ‘‹๐Ÿฝ.

How do I get a string's length in Java, C++, Python and JavaScript?

Java: s.length() (UTF-16 units). C++: s.size() or s.length() on a std::string (bytes). Python: len(s) (code points). JavaScript: s.length (UTF-16 units); [...new Intl.Segmenter().segment(s)].length counts what people see.

Should a database limit count characters or bytes?

Check the database. MySQL and PostgreSQL VARCHAR(n) limits count characters (code points), but MySQL's utf8mb4 needs up to 4 bytes per character, which matters for index size limits. Byte limits are common in APIs, message queues and file formats.

How long is an emoji?

It depends on the emoji and the unit. ๐Ÿ‘‹ is 1 character, 1 code point, 2 UTF-16 units and 4 UTF-8 bytes. ๐Ÿ‘‹๐Ÿฝ adds a skin-tone modifier: still 1 character, but 2 code points, 4 UTF-16 units and 8 bytes. Family and flag emoji are longer still.

Does the character count include spaces?

The main count does, as does every other unit. The Without spaces tile counts characters with all spaces, tabs and line breaks removed.

Is my text sent anywhere?

No. Lengths are calculated in your browser. A copy is saved to your past runs when you copy the text or leave the box, as described on the Privacy page.

Automation: an MCP tool count_text(text, units) โ†’ lengths and an n8n node are planned for this tool.

GuideCleaning pasted text: line breaks, spaces, duplicates and sorting โ†’Text pasted from PDFs, Word and web pages brings hidden breaks, odd spaces and duplicates. Fix them in the right order: breaks, spaces, duplicates, sort.
Built and maintained by Radhika SinghLast updated Questions: hello@operativez.ai