Developer
Byte Size Calculator
See how many bytes a string, cookie, or header will occupy in UTF-8 and UTF-16, so a size limit is a number you can check before you paste it.
Byte size breakdown
UTF-8 bytes: 0 B UTF-16 bytes: 0 B Characters: 0 ASCII characters: 0 Non-ASCII chars: 0 Kilobytes (UTF-8): 0.0000 KB Megabytes (UTF-8): 0.0000 MB Cookie (UTF-8): 0 B of 4,096 B (fits one cookie) Header (UTF-8): 0 B of 8,192 B (fits one header field)
Output actions
Ready to copy output once your result appears.
Nine lines, updated on every keystroke
Byte Size Calculator fills Byte size breakdown from the paste in Text, cookie, header, or payload to measure. There is no Run button. The block lists UTF-8 bytes, UTF-16 bytes, characters, ASCII characters, non-ASCII characters, kilobytes, megabytes, and two budget lines. Copy output copies those nine lines. Download output is not on this page.
How to measure a paste
- 1Paste or type into Text, cookie, header, or payload to measure. The placeholder mentions emoji and unicode. The box starts empty, and an empty box already prints zeros, including 0 B of 4,096 B (fits one cookie).
- 2Read Byte size breakdown. Each change replaces all nine lines. Labels are padded so the values line up. There is no encoding menu and no checkbox that switches the cookie or header budget.
- 3Press Copy output for the nine lines. A spaces-only paste is not the empty box: spaces are ASCII bytes, so UTF-8 bytes rises by one per space while the cookie line still says fits until the UTF-8 count passes 4,096.
What it is good for
- • Checking café as 5 UTF-8 bytes and 8 UTF-16 bytes before a payload limit.
- • Seeing that 4,096 ASCII letters still fit one cookie and that 4,097 do not.
- • Reading kilobytes and megabytes as binary units of the UTF-8 size, to four decimal places.
Example
Input
café
Output
UTF-8 bytes: 5 B UTF-16 bytes: 8 B Characters: 4 ASCII characters: 3 Non-ASCII chars: 1 Kilobytes (UTF-8): 0.0049 KB Megabytes (UTF-8): 0.0000 MB Cookie (UTF-8): 5 B of 4,096 B (fits one cookie) Header (UTF-8): 5 B of 8,192 B (fits one header field)
c, a, and f are one UTF-8 byte each. é is the two bytes C3 A9, so the UTF-8 line is 5. JavaScript stores é as one UTF-16 code unit, and the page multiplies the string length by 2, so the UTF-16 line is 8. Kilobytes are 5 ÷ 1,024, printed as 0.0049.
What the nine lines count
UTF-8 bytes is the length of a TextEncoder encoding of the box. ASCII stays one byte. é is two. A typical emoji such as 😀 is four UTF-8 bytes, four UTF-16 bytes, and one character. Characters walks the string by Unicode code point, so that emoji counts once even though it occupies a surrogate pair. ASCII characters counts those code points whose first code unit is below 128. The emoji's first code unit is a surrogate, which is above 127, so it lands on Non-ASCII chars and ASCII characters stays 0. A box of only café is Characters 4, ASCII characters 3, Non-ASCII chars 1.
UTF-16 bytes is the JavaScript string length multiplied by 2. That length is code units, not code points, so the emoji contributes 4 and é contributes 2. Kilobytes (UTF-8) divides the UTF-8 count by 1,024 and prints four decimal places. Megabytes (UTF-8) divides by 1,024 × 1,024 and also prints four places, which is why 5 bytes shows as 0.0000 MB. The grouping on the byte numbers uses en-US separators, so 4096 on the budget lines is written 4,096. This page does not offer a decimal SI kilobyte of 1,000.
The cookie line, the header line, and Copy output
Both budget lines use the UTF-8 count, not the UTF-16 count and not the character count. Cookie (UTF-8) compares that count with 4,096. The comparison is inclusive: 4,096 bytes of ASCII still says fits one cookie, and 4,097 says exceeds one cookie. Header (UTF-8) uses 8,192 the same way. A paste of 5,000 c characters exceeds the cookie line and still fits the header line. A paste of 9,000 exceeds both. The wording is fits one cookie, exceeds one cookie, fits one header field, or exceeds one header field, always after the phrase N B of 4,096 B or N B of 8,192 B.
The 4,096 figure is the size browsers are expected to support for one cookie's name, value, and attributes together. Paste the pair you will actually store, not a prose description of it. The 8,192 figure is one buffer in nginx's default large_client_header_buffers. Another server, or a different nginx setting, can cut off sooner or later. The page does not parse Set-Cookie attributes, and it does not add the overhead of a header name you left out of the box. Copy output copies the padded lines. There is no control that copies only the UTF-8 integer.
When the limit is bytes
Use this page when the limit is storage or a protocol budget: a JSON body, a cookie, a single header field, or a string a database will store as UTF-8. A character count answers a different question. The word counter reports characters as UTF-16 code units, including spaces, and it never prints a byte size. café is 4 characters there and 5 UTF-8 bytes here. An emoji that is one character on this page can still be two code units on the word counter. Reading time and sentence counts stay on that page.
A hex listing of the same bytes is the hex encoder, which writes each UTF-8 byte as a lowercase pair. This page will not turn café into c3 a9. A typed quantity such as 5 megabytes, converted between decimal and binary prefixes, is the unit converter. This page will not take the number 5 and emit kibibytes. It only measures the paste. A Flesch score and a top-words list are on text statistics, which also does not encode the draft.
Emoji, an empty box, and the exact 4,096 boundary
An empty box is a valid measurement. Every count is 0, kilobytes and megabytes print 0.0000, and both budgets say fits. Clearing the box returns that report. A single space is 1 UTF-8 byte, 2 UTF-16 bytes, 1 character, and 1 ASCII character. A newline is one byte in UTF-8 and one code unit in UTF-16, so it adds 1 and 2. The page does not strip a trailing newline you pasted from an editor. If the cookie line flipped to exceeds while the text still looks short, look for an emoji, a non-ASCII letter, or a newline you cannot see. é costs two UTF-8 bytes. 😀 costs four.
The character count and the UTF-16 byte count diverge exactly when a code point needs a surrogate pair. 😀 is Characters 1 and UTF-16 bytes 4. Two emoji joined by a zero-width joiner are more than one character if the spread produces more than one code point, and the UTF-8 line follows the encoder, not the grapheme you see. Combining marks add code points. The page does not normalize to NFC before counting, so é written as e plus a combining acute is more bytes than the single character é. Paste the bytes you will send. Copy output is the nine lines with their padding spaces, not a JSON object.
Rules and limitations
UTF-8 bytes: TextEncoder length. UTF-16 bytes: JavaScript string length × 2. Characters: code points. ASCII characters: code points whose first code unit is below 128. Kilobytes and megabytes: UTF-8 ÷ 1,024 and ÷ 1,048,576, four decimal places.
Cookie budget: 4,096 UTF-8 bytes, inclusive. Header budget: 8,192 UTF-8 bytes, inclusive. The lines say fits or exceeds. Copy output copies the nine padded lines. There is no download and no second encoding.
Common problems
If the character count and the UTF-8 count disagree, the extra bytes are non-ASCII. é is 2, and a typical emoji is 4. The word counter's character figure is code units, not this UTF-8 line.
If a cookie you believe is under 4 KB is marked exceeds, the box includes attributes or the name, or the value has characters outside ASCII. The header line is one 8,192-byte buffer, not every server's limit.
Frequently asked questions
Why is café 5 bytes and 4 characters?
UTF-8 encodes é as two bytes, and c, a, and f as one each. Characters counts the four code points. UTF-16 bytes is 8 because each of those four code units is two bytes.
Does 4,096 bytes still fit a cookie?
Yes. The cookie line uses the UTF-8 count and treats 4,096 as inside the budget. 4,097 says exceeds one cookie.
Are kilobytes 1,000 or 1,024?
1,024. Kilobytes (UTF-8) is the UTF-8 size divided by 1,024, shown to four decimal places. Megabytes divide by 1,024 again.
Does an empty box count as a failure?
No. It prints zeros and both budgets say fits. A box of spaces is measured as those spaces, not as empty.
Is my input uploaded or saved?
This tool processes input in your browser and does not save its input or output to local storage. Copy and download are user actions. The site uses analytics for page and action metadata and may use ads and production error reporting; see the Privacy Policy for those services.
About this tool
Maintained by Toolbench. For large or deeply nested files, split the input into smaller batches and verify representative results before using them in an import or application. Report reproducible problems through Contact.
Next steps
Related tools
Continue the workflow with nearby tools for formatting, publishing, debugging, or follow-up checks.
Word Counter
Count words, characters, sentences, paragraphs, and reading time.
Open Word CounterText Statistics
Count words, sentences, a Flesch score, and the five most common words as you type.
Open Text StatisticsHex Encode / Decode
Encode text to space-separated hex bytes, or decode those bytes back to text.
Open Hex Encode / DecodeUnit Converter
Convert length, weight, volume, area, and digital storage between two units.
Open Unit ConverterTrust
Policies, contact, and answers
Clear pages for how Toolbench works, what we collect, and how to reach us.