Hex ⇄ Base64 Converter

Converts raw bytes directly between hex and Base64 (or Base64URL), accepting 0x prefixes, spaces and colons in the hex, and formats hex output as you like.

Use the tool

Why this tool exists

Hashes, keys, signatures and binary IDs are shown as hex in one place and Base64 in another. A SHA-256 digest in a log is hex, the same value in a JWT or an HTTP header is Base64. Converting between them with a normal text Base64 tool gives the wrong answer, because those tools encode the characters of the hex string, not the bytes it stands for. This converter works on the bytes themselves. Paste a fingerprint with colons, a value starting with 0x or a spaced hex dump and get the right Base64, with or without padding and in the URL-safe alphabet. It also goes the other way and groups the hex into pairs. Nothing leaves your browser.

How to use it

  1. Choose the direction: hex to Base64, or Base64 to hex.
  2. Paste the value. Hex may include 0x, spaces, commas, dashes or colons; Base64 may be standard or URL-safe.
  3. Set the options for URL-safe alphabet, padding, upper-case hex and grouping, then copy the result.

Frequently asked questions

Why not just use a normal Base64 encoder?

A text encoder turns the characters "de ad be ef" into Base64, not the four bytes they represent. This tool first decodes the hex to bytes and then encodes those bytes, which is what keys and digests need.

What makes hex input invalid?

After removing 0x, spaces, commas, dashes and colons the input must contain an even number of digits from 0-9 and a-f. An odd count or any other character produces an error.

What is the Base64URL option?

It swaps + and / for - and _ so the value can sit in a URL or JWT. You can also drop the = padding. When decoding, the tool accepts either alphabet.

Is there a size limit?

There is no fixed limit, but it runs in the page, so very large inputs will be slow. It is meant for keys, digests and short binary values.