Two text representations of the same bytes
Base64 maps groups of bytes into a 64-character alphabet, while hexadecimal writes each byte as two digits from 00 to FF. Converting between them does not interpret the bytes as text and does not change their binary value.
The spaced hex view makes signatures, delimiters, null bytes, and protocol fields easier to inspect. Reverse conversion accepts spaces, commas, colons, and optional 0x prefixes, but still requires exactly two hex digits per byte.
Byte inspection without encoding guesses
A Base64 payload may represent UTF-8, an image, compressed data, encrypted bytes, or any other binary format. Hex is useful when a text decoder would replace invalid sequences or hide zero bytes.
Neither Base64 nor hex protects information. Both are reversible encodings. Use a file signature tool, protocol specification, or cryptographic verification when the meaning and integrity of the bytes matter.
Common failures this tool explains
- The Base64 side contains invalid characters or impossible padding.
- The hex side contains a non-hexadecimal character.
- The hex side has an odd number of digits.
- Decoded bytes are mistaken for readable text without checking their character encoding.
Equivalent commands
Use the runtime or shell already available in your workflow. Validate untrusted input and keep binary output out of terminals when it may contain control bytes.
Python
import base64
hex_value = base64.b64decode(value, validate=True).hex(' ')
base64_value = base64.b64encode(bytes.fromhex(hex_value)).decode('ascii')
JavaScript
const hex = Buffer.from(value, 'base64').toString('hex');
const base64 = Buffer.from(hex, 'hex').toString('base64');
Shell
printf '%s' "$VALUE" | base64 --decode | xxd -p
printf '%s' "$HEX" | xxd -r -p | base64 --wrap=0