What does the Base64URL to Base64 Converter do?
The Base64URL to Base64 Converter transforms URL-safe Base64URL strings (RFC 7515, commonly used in JWTs, OAuth tokens, and WebAuthn credentials) into standard RFC 4648 Base64 strings. It replaces - with +, _ with /, and computes and appends the exact trailing = padding needed for strict backend decoders.
Core Concepts
Understanding Base64URL to Base64 conversion mechanics:
- Alphabet Character Swapping: Maps URL-safe characters (
-and_) back to standard Base64 characters (+and/). - Modulo-4 Padding Calculation: Base64 strings must have a length divisible by 4. If length modulo 4 is
2, two=signs are appended; if3, one=sign is appended. - Input Validation: Strict error detection flags input strings containing invalid characters (such as standard
+or/characters in Base64URL input) or malformed lengths (length % 4 == 1).
How to use the tool?
- Paste Base64URL String: Enter or paste your Base64URL string into the editor or click Sample.
- Live Auto-Map & Padding: The tool automatically maps characters and computes trailing
=padding in real time. - Copy Output: Click Copy or Download to export the standard Base64 result.
Related Developer Utilities
If you work with Base64 encoding, JWT tokens, and URL safety, explore these complementary tools:
- Base64 to Base64URL Converter: Convert standard Base64 into URL-safe Base64URL.
- Base64 Decoder: Decode Base64 payloads into UTF-8 text or JSON.
- Base64 Encoder: Encode plain text into Base64 or URL-safe Base64.
- JWT Decoder: Parse and inspect JSON Web Tokens.
REST API Integration
blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/base64/base64url-to-base64) to programmatically convert URL-safe Base64URL strings into standard Base64 strings with exact padding calculations.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
rawText |
String / Object | Base64URL string or object to convert (aliases: text, payload, data, input, value). |
"eyJzdWIiOiIxMjM0In0-w_1" |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/base64/base64url-to-base64 \
-H "Content-Type: application/json" \
-d '{
"rawText": "eyJzdWIiOiIxMjM0In0-w_1"
}'Python
import requests
url = "https://blueutils.com/api/base64/base64url-to-base64"
payload = {"rawText": "eyJzdWIiOiIxMjM0In0-w_1"}
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": "eyJzdWIiOiIxMjM0In0-w_1"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/base64/base64url-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 conversion succeeded. | true |
converted |
String | Converted standard Base64 string. | "eyJzdWIiOiIxMjM0In0+w/1==" |
inputLength |
Number | Character length of input string. | 24 |
outputLength |
Number | Character length of output string. | 28 |
paddingAdded |
Number | Count of = characters appended. |
2 |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"inputLength": 24,
"outputLength": 28,
"paddingAdded": 2,
"converted": "eyJzdWIiOiIxMjM0In0+w/1=="
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "Invalid Base64URL: String contains standard Base64 characters (\"+\" or \"/\")."
}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 Base64URL to Base64?
Integrating the Base64URL to Base64 API into authentication microservices, token validation layers, or AI agent tool calling provides key benefits:
- Rapid Script Validation: Converts unpadded URL-safe tokens from OAuth identity providers into standard Base64 payloads compatible with strict legacy crypto libraries.
- Optimized Token Efficiency for AI Agents: LLMs frequently miscount modulo-4 padding characters. Invoking the API normalizes strings deterministically without hallucination.
- Deterministic Accuracy Without Hallucinations: Ensures 100% accurate character swapping and RFC 4648 padding syntax.
Native Usage
How to convert Base64URL to standard Base64 locally in terminal environments or scripts:
Windows (CMD / PowerShell)
# Convert Base64URL to standard Base64 in PowerShell
$b64url = "eyJzdWIiOiIxMjM0In0-w_1"
$b64 = $b64url.Replace('-', '+').Replace('_', '/')
$pad = (4 - ($b64.Length % 4)) % 4
$b64 = $b64 + ('=' * $pad)
Write-Output "Standard Base64: $b64"Linux / Unix (Bash)
# Convert Base64URL to standard Base64 in Linux
b64url="eyJzdWIiOiIxMjM0In0-w_1"
b64=$(echo -n "$b64url" | tr '_-' '/+')
pad=$(( (4 - ${#b64} % 4) % 4 ))
printf '%s%*s\n' "$b64" $pad '' | tr ' ' '='Python
Using Python:
def base64url_to_base64(b64url_str):
b64 = b64url_str.replace('-', '+').replace('_', '/')
pad = (4 - len(b64) % 4) % 4
return b64 + ('=' * pad)
token = "eyJzdWIiOiIxMjM0In0-w_1"
print("Standard Base64:", base64url_to_base64(token))Java
Using Java:
public class Base64UrlToBase64Example {
public static String toBase64(String base64Url) {
String base64 = base64Url.replace('-', '+').replace('_', '/');
int remainder = base64.length() % 4;
if (remainder == 2) base64 += "==";
else if (remainder == 3) base64 += "=";
return base64;
}
public static void main(String[] args) {
String urlSafe = "eyJzdWIiOiIxMjM0In0-w_1";
System.out.println(toBase64(urlSafe));
}
}