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?
- Enter or Upload Base64: Paste your Base64 string, PEM certificate, or Data URI into the left editor, click Upload, or click Sample.
- 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. - Instant Real-Time Normalization: The normalized canonical Base64 string and diagnostic metrics update in real time as you type or change options.
- 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);
}
}