Base64 Validator

Inspect, validate, and diagnose Standard Base64 (RFC 4648 §4) and URL-safe Base64URL strings. Detect invalid characters, line & column coordinates, modulo-4 length errors, and padding anomalies with one-click repairs.

How to Use the Base64 Validator

1

Paste or Upload Base64

Enter your Base64 string, Data URI, or JWT segment into the editor, click Upload, or click Sample.

2

Configure Expected Variant

Choose Auto-Detect, Strict Standard Base64 (with `+/`), or Strict Base64URL (`-_` safe).

3

Inspect Diagnostics & Fixes

Click Validate Base64 to review invalid character positions, length/modulo diagnostics, and copy repaired canonical strings.

Tool Options

Expected Variant Enforcement

Configure validation for Auto-Detection, Strict RFC 4648 §4 Standard Base64 (with `+/` & `=`), or Strict RFC 4648 §5 Base64URL (`-_` safe).

RFC 2045 Whitespace Policy

Allow multiline formatted MIME Base64 streams with embedded newlines, or enforce strict whitespace-free checks for raw cryptographic tokens.

Canonical Repair & Diagnostics

Inspect exact Line/Column coordinates, modulo-4 alignment, and automatically generate corrected Standard and URL-Safe canonical strings.

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 Validator do?

The Base64 Validator inspects, validates, and diagnoses Standard Base64 (RFC 4648 §4), Base64URL (RFC 4648 §5), and MIME Base64 (RFC 2045) payloads. It detects illegal non-alphabet characters, reports exact line & column coordinate errors, identifies mixed alphabets (+/ combined with -_), analyzes modulo-4 length alignment, and detects misplaced or excessive = padding.

Core Concepts

  • Modulo-4 Length Constraint: Standard Base64 maps 3 binary bytes (24 bits) into 4 ASCII characters (6 bits each). Padded strings must have a total character count divisible by 4.
  • The Impossible Modulo 1: A Base64 string with length % 4 == 1 is mathematically impossible. A single 6-bit Base64 character cannot represent even a single 8-bit byte.
  • Base64 vs Base64URL: Standard Base64 uses + and / with trailing = padding. Base64URL replaces them with - and _ and omits padding so the string can be safely placed in HTTP URLs, query parameters, and JWT tokens.
  • Misplaced Padding: Padding = characters can only appear at the very end of a Base64 stream (max 2 characters). A = in the middle indicates stream corruption.

How to use the tool?

  1. Enter or Upload Base64: Paste your Base64 string, JWT segment, or Data URI into the editor, click Upload, or click Sample.
  2. Select Expected Variant & Policy: Choose Auto-Detect, Standard (+/), or Base64URL (-_), and configure whitespace rules in the master toolbar.
  3. Instant Real-Time Diagnostics: The validator analyzes in real time. Review validation status, error coordinates, modulo statistics, and decoded payload previews.
  4. Copy Fixes or Export: Copy canonical repaired Standard / Base64URL strings with one click or download the full diagnostic report as JSON.

Context-Aware Practical Workflow Guides

Debugging JWT (JSON Web Tokens)

  • JWT signatures and payload segments use unpadded Base64URL (RFC 7519). If a standard decoder throws a padding error, use this validator to inspect unpadded tokens and generate padded canonical Standard Base64 strings.

Data URI Validation

  • Inspect embedded inline images (data:image/png;base64,...) and font files to ensure no unescaped characters or corrupted byte offsets prevent browser rendering.

Related Developer Utilities

REST API Integration

blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/base64/validator) for programmatic Base64 validation and diagnostics.

API Request Parameters

Name Type Description Example
rawText String / Object The Base64 string or Data URI to inspect (aliases: text, payload, data, input, value). "SGVsbG8gV29ybGQ="
expectedVariant String Optional variant rule: "auto", "standard", "url_safe". "auto"
allowWhitespace Boolean Whether to permit RFC 2045 whitespace/newlines (default: true). true

API Request Payload Examples

cURL

curl -X POST https://blueutils.com/api/base64/validator \
  -H "Content-Type: application/json" \
  -d '{
    "rawText": "SGVsbG8gV29ybGQ="
  }'

Python

import requests

url = "https://blueutils.com/api/base64/validator"
payload = {"rawText": "SGVsbG8gV29ybGQ="}
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": "SGVsbG8gV29ybGQ="
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://blueutils.com/api/base64/validator"))
            .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 the Base64 string is valid. true
variant String Identified variant format. "Standard Base64 (RFC 4648 §4)"
isStandardBase64 Boolean True if conforming to standard alphabet. true
isBase64Url Boolean True if conforming to URL-safe alphabet. false
charStats Object Length, padding, and modulo metrics. { "cleanedLength": 16, "modulo4": 0 }
issues Array Detailed errors and warnings list. []
fixes Object Canonical repaired representations. { "canonicalBase64": "..." }

API Response Payload Examples

Success Response (HTTP 200 OK)

{
  "isValid": true,
  "variant": "Standard Base64 (RFC 4648 §4)",
  "isStandardBase64": true,
  "isBase64Url": false,
  "isDataUri": false,
  "dataUriMime": null,
  "hasWhitespace": false,
  "charStats": {
    "rawLength": 16,
    "cleanedLength": 16,
    "paddingCount": 1,
    "modulo4": 0
  },
  "decodedStats": {
    "byteLength": 11,
    "isUtf8Text": true,
    "previewText": "Hello World"
  },
  "issues": [],
  "fixes": {
    "canonicalBase64": "SGVsbG8gV29ybGQ=",
    "canonicalBase64Url": "SGVsbG8gV29ybGQ"
  }
}

Validation Failure Response (HTTP 400 Bad Request)

{
  "isValid": false,
  "error": "Base64 input cannot be empty.",
  "issues": [
    {
      "type": "empty_input",
      "severity": "error",
      "message": "Base64 string cannot be empty."
    }
  ]
}

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

  • Pre-Ingestion Security Checks: Verify webhook payloads and authentication headers before passing them to backend deserializers.
  • Prevent Decoder Crashes: Isolate corrupted bytes and modulo-1 fragments before database persistence.
  • Automated Fix Generation: Convert unpadded Base64URL tokens into standard Base64 for legacy downstream decoders.

Native Usage

How to validate and test Base64 strings locally in terminal environments:

Windows (PowerShell)

# Validate and decode Base64 in PowerShell
$str = "SGVsbG8gV29ybGQ="
try {
    [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($str))
    Write-Host "Valid Base64" -ForegroundColor Green
} catch {
    Write-Host "Invalid Base64: $_" -ForegroundColor Red
}

Linux / Unix (Bash)

# Validate Base64 using Linux base64 utility
echo "SGVsbG8gV29ybGQ=" | base64 --decode > /dev/null 2>&1 && echo "Valid" || echo "Invalid"

Python

Using Python standard library:

import base64

def check_base64(s):
    try:
        # Check standard and urlsafe decoding
        decoded = base64.b64decode(s, validate=True)
        return True, len(decoded)
    except Exception as e:
        return False, str(e)

print(check_base64("SGVsbG8gV29ybGQ="))

Java

Using Java standard library:

import java.util.Base64;

public class Base64Check {
    public static void main(String[] args) {
        String input = "SGVsbG8gV29ybGQ=";
        try {
            byte[] decoded = Base64.getDecoder().decode(input);
            System.out.println("Valid Base64 (" + decoded.length + " bytes)");
        } catch (IllegalArgumentException e) {
            System.err.println("Invalid Base64: " + e.getMessage());
        }
    }
}

Frequently Asked Questions (FAQ)

What makes a Base64 string invalid?

A Base64 string is invalid if it contains illegal characters (outside A-Z, a-z, 0-9, +, /, =, -, _), has mixed standard and URL-safe characters, has an impossible length (length % 4 == 1), contains misplaced padding in the middle, or has more than two '=' padding characters.

What is the difference between Standard Base64 and Base64URL?

Standard Base64 (RFC 4648 §4) uses '+' and '/' characters and requires '=' padding to multiples of 4. Base64URL (RFC 4648 §5) replaces '+' with '-' and '/' with '_', and typically omits trailing padding to be safe in URLs, query params, and JWT headers.

Why does length % 4 == 1 make Base64 invalid?

Every 4 Base64 characters represent 3 decoded binary bytes (24 bits). A standalone single Base64 character represents only 6 bits, which is insufficient to reconstruct even a single 8-bit byte. Therefore, a valid Base64 string can never have length % 4 == 1.

Can this tool fix invalid or unpadded Base64 strings?

Yes. When padding is missing or characters need standard/URL-safe normalization, the tool provides one-click canonical Standard Base64 and Base64URL fixed strings.

Are my sensitive tokens or Base64 payloads uploaded to servers?

No. All validation checks, character scanning, and padding repairs execute 100% client-side directly inside your browser session for maximum privacy and zero latency.

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.