Base64 Normalizer

Clean stray whitespace, normalize characters between Standard (+/) and URL-safe (-_) alphabets, repair = padding, and format line wrapping to produce canonical, cross-platform Base64 representations.

How to Use the Base64 Normalizer

1

Input Raw Base64

Paste your Base64 string, PEM certificate block, or Data URI into the left input editor, upload a file, or click Sample.

2

Configure Target Format

Select your target alphabet (Standard +/ vs URL-Safe -_), padding policy (Pad, Unpad, Preserve), and line wrapping.

3

Copy or Export Output

Click Normalize Base64 to clean whitespace and view the canonical output on the right, then click Copy or Download.

Tool Options

Target Alphabet Translation

Seamlessly convert between RFC 4648 §4 Standard Base64 (+, /) and RFC 4648 §5 URL-Safe Base64URL (-, _).

Padding & Alignment Normalization

Enforce strict multiple-of-4 padding with =, unpad for compact URL/JWT tokens, or preserve existing padding.

RFC 2045 & PEM Line Wrapping

Format continuous Base64 streams into 76-character MIME blocks (RFC 2045) or 64-character PEM certificate lines (RFC 1421).

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 Base64 Normalizer do?

The Base64 Normalizer cleans dirty or unformatted Base64 strings, strips stray whitespace and newlines, converts between Standard RFC 4648 §4 (+/) and URL-Safe RFC 4648 §5 (-_) alphabets, recalculates required = padding, strips or prepends Data URI prefixes, and formats lines to 76-character MIME or 64-character PEM standards.

Core Concepts

  • Whitespace Sanitation: Email bodies (MIME RFC 2045) and certificates embed arbitrary line breaks, tabs, and spaces that break standard JSON parsers and strict binary decoders. Normalization strips all whitespace cleanly.
  • Alphabet Interoperability: Standard Base64 uses + and / which cause parsing corruption when placed directly in URLs or query strings. Base64URL replaces them with - and _. The normalizer converts between both specifications seamlessly.
  • Padding Alignment: Standard Base64 requires trailing = padding to make string length a multiple of 4, while JWTs (RFC 7519) mandate unpadded Base64URL. Normalization allows you to pad, unpad, or preserve padding.
  • Line Wrapping: Formats continuous streams into 76-character MIME blocks or 64-character PEM blocks for TLS certificates and public keys.

How to use the tool?

  1. Enter or Upload Base64: Paste your Base64 string, PEM certificate, or Data URI into the left editor, click Upload, or click Sample.
  2. Configure Target Format: Select your target alphabet (Standard +/ vs URL-Safe -_), padding policy (Pad, Unpad, Preserve), line wrapping, and Data URI handling directly from the master toolbar.
  3. Instant Real-Time Normalization: The normalized canonical Base64 string and diagnostic metrics update in real time as you type or change options.
  4. Copy or Download: Click Copy to copy the canonical Base64 string or Download to save it as a text file.

Context-Aware Practical Workflow Guides

Preparing Tokens for JWT Signatures

  • Standard Base64 encoded payload strings containing + or / will break JWT parsing. Convert your string to URL-Safe Base64URL with Unpad policy to ensure RFC 7519 compliance.

Formatting OpenSSL Certificates & PEM Keys

  • Select PEM Wrap (64 Chars) and Standard Base64 to format unformatted Base64 payloads into valid cryptographic certificate blocks.

Related Developer Utilities

  • Base64 Validator: Validate Base64 syntax, inspect invalid characters, and diagnose modulo-4 length errors.
  • Base64 Encoder: Encode UTF-8 plain text into standard or URL-safe Base64 strings.
  • Base64 Decoder: Decode Base64 payloads into UTF-8 text or formatted JSON.
  • Base64 to Hex Converter: Convert Base64 strings to formatted hexadecimal byte streams.

REST API Integration

blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/base64/normalizer) for programmatic Base64 normalization.

API Request Parameters

Name Type Description Example
rawText String / Object The unformatted Base64 string or Data URI (aliases: text, payload, data, input, value). "SGVsbG8g\n V29ybGQ"
targetAlphabet String Target alphabet: "standard" or "url_safe". "standard"
paddingMode String Padding policy: "pad", "unpad", or "preserve". "pad"
lineWrap String Line wrap: "none", "mime", "pem", or "custom". "none"
stripDataUri Boolean Whether to strip Data URI prefix (default: true). true

API Request Payload Examples

cURL

curl -X POST https://blueutils.com/api/base64/normalizer \
  -H "Content-Type: application/json" \
  -d '{
    "rawText": "eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9l\nIiwiaWF0IjoxNTE2MjM5MDIyLCJyb2xlIjoiYWRtaW4ifQ",
    "targetAlphabet": "standard",
    "paddingMode": "pad"
  }'

Python

import requests

url = "https://blueutils.com/api/base64/normalizer"
payload = {
    "rawText": "eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9l\nIiwiaWF0IjoxNTE2MjM5MDIyLCJyb2xlIjoiYWRtaW4ifQ",
    "targetAlphabet": "standard",
    "paddingMode": "pad"
}
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": "eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9l\\nIiwiaWF0IjoxNTE2MjM5MDIyLCJyb2xlIjoiYWRtaW4ifQ",
                "targetAlphabet": "standard",
                "paddingMode": "pad"
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://blueutils.com/api/base64/normalizer"))
            .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 normalization succeeded. true
normalizedBase64 String The cleaned, canonical Base64 output string. "SGVsbG8gV29ybGQ="
originalStats Object Diagnostics on input string before normalization. { "hadWhitespace": true }
normalizedStats Object Metrics on output canonical Base64 string. { "outputLength": 16, "paddingCount": 1 }

API Response Payload Examples

Success Response (HTTP 200 OK)

{
  "isValid": true,
  "normalizedBase64": "SGVsbG8gV29ybGQ=",
  "originalStats": {
    "rawLength": 18,
    "detectedVariant": "Standard Base64",
    "hadWhitespace": true,
    "hadDataUriPrefix": false,
    "originalPadding": 0
  },
  "normalizedStats": {
    "outputLength": 16,
    "targetVariant": "Standard Base64 (RFC 4648 §4)",
    "paddingCount": 1,
    "lineCount": 1,
    "decodedBytes": 11
  }
}

Validation Failure Response (HTTP 400 Bad Request)

{
  "isValid": false,
  "error": "Invalid character \"#\" (ASCII 35) found at Line 1, Column 7."
}

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 normalize Base64?

  • Data Ingestion Pipelines: Normalize incoming Base64 file attachments and webhooks to standard RFC 4648 representations before database storage.
  • Cross-Service Microservice Compatibility: Bridge Golang, Python, and Java services that have conflicting requirements for Base64URL padding.
  • Automated Certificate Formatting: Clean raw certificate tokens from AWS Secrets Manager or Vault into formatted 64-char PEM blocks.

Native Usage

How to clean and normalize Base64 strings locally in terminal environments:

Windows (PowerShell)

# Clean whitespace and normalize padding in PowerShell
$raw = "SGVsbG8g`nV29ybGQ" -replace '\s',''
while ($raw.Length % 4 -ne 0) { $raw += '=' }
Write-Host "Normalized: $raw"

Linux / Unix (Bash)

# Strip whitespace and pad using tr and awk in Bash
echo "SGVsbG8g V29ybGQ" | tr -d ' \n\r\t'

Python

Using Python standard library:

import re

raw = "eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9l\nIiwiaWF0IjoxNTE2MjM5MDIyLCJyb2xlIjoiYWRtaW4ifQ"
clean = re.sub(r'\s+', '', raw).replace('-', '+').replace('_', '/')
while len(clean) % 4 != 0:
    clean += '='

print("Normalized Base64:", clean)

Java

Using Java standard library:

public class Base64Normalize {
    public static void main(String[] args) {
        String raw = "SGVsbG8g\n V29ybGQ";
        String clean = raw.replaceAll("\\s+", "").replace('-', '+').replace('_', '/');
        while (clean.length() % 4 != 0) {
            clean += "=";
        }
        System.out.println("Normalized: " + clean);
    }
}

Frequently Asked Questions (FAQ)

How does the Base64 Normalizer clean dirty or malformed strings?

The normalizer strips unwanted whitespace, line breaks, and tabs, maps between Standard (+/) and URL-Safe (-_) alphabets, recalculates required '=' padding, and optionally adds RFC 2045 (76-char) or PEM (64-char) line wrapping.

What is the difference between pad, unpad, and preserve padding modes?

Pad ensures the string length is a multiple of 4 by appending '=', Unpad strips all trailing '=' characters for compact Base64URL/JWT tokens, and Preserve maintains existing padding only if originally present.

Can I extract raw Base64 data from a Data URI?

Yes. By default, the normalizer strips data:image/...;base64, prefixes to output raw Base64 payloads, or can prepend custom Data URI schemes on demand.

Why should I normalize Base64 strings before storing in databases or JWTs?

Inconsistent whitespace, stray line breaks, or mixed + and - characters frequently cause decoder exceptions in backend microservices. Normalizing to a canonical representation ensures cross-platform decoder compatibility.

Are my sensitive tokens, certificates, or keys processed privately?

Yes. All whitespace cleaning, alphabet translation, and padding repairs execute 100% locally in your browser without transmitting your payload to external servers.

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.