Hex to Base64 Converter

Convert raw or formatted hexadecimal byte streams (with spaces, 0x, colons, or dashes) into standard RFC 4648 or URL-safe Base64 strings instantly.

How to Convert Hexadecimal to Base64 Online

1

Paste Hex String

Enter raw hex digits, Wireshark dumps, or C-style 0x byte arrays into the input editor.

2

Select Encoding Mode

Optionally toggle URL-Safe Mode and choose whether to strip trailing = padding characters in real time.

3

Copy & Export Base64

The tool converts automatically. Click Copy or Download to export the Base64 result.

Tool Options

Delimiter & Prefix Sanitizer

Automatically cleans spaces, colons, hyphens, commas, 0x, and \x escapes before byte conversion.

URL-Safe Base64 Mode

Generates web-safe Base64 strings using - and _ characters, compliant with JWT and RFC 4648 §5.

Automatic Nibble Alignment

Handles odd-length hexadecimal inputs gracefully by padding with leading zeros to maintain strict byte boundaries.

Your Data Privacy

Web Tool
Privacy-First Architecture
Most of our web tools process your data entirely in-browser. Where server processing is technically required, payloads are evaluated statelessly in-memory and are never stored, saved, or logged.
REST API
Stateless In-Memory Processing
When you use our API endpoints, your requests are processed strictly in-memory without persistent database storage, disk logging, or data retention.
Want to learn more about how we safeguard your information and infrastructure?
Read our full Privacy Policy for detailed security standards, data retention principles, and compliance guarantees.

What does the Hex to Base64 Converter do?

The Hex to Base64 Converter transforms raw hexadecimal byte sequences (Base16) into standard (RFC 4648 §4) and URL-safe Base64 (base64url) representations. It handles a wide range of common developer input formats—including space-separated bytes, colons, hyphens, C/C++ style 0x prefixes, and \x escape codes—normalizing and converting the binary payload with zero external dependencies.

Core Concepts

  • Hexadecimal to Binary Decoding: Hexadecimal encoding represents each byte (8 bits) as two characters from the range 0-9 and a-f. When decoding, two hex characters are combined into a single byte.
  • Odd-Length Alignment: Hex strings with odd lengths (e.g. fff) imply a missing nibble. The converter automatically prepends a leading zero (0fff) to maintain rigorous 8-bit byte boundaries.
  • URL-Safe Base64: URL-safe Base64 replaces + with - and / with _, preventing encoding collisions when embedding binary tokens or signatures into HTTP headers, query parameters, or JWT payloads.

How to use the tool?

  1. Paste Hexadecimal String: Enter your hex string, Wireshark byte dump, cryptographic hash, or binary output into the editor or click Sample.
  2. Configure Output Options: Optionally toggle URL-Safe Mode and choose whether to strip trailing = padding characters.
  3. Live Convert & Export: The tool converts instantly in real time. Click Copy or Download to export the Base64 result.

Related Developer Utilities

  • Base64 to Hex: Decode standard and URL-safe Base64 strings into formatted hexadecimal byte streams.
  • Base64 Encoder: Encode plain UTF-8 text strings to standard and URL-safe Base64.
  • Base64 Decoder: Decode Base64 payloads back to UTF-8 text or formatted JSON.
  • Base64 to Base64URL: Convert standard RFC 4648 Base64 strings to URL-safe Base64 format.

REST API Integration

blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/base64/hex-to-base64) for programmatic integration into CI/CD pipelines, build systems, and autonomous agent workflows.

API Request Parameters

Name Type Description Example
rawText String / Object Hexadecimal string (aliases: text, payload, data, input, value). Supports delimiters like spaces, colons, 0x, \x. "48656c6c6f"
isUrlSafe Boolean Whether to output URL-safe Base64 (- and _). Default is false. true
preservePadding Boolean Whether to keep trailing = padding when URL-safe is active. Default is true. false

API Request Payload Examples

cURL

curl -X POST https://blueutils.com/api/base64/hex-to-base64 \
  -H "Content-Type: application/json" \
  -d '{ "rawText": "48 65 6c 6c 6f 20 42 6c 75 65 75 74 69 6c 73 21", "isUrlSafe": false }'

Python

import requests

url = "https://blueutils.com/api/base64/hex-to-base64"
payload = {
    "rawText": "48 65 6c 6c 6f 20 42 6c 75 65 75 74 69 6c 73 21",
    "isUrlSafe": False
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String jsonPayload = "{\"rawText\": \"48656c6c6f\", \"isUrlSafe\": false}";
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://blueutils.com/api/base64/hex-to-base64"))
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
            .build();
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

API Response Parameters

Name Type Description Example
isValid Boolean Indicates whether Hex parsing and Base64 conversion succeeded. true
result String Base64 encoded output string. "SGVsbG8="
cleanHex String Sanitized continuous hexadecimal string without delimiters. "48656c6c6f"
byteLength Number Total parsed binary length in bytes. 5
bitLength Number Total parsed binary length in bits. 40

API Response Payload Examples

Success Response (HTTP 200 OK)

{
  "isValid": true,
  "result": "SGVsbG8gQmx1ZXV0aWxzIQ==",
  "cleanHex": "48656c6c6f20426c75657574696c7321",
  "byteLength": 16,
  "bitLength": 128,
  "isUrlSafe": false,
  "preservePadding": true
}

Validation Failure Response (HTTP 400 Bad Request)

{
  "isValid": false,
  "error": "Invalid Hex format: String contains non-hexadecimal characters."
}

Rate Limit Exceeded Response (HTTP 429 Too Many Requests)

{
  "error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}

Why use an API to convert Hex to Base64?

Integrating the Hex to Base64 API into automated DevOps pipelines and cloud microservices provides essential benefits:

  • Automated Signature & Digest Translation: Convert raw cryptographic SHA/HMAC hex outputs directly into Base64 format for AWS Signature Version 4 or HTTP Authorization headers.
  • Optimized Token Efficiency for AI Agents: Binary conversions are notoriously error-prone when executed purely via LLM prompt reasoning. Delegating conversion to Blueutils guarantees 100% deterministic accuracy with minimum token cost.
  • Microservice Integration: Process raw byte dumps from Redis, databases, or network sensors into compact Base64 strings for JSON transport across REST boundaries.

Native Usage

Perform Hexadecimal to Base64 conversions locally without external dependencies using native OS tools:

Windows (PowerShell)

# Convert Hex string to Base64 in PowerShell
$hex = "48656c6c6f"
$bytes = for ($i = 0; $i -lt $hex.Length; $i += 2) { [Convert]::ToByte($hex.Substring($i, 2), 16) }
$b64 = [Convert]::ToBase64String($bytes)
Write-Output $b64

Linux / Unix (Bash)

# Convert Hex string to Base64 using xxd and base64
echo -n "48656c6c6f" | xxd -r -p | base64

Python

import base64

hex_str = "48656c6c6f"
raw_bytes = bytes.fromhex(hex_str)
b64_str = base64.b64encode(raw_bytes).decode('utf-8')
print(b64_str)

Java

import java.util.Base64;
import java.util.HexFormat;

public class HexBase64 {
    public static void main(String[] args) {
        String hex = "48656c6c6f";
        byte[] bytes = HexFormat.of().parseHex(hex);
        String b64 = Base64.getEncoder().encodeToString(bytes);
        System.out.println(b64);
    }
}

Frequently Asked Questions (FAQ)

How do I convert Hex to Base64 online?

Paste your hex digits (supports spaces, colons, 0x prefixes) into the editor, select standard or URL-safe mode, and click Convert to Base64.

Does the converter handle odd-length hex strings?

Yes. The converter automatically prepends a leading zero to odd-length hex inputs to maintain 8-bit byte boundary alignment.

Can I generate URL-Safe Base64 from hex?

Yes. Simply toggle the URL-Safe Base64 Mode option to generate strings with - and _ characters suitable for web tokens and URLs.

Rate Limits

UI Limits
100 uses per 15 minutes
Max payload size: 5 MB
API Limits
5 requests per 60 minutes
Max payload size: 256 KB
Need higher API rate limits, increased payload sizes, or custom developer solutions?
Contact our engineering team at support@blueutils.com for custom rate limit increases, higher quota allocations, or tailored enterprise integrations.