Base64 Guide

Base64URL vs Base64

Learn the differences between Base64URL and Base64, including alphabet changes, padding behavior, and conversion patterns.

Updated:

Base64URL is a URL-safe variant of Base64.

You often receive Base64URL payloads from JWT, OAuth, and browser API integrations.

What changes in Base64URL

Base64URL replaces '+' with '-', '/' with '_', and often omits '=' padding.

  • Safe for URL query strings and path segments.
  • Not always accepted by classic Base64 decoders.
  • Needs normalization before atob/decode steps.

Convert Base64URL to Base64

Normalize alphabet and restore padding before decoding.

function base64UrlToBase64(input: string): string {
  const normalized = input.replace(/-/g, "+").replace(/_/g, "/");
  const pad = normalized.length % 4;
  return pad === 0 ? normalized : normalized + "=".repeat(4 - pad);
}

Practical checklist

When decode fails, verify both alphabet and length constraints.

  • Strip whitespace before conversion.
  • Normalize to Base64 then decode.
  • Validate expected MIME if Data URL is present.

Frequently asked questions

When should I use Base64URL vs Base64?

Use this guide for Base64URL vs Base64.

Can this workflow run without backend?

Yes. The implementation is browser-first. Keep validation, size limits, and error handling in the client flow.

What is the first step when conversion fails?

Start with payload normalization, MIME checks, and route validation. Then verify with the related tool: Base64 decoder

Primary converter page for this intent

Related tools

Next steps

More Base64 guides

Editorial and trust signals

  • Guide content is reviewed for practical browser-only implementation.
  • Examples focus on safe payload handling and clear validation checks.
  • Each page includes last-updated date and links to supporting routes.