Converting Base64 to hexadecimal means translating the same bytes between two text-safe representations: RFC 4648 Base64, which encodes every three input bytes as four characters drawn from an alphabet of 64, and Base16 hex, which writes each byte as exactly two characters from 0–9 and a–f. The bytes themselves never change — only their on-screen format does — so the conversion is fully reversible and proves itself by round-tripping without loss. For any payload up to 500,000 decoded bytes, a browser-side tool can validate the alphabet, the required equals padding, and the zero pad bits, then emit canonical lowercase hex with no separators. This kind of strict conversion is what you reach for when you need to inspect an encoded payload, paste a hash into a different tool, or compare a value against an RFC test vector. The same workflow in reverse — hex bytes back to Base64 — lets you rebuild a token or a protocol field for transport after you have inspected or edited it in hex form.

how to convert base64 to hex
how to convert base64 to hex

What Base64 and Hex Actually Represent

Base64 and hex are both reversible encodings, not encryption, hashing, or compression. They take raw bytes and print them as text using different alphabets so the data can travel through channels that would otherwise mangle binary values, or so the data can be inspected on a screen one byte at a time.

Standard Base64, defined in RFC 4648, groups input bytes into triples and writes each triple as four characters from an alphabet of 64: uppercase A–Z, lowercase a–z, the digits 0–9, the plus sign, and the forward slash. When the final group contains one or two bytes instead of three, one or two equals signs pad the output to a multiple of four characters. Hex, also defined in RFC 4648, is simpler: each byte becomes exactly two characters from 0–9 and a–f. Hex input accepts both cases, but standard output is always lowercase for compactness and consistency.

PropertyRFC 4648 Base64Base16 Hexadecimal
Alphabet size64 printable characters16 characters (0–9, a–f)
Bytes per group3 input bytes → 4 output characters1 input byte → 2 output characters
Padding rule1 or 2 trailing equals signs requiredNone required; odd length is invalid
Output length≈ 4 characters per 3 bytesExactly 2 characters per byte
Special characters+ and / used as values 62 and 63None beyond digits
Case sensitivityCase-sensitive alphabetInput accepts both cases; output lowercase
Typical roleTransport in text channels (MIME, JWT, keys)Inspection, hashing output, byte-level debugging

Because Base64 is more compact on the wire but unreadable without decoding, and hex is longer but byte-explicit on the page, the two formats show up in different parts of the same workflow. That is the reason "base64 to hex" is a real recurring task instead of a curiosity, and the reason the conversion needs to be exact rather than approximate.

When You Need to Convert Between Them

A handful of situations make a byte-exact base64↔hex conversion the right tool for the job:

  • Reading encoded payloads. Tokens, certificate fields, JWT segments, and signed data often arrive as Base64. Dropping them into hex lets you confirm length, see leading zero bytes, and spot stray whitespace or padding mistakes before they cause protocol failures downstream.
  • Comparing against test vectors. RFC 4648 ships canonical vectors such as the empty string, f, fo, foo, foob, fooba, and foobar, plus a vector exercising alphabet values 62 and 63. Running your input through both directions and checking the output against the spec catches typos before they become protocol bugs.
  • Hashes and identifiers. A SHA-256 digest, a UUID, or a binary identifier may be delivered in either format depending on the system that produced it. Converting between them is faster than re-running the hash and easier than counting characters by hand.
  • Building fixtures. Protocol tests, cache keys, and replay files often want exact byte sequences. Hex makes the byte boundaries visually explicit, which helps when you are diffing fixtures in code review or pasting them into multiple test runners.

If your goal is one of those — inspecting, comparing, or assembling exact bytes — then a strict converter is the right level of tool. If you actually want to decode a JWT payload, render an image, or read a UTF-8 string, you need a different step that interprets the bytes after the conversion.

How to Convert Base64 to Hex Online

The Base64 to Hex Converter runs entirely in the browser and validates each step of the conversion. The exact workflow is:

  1. Choose the direction: Base64 → hex if your source is RFC 4648 Base64, or hex → Base64 if you are starting from hex bytes. The page also lets you paste either side so you can round-trip a value to confirm correctness.
  2. Identify the source profile. Standard Base64 uses +, /, and required = padding. If your input uses - and _, or omits the trailing equals signs, it is base64url under a separate profile and must be converted to standard form first.
  3. Paste the input exactly. For Base64, paste canonical padded text with no spaces, line breaks, or surrounding quotes. For hex, paste a continuous string with exactly two digits per byte, no 0x prefix, no spaces, no underscores, no colon separators, and no odd trailing nibble.
  4. Run the conversion. The page decodes the bytes, validates canonical padding and zero pad bits, then re-emits them as lowercase hex or standard padded Base64. Conversion is bounded at 500,000 decoded bytes to keep browser memory predictable, and output is never silently truncated.
  5. Verify the result. Check that the byte length matches expectations (Base64 character count ÷ 4 × 3, minus trailing equals signs), confirm any leading zero bytes appear as 00 in hex, and then copy the exact output with the page's copy action — only the converted value is placed on the clipboard, not labels or explanatory text.

A quick worked example using the RFC 4648 vector foo: the three bytes are 0x66, 0x6f, 0x6f, which the converter renders as the hex string 666f6f and as the Base64 string Zm9v. Round-tripping either direction through the same tool must produce the other representation byte for byte — that is the basic correctness check the tool is designed to satisfy.

Rules the Converter Enforces

The tool is intentionally strict rather than permissive. Every one of these rules exists to keep a successful conversion from masking a real mistake:

  • Standard Base64 only. The alphabet is exactly A–Z, a–z, 0–9, +, /. Whitespace is rejected, base64url (- and _) is rejected, and MIME-style line wrapping is rejected. If you are not sure which profile you have, identify it first — guessing the profile is exactly how silent errors creep into protocol code.
  • Length is a multiple of four. Any other length means the input is malformed and cannot decode to whole bytes.
  • Padding appears only at the end. Equals signs belong in the last group of four characters and nowhere else. A spurious equals in the middle is not "extra padding" — it is a structural error.
  • Zero pad bits are rejected. After decoding, the tool re-encodes the bytes and checks that the result matches the input exactly. A non-canonical Base64 string that decodes to the same bytes through different pad bits is refused, because accepting it would let two different spellings represent the same value.
  • Hex is two digits per byte, no prefixes. Input like 0f is one byte; f alone is incomplete and rejected. Prefixes such as 0x, separators like spaces, underscores, or colons, and odd-length strings are all rejected so byte boundaries never get ambiguous.
  • Output is lowercase hex. Hex input may be uppercase or lowercase, but output is always lowercase for compactness and consistency across runs.

When any of these checks fail, you get a specific error and no partial result. There is no silent truncation and no best-guess fallback.

Reading the Output Without Mistakes

The converted hex string looks deceptively simple, but two checks catch almost every mistake downstream.

First, count the hex characters. Each byte is two characters, so a valid hex string always has even length. If you started from Zm9v (four Base64 characters, no equals), the byte length is 3 and the hex string should be 6 characters long: 666f6f. If you started from Zm8= (one trailing byte, one equals sign), the byte length is 2 and the hex string should be 4 characters long. An odd-length hex output is a red flag that something was lost in transit.

Second, watch for leading zeros. If the first byte of your input is 0x00, it shows up as the two characters 00 at the front of the hex output — easy to miss when scanning visually. Conversely, if you expect 00 at the start and you do not see it, that is a strong sign the leading byte was dropped somewhere upstream, either in the conversion or in the system that produced the source string. Preserving these leading zeros is exactly what makes the representation byte-exact, and it is the property that signed data, cache keys, and protocol fixtures depend on.

Common Pitfalls and Safety Notes

A few mistakes come up often enough to call out before you paste your first string:

  • Confusing Base64 with base64url. JWTs and many web APIs use base64url, which swaps + and / for - and _ and frequently drops the trailing equals signs. A standard Base64 converter will reject this input outright. Convert to canonical padded standard Base64 first, then run the tool, rather than trying to "fix it on the fly".
  • Letting whitespace slip in. Line breaks, spaces, and tabs are not part of the standard alphabet. Email pipelines and copy-paste from terminals often add them, especially for longer payloads. Strip them before pasting so the strict parser does not reject otherwise valid bytes.
  • Treating a successful conversion as semantic validation. The converter proves the bytes round-trip exactly. It does not prove those bytes mean what you think they mean. For security-sensitive protocols, compare the final representation against the governing specification or an official test vector rather than treating a green conversion as proof of correctness.
  • Using Base64 or hex as if they protect a secret. Both encodings are fully reversible. Anyone who has the encoded string has the original bytes. Treat tokens, private keys, passwords, and personal data with the same care regardless of how they are formatted, and keep them out of untrusted clipboards, logs, screenshots, issue trackers, analytics fields, and shared browser sessions.

Once those pitfalls are out of the way, the conversion itself is short: confirm the profile, paste the exact bytes, run the tool, verify the byte length and any leading zeros, and copy the result. That single round trip is what makes base64↔hex such a dependable part of day-to-day protocol work, and it is why strict validation is worth the few extra seconds it costs over a permissive decoder.