Skip to the Base64 decoder

Base64 → hexadecimal

Base64 to hex, byte by byte.

Paste Base64 and every decoded byte is shown as hexadecimal: a classic dump with offsets and an ASCII column for reading, and Copy hex string for a plain 48656c6c6f-style value you can paste into code, a database or a hash comparison.

Updated · Runs entirely in your browser

Base64 to hex converter

0 chars
Decoded result
Type: — Size: 0 B
Options
General
Decoding options

Ctrl+Enter decode Ctrl+Shift+C copy result Drop a file anywhere on the input to load it

How to convert Base64 to hex

  1. 01

    Paste the Base64

    Paste standard or URL-safe Base64. Missing padding and whitespace are repaired automatically before conversion.

  2. 02

    Read the hex dump

    The Hex tab lists 16 bytes per line: the offset, the bytes in hex, and their printable ASCII characters.

  3. 03

    Copy the format you need

    Copy copies the dump as shown. Copy hex string copies the bytes as one continuous lowercase hex value.

How Base64 becomes hex

Base64 and hex are two ways of writing the same bytes as text. Base64 packs 6 bits into each character; hex uses 4 bits per character. Converting between them means decoding the Base64 to bytes, then writing each byte as two hex digits. So every 4 Base64 characters (3 bytes) become 6 hex digits, and the hex form is about 1.5× the length of the Base64.

Worked example: SGVsbG8= decodes to the five bytes of “Hello”, which in hex are 48 65 6c 6c 6f — or 48656c6c6f as a single string.

Reading the hex dump

Each line starts with the offset of its first byte (in hex), followed by 16 bytes split into two groups of eight, then the same bytes as ASCII with non-printable values shown as dots. This is the layout of xxd and hexdump -C, so output can be compared side by side. The first bytes identify the file type:

The Base64 text each common file type starts with
FormatBase64 starts withFirst bytes (hex)
PNGiVBORw0KGgo89 50 4e 47 0d 0a 1a 0a
JPEG/9j/ff d8 ff
GIFR0lGOD47 49 46 38 (GIF8)
WebPUklGR52 49 46 46 (RIFF)
SVGPHN2Zy / PD94bWwg<svg / <?xml
BMPQk42 4d (BM)
ICOAAABAA00 00 01 00
PDFJVBERi025 50 44 46 2d (%PDF-)
ZIP / DOCX / XLSXUEsDB50 4b 03 04 (PK)
GzipH4sI1f 8b 08

When you need Base64 as hex

  • Hashes and keys. APIs often return SHA-256 digests, HMACs and key IDs in Base64, while documentation and CLIs show them in hex. Converting lets you compare them directly.
  • Binary protocols. Inspect the exact bytes of a protobuf message, a certificate or a packet captured as Base64.
  • Database literals. Postgres bytea ('\x48656c6c6f') and MySQL X'48656C6C6F' take hex, not Base64.

Convert Base64 to hex in code

# Python
base64.b64decode("SGVsbG8=").hex()            # '48656c6c6f'

// Node.js
Buffer.from("SGVsbG8=", "base64").toString("hex")

# Shell
echo "SGVsbG8=" | base64 --decode | xxd -p

# And back again: hex -> Base64
echo "48656c6c6f" | xxd -r -p | base64

For decoding to text instead of hex, use the main Base64 decode tool.

More decoders

Other ways to decode Base64.

Questions

Base64 to hex: common questions.

How do I convert Base64 to hex?

Paste the Base64 into the input box on this page. It is decoded to bytes and shown as a hex dump immediately. Use Copy for the dump or Copy hex string for one continuous hex value. In Python the same conversion is base64.b64decode(s).hex().

Why is the hex longer than the Base64?

Hex stores 4 bits per character while Base64 stores 6, so the same bytes need 1.5 times as many characters in hex. Three bytes are four Base64 characters but six hex digits.

Can I convert hex back to Base64?

Yes. Decode the hex to bytes and encode those bytes as Base64. On the command line that is xxd -r -p | base64; in Python it is base64.b64encode(bytes.fromhex(h)).

Does this work with URL-safe Base64?

Yes. Strings containing - or _ are detected as base64url and converted automatically, and missing = padding is repaired before the bytes are shown in hex.