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
JSON Web Token
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
- 01
Paste the Base64
Paste standard or URL-safe Base64. Missing padding and whitespace are repaired automatically before conversion.
- 02
Read the hex dump
The Hex tab lists 16 bytes per line: the offset, the bytes in hex, and their printable ASCII characters.
- 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:
| Format | Base64 starts with | First bytes (hex) |
|---|---|---|
| PNG | iVBORw0KGgo | 89 50 4e 47 0d 0a 1a 0a |
| JPEG | /9j/ | ff d8 ff |
| GIF | R0lGOD | 47 49 46 38 (GIF8) |
| WebP | UklGR | 52 49 46 46 (RIFF) |
| SVG | PHN2Zy / PD94bWwg | <svg / <?xml |
| BMP | Qk | 42 4d (BM) |
| ICO | AAABAA | 00 00 01 00 |
JVBERi0 | 25 50 44 46 2d (%PDF-) | |
| ZIP / DOCX / XLSX | UEsDB | 50 4b 03 04 (PK) |
| Gzip | H4sI | 1f 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 MySQLX'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.
- Base64 decode Decode any Base64 to text, an image or a file, with 20+ character sets.
- Base64 to image Preview a Base64 PNG, JPEG, GIF, WebP or SVG and save it as a real image file.
- Base64 to PDF Turn a Base64 string from an API or email into a PDF you can view and save.
- Base64URL decode Decode URL-safe Base64 and JSON Web Tokens, with missing padding repaired.
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.