Base64 to hex converter — and hex back to Base64

Convert a Base64 value into the hex bytes it contains, or turn hex bytes into Base64. Handy for hashes, keys and signatures that one system shows in Base64 and another in hex.

Live demo · real result from this tool
Direction
Hex output

Encoded

48 65 6c 6c 6f 2c 20 54 6f 6f 6c 73 52 69 66 74 21

Processed on your device — nothing is uploaded.

How to use the Base64 to hex converter

  1. Set Direction to Base64 → hex or Hex → Base64.
  2. Paste the value into Input.
  3. For Base64 to hex, choose the Hex output style: 48 65 6c (spaced) or 48656c (compact).
  4. Copy the result.

What it does and when to use it

This is a converter between two ways of writing the same bytes. It does not interpret the bytes as text, so it works for binary values such as:

  • A SHA-256 or SHA-512 digest, to compare an integrity="sha256-…" value with a hash printed in hex.
  • An HMAC or signature returned by an API in Base64, to check it against your own hex output.
  • A key, salt or IV that one library prints in hex and another expects in Base64.

To see the bytes with offsets and a text column, use the hex dump viewer, which also accepts Base64. If the Base64 contains readable text, the Base64 decoder shows it directly. For hashing data in the first place, try the SHA-256 hash generator.

How it works

Both directions go through raw bytes, following RFC 4648 for Base64 and Base16 (hex):

  • Base64 → hex: whitespace and padding are removed, - and _ are mapped to + and /, and each group of 4 characters becomes 3 bytes. Each byte is then printed as two lowercase hex digits.
  • Hex → Base64: separators and prefixes are removed, each pair of digits becomes a byte, and the bytes are Base64-encoded with = padding.

Invalid characters are reported with their position. Nothing leaves your browser.

Worked examples

SGVsbG8=                                →  48 65 6c 6c 6f
SGVsbG8sIFRvb2xzUmlmdCE=  (compact)     →  48656c6c6f2c20546f6f6c735269667421
3q2-7w   (URL-safe, no padding)          →  de ad be ef
0x48 0x65 0x6c 0x6c 0x6f  (Hex → Base64) →  SGVsbG8=
de ad be ef               (Hex → Base64) →  3q2+7w==

The third and last lines are a round trip: the URL-safe 3q2-7w and the standard 3q2+7w== are the same four bytes.

Limits and tips

  • Hex output is always lowercase. Most tools compare hex case-insensitively, but a plain text comparison may not.
  • When comparing a hash, make sure both sides hashed exactly the same bytes, including line endings.
  • For converting text to hex, rather than Base64 to hex, use Text to Hex.

Frequently asked questions

Why would I convert Base64 to hex?
Hashes, keys and signatures are bytes, and different tools print them differently. A checksum tool may show hex while an API, a JWT or a Subresource Integrity attribute uses Base64. Converting one to the other lets you compare them byte for byte.
Which hex formats can I paste?
Pairs with spaces (48 65 6c), one long run (48656c), colons (48:65:6c), commas, dashes, 0x prefixes (0x48 0x65), \x escapes and %XX. Upper and lower case both work. An odd number of hex digits is reported as an error.
Does it accept URL-safe Base64?
Yes. The Base64 side accepts the standard alphabet with + and / and the URL-safe one with - and _, with or without = padding, and ignores spaces and line breaks. A data URI prefix is removed too. Hex to Base64 always gives standard Base64 with padding.
Why is the hex twice as long as the bytes?
Each byte is written as two hex digits, from 00 to ff. A 32-byte SHA-256 digest is 64 hex digits but only 44 Base64 characters, including one = sign.
Does converting change the data?
No. Both forms describe exactly the same bytes. Converting back and forth always returns the original value.

Sources

  1. RFC 4648: The Base16, Base32, and Base64 Data Encodings — IETF / RFC Editor, accessed 2026-10-08

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close