Base64 to Hex Converter
Input
Output
Overview
Base64 is a binary-to-text encoding scheme that maps binary data into a subset of ASCII characters (A–Z, a–z, 0–9, +, /) with = padding. It’s commonly used in data URIs, email attachments, and web APIs to safely transmit binary content over channels that only support text. However, hexadecimal (base-16) is often preferred for low-level debugging, address notation, and cryptographic fingerprint display. The Base64 to Hex converter first decodes the input string into raw bytes, then represents each byte as two hexadecimal digits (00–FF).
This tool supports standard Base64 and URL-safe variants (using - and _), correctly handles padding, and rejects invalid characters. The resulting hex string can be consumed by cryptographic libraries, displayed in logs, or embedded in configuration files that expect hex notation.
Key Concepts
Base64 decoding groups input into 4-character blocks, each block representing 3 bytes. Padding characters (‘=’) indicate missing bytes in the final block. Once decoded to bytes, each byte is converted to a two-digit hex string. No spaces or separators are added by default, yielding a compact hex stream.
URL-Safe Variant
The URL-safe Base64 alphabet replaces ‘+’ with ‘-’ and ‘/’ with ‘_’ to avoid reserved URL characters. This converter auto-detects and normalizes URL-safe input before decoding.
Input Format
Input must be a valid Base64-encoded string. Valid characters: A–Z, a–z, 0–9, +, / (or - and _ for URL-safe), and up to two padding characters (‘=’) at the end. Whitespace and line breaks are ignored.
Output Format
The output is a continuous string of lowercase hex digits. Each byte from the decoded data is represented by two hex characters (00–ff). For example, “aGVsbG8=” decodes to bytes [0x68,0x65,0x6c,0x6c,0x6f], which yields “68656c6c6f”.
How It Works
1. **Normalize**: Replace URL-safe characters with standard Base64 alphabet.
2. **Strip**: Remove whitespace and line breaks.
3. **Decode**: Convert Base64 to byte array.
4. **Hex Conversion**: For each byte (0–255), map to two-digit hex.
5. **Concatenate**: Join all hex pairs into a single string.
Use Cases
Developers debugging REST API payloads embedded in JSON or HTML can convert Base64 attachments into hex to inspect raw bytes. Cryptographers use hex to display message digests and signatures; Base64-to-hex conversion provides a quick way to interoperate between web-friendly encodings and hex-based tooling.
In security audits, analysts extract Base64-encoded segments from network traffic and convert them to hex to feed into packet-inspection tools that expect hex input.
Performance Considerations
Base64 decoding and hex conversion are both linear in input length. For very large inputs (>10MB), chunk the data to avoid memory spikes. Browser-based implementations may leverage TypedArrays for speed.
Security Considerations
Reject input with invalid characters or incorrect padding. Enforce a maximum input length to guard against denial-of-service. Isolate conversion in Web Workers for untrusted data.
Example
`aGVsbG8=` → `68656c6c6f`