Home / Text tools / Byte counter

Byte Counter

Find out how many bytes your text takes in UTF-8, UTF-16, UTF-32 and Latin-1, and check it against a byte limit.

Characters are not bytes

A character is a letter or symbol. A byte is a unit of storage. In plain English text every character takes one byte, but accented letters take two, most Asian scripts take three and emoji take four. A text of 100 characters can therefore be anywhere from 100 to 400 bytes. Limits for files, database columns, API fields and SMS parts are often set in bytes, so the character count alone is not enough.

Bytes by encoding

EncodingBytes per characterUsed for
UTF-81 to 4The web, files, APIs and most databases
UTF-162 or 4JavaScript, Java, Windows and .NET strings in memory
UTF-324Fixed-width storage, some internal use
Latin-1 (ISO-8859-1)1Older systems. It cannot store characters above U+00FF.

What this tool shows

  • The byte count in each encoding, and the size in KB.
  • A table of how many characters take 1, 2, 3 or 4 bytes in UTF-8, with the bytes they use.
  • The number of characters that cannot be stored in Latin-1.
  • A limit check: type a limit in bytes and see whether the text fits, and by how much.

Options

  • Add a byte order mark: adds 3 bytes to UTF-8, 2 to UTF-16 and 4 to UTF-32, for files saved with a BOM.
  • Count line breaks as two bytes: counts every line break as the Windows pair of carriage return and line feed.

Counting bytes in code

// JavaScript
new TextEncoder().encode(text).length

# Python
len(text.encode("utf-8"))

// PHP (strlen counts bytes, mb_strlen counts characters)
strlen($text);

Related tools

For plain character counts use the character counter with spaces. To look at the bytes of a string as Base64, see text to Base64. The character count guide explains characters, code points and bytes in more detail.

Frequently asked questions

How many bytes is a character?

In UTF-8 it is 1 byte for ASCII, 2 for most accented letters and Greek or Cyrillic, 3 for most Asian scripts and 4 for emoji.

How many bytes is my text?

Paste it above. The tool shows the size in UTF-8, UTF-16, UTF-32 and Latin-1.

Why is the byte count bigger than the character count?

Because characters outside basic English take more than one byte in UTF-8.

Does a byte order mark add to the size?

Yes. A BOM adds 3 bytes in UTF-8, 2 in UTF-16 and 4 in UTF-32. Switch it on to include it.