String Byte Length Calculator
Calculate the byte length of any string in UTF-8 encoding. Free, instant.
How to use this tool
- Enter text in the fields above.
- Results update instantly as you type — or click Calculate.
- Read your utf-8 byte length and the full breakdown beneath it.
Strings in JavaScript are UTF-16, but network transmission and storage often use UTF-8. This tool calculates how many bytes your text occupies in UTF-8.
How it works
String Byte Length Calculator measures the size of a text string in bytes when encoded as UTF-8, which is the standard encoding for the web and most modern systems. The byte length of a string is not the same as its character count: ASCII characters each take 1 byte, but characters outside ASCII (accented letters, emoji, CJK characters) take 2-4 bytes each.
Paste or type any string into the input field and the tool instantly reports both the character count and the UTF-8 byte length. This is critical for working within size limits imposed by databases (VARCHAR column sizes), APIs (request body limits), messaging systems, and cryptographic functions that accept byte arrays.
For example, a 100-character string containing emoji may be 200-400 bytes -- well over a database column defined as VARCHAR(100 BYTES). This tool lets you check before hitting an error in production.
Worked example
Check whether a string fits in a database VARCHAR(255 BYTES) column
- Prepare the string to insert: a user bio containing accented characters and emoji.
- Paste it into the Text field.
- Click Calculate.
- Compare the byte length shown (e.g., 312 bytes) against the column limit (255 bytes).
- Trim or truncate the input until the byte length is at or below 255.
Confirmation that the string is within the column byte limit before executing the INSERT.
Common mistakes to avoid
- Assuming character count equals byte length: this is only true for pure ASCII text; any non-ASCII character will cause the byte length to exceed the character count.
- Testing with ASCII-only sample data when the real data will contain non-ASCII characters: always test with representative data including accents, emoji, or CJK characters if users will enter them.
- Using the byte length from this tool to truncate a string by character position: cutting at byte N may split a multi-byte character, producing invalid UTF-8; always truncate at character boundaries.
Key terms
- UTF-8
- A variable-width character encoding that represents Unicode characters using 1 to 4 bytes. ASCII characters use 1 byte; emoji and many Asian characters use 3-4 bytes.
- Character count
- The number of Unicode code points (logical characters) in a string, regardless of how many bytes each character occupies in storage.
- Byte length
- The actual number of bytes a string occupies when encoded in a specific encoding such as UTF-8. Always greater than or equal to the character count.
Frequently asked questions
- Why does byte length differ from character count?
- Non-ASCII characters (like accented letters or emoji) take 2-4 bytes in UTF-8, making the byte length larger than the character count.