UTF-8 Byte Size Calculator
Measure text in characters, UTF-16 code units and UTF-8 bytes at once, and check whether it fits a VARCHAR, a DynamoDB key, an SMS segment or an HTTP header limit.
Last reviewed by the Radiatus Cloud team
Measurements
Common limits
Need this built for your product?
We design, build & host secure software & APIs.
Length depends on who is asking
"Maximum 255 characters" is one of the most ambiguous constraints in software. MySQL VARCHAR(255) with the utf8mb4 character set stores 255 characters but reserves up to 1020 bytes. Postgres varchar(255) also counts characters. A DynamoDB partition key limit of 2048 counts UTF-8 bytes. An HTTP header limit counts bytes. Redis counts bytes. A tweet counts weighted code points. Shipping a validator that counts the wrong unit produces either silent truncation in the database or a rejection your users cannot explain.
Where the byte cost comes from
UTF-8 is variable width. ASCII costs one byte per character, Latin accented letters and Greek and Cyrillic cost two, most Asian scripts and the majority of punctuation cost three, and emoji and rarer scripts cost four. A composed emoji such as a family or a flag is several code points joined by zero width joiners, so a single visible glyph can cost more than twenty bytes. That is how a 100 character message overflows a 255 byte column.
Using the result
The calculator reports characters, UTF-16 code units, UTF-8 bytes and Base64 encoded size together, then checks the text against a set of limits people actually hit: index key sizes, SMS segmentation, cookie and header budgets and common column widths. If a limit is exceeded, the byte overage is shown so you know how much to trim rather than guessing.
Related tools
- JSON Formatter — Format and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
- JSON Validator — Validate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
- Regex Tester — Test regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.
- HTML Minifier — Minify HTML by removing comments and redundant whitespace, without breaking inline elements or pre blocks. Runs entirely in your browser.
Frequently Asked Questions
Why do MySQL and Postgres disagree about VARCHAR length?
Both count characters for the declared length, but MySQL additionally caps the row and index byte size, so a utf8mb4 index on VARCHAR(255) needs 1020 bytes and historically exceeded the 767 byte InnoDB index limit. That is the origin of the widespread VARCHAR(191) convention.
What is the difference between UTF-8 bytes and UTF-16 units?
UTF-8 encodes a code point in one to four bytes. UTF-16, which JavaScript and Java strings use internally, encodes it in one or two 16 bit units. A three byte UTF-8 character is a single UTF-16 unit, and a four byte one is a surrogate pair, so neither count predicts the other.
How is the SMS segment count calculated?
If every character is in the GSM 03.38 alphabet, a message fits 160 characters, or 153 per part when concatenated. Any character outside that alphabet forces UCS-2, which allows 70 characters, or 67 per part. The tool detects which encoding applies.
Does Base64 size include padding?
Yes. Base64 expands data to four output characters per three input bytes and pads to a multiple of four, so the figure shown is the exact encoded length you would transmit.
Do line endings count?
Yes. A CRLF pair is two bytes and LF alone is one, which is why the same file can measure differently after a checkout on Windows. The tool counts exactly what is in the box.
Privacy & Security
Everything runs in your browser; nothing is uploaded.
How to Use
Paste text to see byte counts across encodings and which common storage limits it fits.
Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.
Related Tools
JSON Formatter
DeveloperFormat and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
JSON Validator
DeveloperValidate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
Regex Tester
DeveloperTest regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.