Encoding guide

Base64, URL encoding, and the boundary problem

Most encoding bugs come from transforming the wrong layer, using the wrong character set, or encoding the same data twice.

ToolsNHelpers editorial teamReviewed 10 August 20267 minute read

Choose an encoding for the constraint you have

Base64 represents bytes with a limited printable alphabet. It is useful when a text-only field must carry arbitrary bytes, but it increases size and does not provide secrecy. URL percent-encoding protects characters that would otherwise be interpreted as URL syntax. HTML entity encoding is for placing text in an HTML context. These transformations solve different problems and are not interchangeable.

Define the bytes before using Base64

Text must first become bytes through a character encoding such as UTF-8. If one system encodes UTF-8 and another decodes using a legacy character set, ASCII text may appear correct while accented characters and emoji break. Use the Base64 tool with a small non-ASCII test value when diagnosing the boundary.

Standard Base64 and URL-safe Base64 also use different characters and padding conventions. Do not remove padding or replace characters unless the receiving protocol explicitly defines the URL-safe variant.

Encode URL components, not an assembled URL

In a URL, colons, slashes, question marks, ampersands, equals signs, and hash characters may be structural separators. If a query value is release notes & fixes, encode that value before joining it to the parameter name. Encoding the complete URL can also encode separators the parser needs. The URL Encode tool offers component and full-URL modes so the difference is visible.

Recognize double encoding

A percent sign encoded as %25 is a frequent clue. For example, a value intended as %20 can become %2520 when encoded twice. Decode one layer, inspect the result, and determine which component originally owned the transformation. Repeatedly clicking Decode until text “looks right” can corrupt legitimate percent characters.

Debugging checklist

  1. Name the source data: text, bytes, a URL component, or a complete document.
  2. Confirm the character encoding for text-to-byte conversion.
  3. Apply exactly the transformation required by the receiving protocol.
  4. Compare a known test vector on both sides.
  5. Never treat encoding as encryption or access control.

References

Base64 variants are defined in RFC 4648. URL parsing and percent-encoding behavior are maintained in the WHATWG URL Standard.

An unhandled error has occurred. Reload x