Base64, URL & Hash (SHA-256 / MD5) Encoder & Decoder
Encode and decode plain text or binary data to Base64, URL-encoded strings, SHA-256 cryptographic hashes, and MD5 digests.
Base64 (RFC 4648) Mathematical Encoding Architecture
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It divides 24 bits of input data (3 bytes) into four 6-bit groups, mapping each 6-bit value to an index in a 64-character alphabet (A-Z, a-z, 0-9, +, /) so binary payloads survive legacy text-only MIME and JSON transports intact.
+-----------------------------------------------------------------------------------+ | BASE64 24-BIT TO 4-CHARACTER CONVERSION | +-----------------------------------------------------------------------------------+ | Input Bytes: 'M' (0x4D) 'a' (0x61) 'n' (0x6E) | | Binary Bits: 0 1 0 0 1 1 0 1 0 1 1 0 0 0 0 1 0 1 1 0 1 1 1 0 | | 6-Bit Groups: 010011 010110 000101 101110 | | Decimal Index: 19 22 5 46 | | Base64 Output: 'T' 'W' 'F' 'u' | +-----------------------------------------------------------------------------------+ | Size Overhead: Base64 expands binary byte payloads by exactly 33.3% (4/3 ratio). | | URL-Safe Variant: Replaces '+' with '-' and '/' with '_', stripping '=' padding.| +-----------------------------------------------------------------------------------+
UTF-8 & btoa() Encoding Traps
Browser natives like window.btoa() only accept single-byte Latin1 code points and throw InvalidCharacterError on multi-byte emojis or accented UTF-8 characters. Production pipelines should encode strings through TextEncoder into a Uint8Array byte stream before mapping chunks, then reverse with TextDecoder to prevent silent mojibake corruption across internationalized API payloads and filenames.
Base64url & Padding Normalization
Standard Base64 uses +, /, and =, which collide with query string delimiters and get percent-escaped or misinterpreted as spaces in HTTP forms. RFC 4648 Section 5 swaps + for - and / for _ and omits trailing = padding for JWT claims and PKCE verifiers; strict decoders must restore missing padding to a multiple of four characters before parsing.
Data URI Bloat & Transport Hygiene
Inlining large images as Base64 data URIs inside CSS or JSON increases payload size by 33%, blocks independent CDN caching, and forces main-thread decode overhead. Reserve Base64 for tiny critical-path icons or multipart MIME attachments, strip whitespace newlines before decoding PEM blocks, and remember HTTP Basic Auth headers expose credentials trivially without TLS encryption.
About Base64 & URL Encoder / Decoder & Security Considerations
Everything you need to know about how this utility processes data safely in your browser.
Is Base64 an encryption method?
No, Base64 is an encoding format designed to transmit binary data over text-only protocols. It provides zero cryptographic secrecy.
Why is SHA-256 preferred over MD5?
MD5 suffers from known hash collision vulnerabilities and is cryptographically broken, whereas SHA-256 is collision-resistant.
What is the padding character = in Base64?
Base64 processes data in 3-byte chunks. If the input data is not an exact multiple of 3 bytes (1 or 2 bytes left over), one or two = characters are appended to the output string to ensure the final block contains 4 characters.
When should developers use Base64 Data URLs for images?
Data URLs (data:image/png;base64,...) are ideal for tiny icons (< 2KB) or critical above-the-fold SVGs to eliminate extra HTTP round-trips. For larger assets, external URLs with browser caching and CDN optimization are superior.