Search Tools

UTF-8, URL and Base64 character counts and sizes

Compare the lengths and sizes of text and byte sequences after encoding

What to calculate

No line breaks; at most 16,384 UTF-16 code units. Empty input is not calculated. Whitespace-only input is treated as text.

Results

Results update automatically when the required values are entered.

Report an issue

Method, applicability and sources

Calculation method

Without normalizing the input text, Unicode scalar values are encoded in UTF-8 using 1–4 bytes. URL-component encoding follows RFC 3986: only unreserved ASCII characters [A–Z a–z 0–9 - . _ ~] remain 1 byte each, and every other UTF-8 byte is represented by 3 ASCII characters in %HH form. For Base64 (with trailing = padding and no line breaks), the output character count and byte count are 4×⌈original byte count÷3⌉. The increase is output bytes−original bytes. Character count means Unicode code points and may differ from the number of visually perceived characters. All calculations use exact integers, without rounding.

Worked example (hypothetical values)

For “あ”, the code point count is 1; UTF-8 uses 3 bytes, URL-component %HH representation uses 9 bytes, and Base64 uses 4 bytes. If the original data is 4 bytes, Base64 uses 8 bytes with 2 trailing = characters.

Applicability and limitations

An input Unicode string of 1 line, or binary data of known length. Excludes complete URL construction, application/x-www-form-urlencoded (spaces converted to +), the unescaped characters specific to JavaScript encodeURIComponent, Base64url, inserted line breaks, BOM, compression and transport headers. Character counts and URL-encoded lengths are not inferred from byte counts alone.

Method and sources

Method: E244 RFC 3629 / RFC 3986 / RFC 4648 v1.0 (2026-11-13). Data recorded: 2026-11-13.