URL-Safe Base64 Guide: When Standard Base64 Breaks URLs
Standard Base64 uses + and / which break URLs. URL-safe Base64 substitutes - and _ instead. Learn when to use each, conversion steps, and library support.
Published:
Tags: encoding, url, base64
URL-Safe Base64 Guide: When Standard Base64 Breaks URLs Base64 is a common way to encode binary data as ASCII text. But the standard Base64 alphabet includes two characters — and — that have special meaning in URLs. Drop a standard Base64-encoded value into a URL and you get subtle, hard-to-debug corruption. This post explains why this happens, what URL-safe Base64 is, and where it is used in practice (including JWTs and PKCE). --- What Standard Base64 Looks Like Base64 takes binary data (or UTF-8 text) and represents it as a sequence of characters from a 64-character alphabet: Plus as padding at the end. A few examples: Notice the and in . These are completely normal in standard Base64 — but they cause problems in URLs. --- Why and Break URLs In a URL query string: means a space (in…
All articles · theproductguy.in