FormatterHQ

String Byte Size Counter

Paste any text to see its exact size in bytes in UTF-8, UTF-16, UTF-32 and Latin-1, alongside visible characters, code points and common length limits.

Input TEXT
Output TEXT
Ready.

How to use the String Byte Size Counter

  1. Paste or type your text into the input box, including emoji, accents or line breaks.
  2. Click Count bytes (results also update as you type).
  3. Read the byte size for each encoding and the character, code point and UTF-16 code unit counts.
  4. Check the Common limits list to see whether the text fits a tweet, SMS, VARCHAR column, DNS label or cookie.

String Byte Counter for UTF-8, UTF-16 and UTF-32

"How long is this string?" has at least four correct answers, and picking the wrong one leads to truncated database values, rejected API payloads and broken SMS messages. This string byte counter shows them side by side: the storage size in UTF-8, UTF-16, UTF-32 and Latin-1, the number of visible characters, Unicode code points and JavaScript code units, and the size after Base64 or URL encoding.

Why bytes and characters differ

Text is stored as numbers called code points, and an encoding decides how many bytes each one takes:

TextUTF-8UTF-16UTF-32
ASCII letter A1 byte2 bytes4 bytes
Accented Γ©2 bytes2 bytes4 bytes
Chinese δΈ–3 bytes2 bytes4 bytes
Emoji β˜• (U+2615)3 bytes2 bytes4 bytes
Emoji πŸ‘‹ (U+1F44B)4 bytes4 bytes4 bytes

On top of that, one visible character (a grapheme) can be several code points. A waving hand with a skin tone is two code points, and a family emoji can be seven. So the character count you see, the code point count, and JavaScript's .length, which counts UTF-16 code units, often disagree.

Example

For the text Hello, δΈ–η•Œ! CafΓ© β˜• πŸ‘‹πŸ½ the tool reports:

UTF-8:            33 B
UTF-16:           44 B
UTF-32:           80 B
Latin-1:          not representable (characters above U+00FF)

Characters (graphemes, what you see): 19
Unicode code points:                   20
UTF-16 code units (JavaScript .length): 22
Non-ASCII code points:                 6 (2 outside the BMP, e.g. emoji)
Words: 5 Β· Lines: 1

As Base64:        44 B
URL-encoded:      81 B

Nineteen visible characters take 33 bytes in UTF-8, while .length says 22. The URL-encoded form is more than twice the UTF-8 size, because every non-ASCII byte becomes a three-character %XX escape.

What each number is for

  • UTF-8 bytes: the size on disk, in HTTP bodies, in most databases and in Content-Length. This is the number to use for byte limits.
  • UTF-16 bytes and code units: memory use in JavaScript, Java and .NET strings, and the unit behind String.length. The UTF-16 figure excludes a byte order mark.
  • UTF-32: a fixed four bytes per code point, useful as a worst-case estimate.
  • Latin-1: shown only when every character is at or below U+00FF, as in legacy systems that store one byte per character.
  • Graphemes: what a person would count, and the right number for user-facing limits.
  • Base64 size: always four characters for every three bytes, about a third larger than the UTF-8 size.

Common limits checked for you

The report ends with a quick pass or fail against limits developers hit often: a 280-character post, a single SMS part (160 characters for plain GSM-7 text, 70 once any Unicode character appears), a MySQL VARCHAR(255), a roughly 160-character meta description, a 63-byte DNS label and a 4 KB cookie. The tweet check counts graphemes, while X weights some characters such as emoji differently, so treat it as an estimate. The SMS check treats only printable ASCII as GSM-7, which is slightly stricter than the real alphabet.

Common pitfalls

  • MySQL utf8 is not full UTF-8. It stores up to three bytes per character, so four-byte emoji fail. Use utf8mb4.
  • Truncating by bytes can split a character. Cutting a UTF-8 string at byte 100 may leave half a multi-byte sequence. Truncate by code points or graphemes, then check the byte size.
  • Invisible characters count. Zero-width joiners and non-breaking spaces add bytes you cannot see.

To see the actual bytes, run the text through UTF-8 encode, or compare the encoded forms with Base64 encode and URL encode. For word and sentence counts aimed at writers, use the word counter.

Privacy

Counting happens in your browser with the standard TextEncoder and Intl.Segmenter APIs. Your text is never sent to a server.

Frequently asked questions

How many bytes is one character in UTF-8?
Between one and four. ASCII characters take one byte, most Latin, Greek, Cyrillic, Hebrew and Arabic letters take two, most Chinese, Japanese and Korean characters take three, and emoji outside the Basic Multilingual Plane take four.
Why does JavaScript .length give a different number?
String.length counts UTF-16 code units, not characters or bytes. Characters outside the Basic Multilingual Plane, including most emoji, use two code units each, so "πŸ‘‹".length is 2. Use [...str].length for code points or Intl.Segmenter for visible characters.
How do I get the byte length of a string in JavaScript?
Use new TextEncoder().encode(str).length for the UTF-8 byte count; this is what the tool uses. In Node.js, Buffer.byteLength(str, "utf8") gives the same result.
Does VARCHAR(255) mean 255 bytes?
In MySQL and PostgreSQL, VARCHAR(n) counts characters, not bytes, so a utf8mb4 VARCHAR(255) can use up to 1,020 bytes. Some other systems, such as older Oracle defaults, measure in bytes, so check your column semantics.
Why does an emoji make my SMS so much shorter?
A standard SMS holds 160 characters in the 7-bit GSM alphabet. Any character outside that alphabet, such as an emoji, switches the whole message to UCS-2 encoding, which fits only 70 characters per part.

Last updated October 3, 2026

Related tools