Content-Length & Body Byte Counter
Compute the exact UTF-8 byte length of pasted HTTP body content, report the JavaScript string length, flag the character-vs-byte mismatch, and verify a declared Content-Length header value. All computation happens locally.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
Counting the bytes of a body
Paste a request or response body and the tool reports its exact UTF-8 byte length, the JavaScript string length, the line count and the average bytes per character. Because UTF-16 string length and UTF-8 byte length disagree for any non-ASCII text, the mismatch line shows precisely where a declared Content-Length would go wrong.
Fix the header that truncates requests
A body containing an accent, a currency sign or an emoji is longer in bytes than in characters, so a Content-Length copied from a character count is too small and the request is cut in half. Pasting the body here gives the number that actually belongs in the header and proves the difference.
Analyze versus verify
Analyze mode breaks the body down and reports the size table. Verify mode takes a declared Content-Length and compares it with the measured bytes, reporting a match, or the exact byte difference in either direction. Both modes normalise CRLF line endings to LF before counting.
What it does not cover
Only bodies that declare a length can be checked, so chunked transfer encoding is out of scope. A declared value must be a non-negative integer or the tool says so instead of guessing. The measurement is UTF-8 by definition, so a body in another encoding needs converting first.
Measured in your browser
Encoding and counting use the page, not a server, so the body never leaves your device. It works offline, and a body containing tokens or personal data is measured without being transmitted anywhere.
Questions
Why does byte length differ from string length?
JavaScript strings count UTF-16 code units, so non-ASCII characters (é, emoji) use multiple bytes in UTF-8.
When does Content-Length matter?
A wrong Content-Length wrong corrupts HTTP/1.1 bodies; mismatches can cause truncation or desync. 2 bytes per multibyte character is a common source.
What about chunked?
Chunked transfer encoding omits Content-Length; this tool is for bodies that declare a length.
Related tools
See category- HTTP Range Header Builder & Parser
- URL Encode / Decode
- Data Size Converter
- :nth-child An+B Evaluator
HTTP Range Header Builder & Parser
Build or inspect byte-range request and response headers.
URL Encode / Decode
Percent-encode or decode text for use in URLs — component or whole-URL mode.
Data Size Converter
Convert data sizes between bytes, decimal/binary units and bits.
:nth-child An+B Evaluator
Parse CSS An+B (:nth-child, :nth-of-type) microsyntax, validate it, and list which child indices it matches.