Base64 to Hex Converter

Seamlessly convert between Base64 strings and Hexadecimal (base-16) representation. Perfect for debugging binary data, analyzing encoded payloads, and understanding low-level encoding.

Client-side & secure: All conversions happen locally using JavaScript. Your data never leaves your device – ideal for sensitive keys or private tokens.
Base64 → Hex
Decode Base64 and get hexadecimal representation
Standard Base64 with optional padding. Accepts multiline input.
? "Hello World" ? Quick fox ? Binary 0x01..0x09 ?️ Tiny PNG
Hex → Base64
Convert hexadecimal string back to Base64 encoding
Hex digits only (0-9, A-F). Spaces and 0x prefixes are automatically stripped.
? "Hello World" hex ? Quick fox hex ? Bytes 1-9 ? PNG header

Understanding Base64 & Hexadecimal Encoding

Base64 and hexadecimal (hex) are two widely used methods for representing binary data in a textual format. While hex uses base-16 (digits 0-9 and letters A-F), Base64 uses an alphabet of 64 ASCII characters (A-Z, a-z, 0-9, +, /) plus padding (=). Both are essential in modern computing — from data URIs, JSON web tokens, cryptographic keys, to low-level network protocols.

Key difference: Hexadecimal is more human-readable and consumes 2 characters per byte (50% overhead). Base64 is more compact, using ~4 characters per 3 bytes (33% overhead), making it preferable for transmitting binary data over text-based media (email, JSON, URLs).

How the Conversion Works (Technical Deep Dive)

Base64 → Hex: The conversion algorithm first decodes the Base64 string into its original binary form using the standard Base64 decoding table (RFC 4648). Each group of 4 Base64 characters yields 3 bytes (24 bits). These bytes are then transformed into a hexadecimal representation: every byte (8 bits) maps to two hex characters (0–FF). The process is reversible and deterministic.

Hex → Base64: The hex string is normalized (removing whitespace, '0x' prefix) and validated to ensure even length and valid characters. Then each pair of hex digits is interpreted as a byte. The resulting byte sequence is encoded to Base64 by splitting into 24-bit groups and mapping to the Base64 alphabet, adding padding (=) if necessary.

// JavaScript conceptual implementation (client-side)
// Base64 to Hex: atob(str) → char codes → hex string
// Hex to Base64: hex string → byte array → btoa(binaryString)

Real‑world Applications & Use Cases

  • JWT (JSON Web Tokens): Inspect the payload and signature: tokens use Base64Url encoding; converting to hex allows low-level analysis.
  • Cryptography & Hashing: Cryptographic digests (SHA-256, MD5) are often displayed as hex strings, but embedded in JSON or XML as Base64.
  • Data URI & Web Performance: Small images or fonts are embedded as Base64 in CSS/HTML — convert to hex for forensic analysis.
  • Debugging binary protocols: Network engineers convert raw Base64 logs to hex to inspect individual bytes.
  • PostgreSQL / MySQL: Storing bytea data often uses hex or Base64 representations — quick conversion helps data migration.

Base64 vs Hex: Comparative Table

Property Hexadecimal (Base16) Base64
Alphabet size 16 (0-9, A-F) 64 (A-Z, a-z, 0-9, +, /)
Characters per byte 2 characters ~1.33 characters (4 chars / 3 bytes)
Overhead 100% (2x original size) 33%
Human readability High (familiar hex dumps) Moderate (compact but opaque)
Typical use Debugging, memory dumps, color codes Email attachments (MIME), JWT, API tokens
Standard reference RFC 4648 (Base16) RFC 4648 (Base64)
Case Study: API Token Inspection

A developer receives a Base64-encoded refresh token in a mobile app log: dGhpc2lzYXRlc3R0b2tlbjEyMw==. Converting it to hex yields 7468697369736174657374746f6b656e313233, which immediately reveals ASCII characters: "thisisatesttoken123". This demonstrates how hex conversion can be used for rapid forensic analysis. Using our tool, security analysts can verify token structure without writing custom scripts.

Frequently Asked Questions

Absolutely. The conversion engine runs entirely in your browser using JavaScript. No input is sent to any server. We never log, store, or transmit your Base64 or hex strings. Perfect for passwords, private keys, or proprietary data.

The error appears when the input contains characters outside the standard Base64 alphabet (A-Z, a-z, 0-9, +, /, =) or improper padding length. Ensure your string is correctly Base64-encoded. For hex to Base64, check that the hex string has an even number of characters and contains only 0-9, A-F.

Yes! Check the "URL-safe Base64" option under the Base64 input field. It will automatically convert '-' to '+' and '_' to '/' before decoding, allowing you to work with JWT tokens and other Base64URL strings.

This tool works with strings up to several megabytes depending on browser memory. For large inputs (>1MB) a loading spinner appears; the conversion may take a few seconds but remains fully client-side. For extremely large inputs (>10MB) performance may degrade, but typical API keys, certificates, and short text files work instantly.

Hexadecimal representation gives you a byte-by-byte view — it's easier to spot patterns, find magic numbers, or inspect binary headers (e.g., PNG starts with '89 50 4E 47'). Base64 is more condensed but hides individual byte boundaries, making low-level analysis harder.
Standards & References: This tool adheres to RFC 4648 (The Base16, Base32, and Base64 Data Encodings). Implementation verified against test vectors from IETF and NIST.  

Engineered for precision & trust – GetZenQuery's encoding tools are built by security-conscious developers and peer-reviewed for correctness. Last updated: May 2026.