What does the Base64 to Base64URL Converter do?
The Base64 to Base64URL Converter transforms standard RFC 4648 Base64 strings containing +, /, and = characters into URL-safe Base64URL format (RFC 7515). It replaces + with -, / with _, and strips trailing = padding characters by default (or preserves them optionally).
Core Concepts
Understanding Base64 to Base64URL conversion mechanics:
- Alphabet Character Replacement: Replaces URI-reserved characters
+with-and/with_to prevent percent-encoding expansion in HTTP URLs and web query strings. - Padding Stripping: Removes trailing
=padding characters by default, following RFC 7515 specifications for JWT headers, claims, and signatures. - Input Validation: Detects existing Base64URL characters (
-or_) in input and flags non-Base64 illegal characters.
How to use the tool?
- Paste Standard Base64: Enter or paste your standard Base64 string into the input editor or click Sample.
- Configure Padding: Optionally check Preserve '=' Padding if your downstream parser requires trailing
=characters. - Live Convert & Copy: The tool converts instantly in real time. Click Copy or Download to export the URL-safe result.
Related Developer Utilities
If you work with Base64 encoding, URL formatting, and JWT tokens, explore these complementary tools:
- Base64URL to Base64 Converter: Add padding and convert URL-safe Base64 to standard Base64.
- Base64 Decoder: Decode Base64 payloads into UTF-8 text or JSON.
- Base64 Encoder: Encode plain text into Base64 or URL-safe Base64.
- URL Encoder & Decoder: Encode and decode URI query parameters.
REST API Integration
blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/base64/base64-to-base64url) to programmatically convert standard Base64 strings into URL-safe Base64URL strings.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
rawText |
String / Object | Standard Base64 string or object to convert (aliases: text, payload, data, input, value). |
"eyJzdWIiOiIxMjM0In0+w/1==" |
preservePadding |
Boolean | Optional flag to retain = padding. Default: false. |
false |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/base64/base64-to-base64url \
-H "Content-Type: application/json" \
-d '{
"rawText": "eyJzdWIiOiIxMjM0In0+w/1==",
"preservePadding": false
}'Python
import requests
url = "https://blueutils.com/api/base64/base64-to-base64url"
payload = {
"rawText": "eyJzdWIiOiIxMjM0In0+w/1==",
"preservePadding": False
}
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==",
"preservePadding": false
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/base64/base64-to-base64url"))
.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 URL-safe Base64URL string. | "eyJzdWIiOiIxMjM0In0-w_1" |
inputLength |
Number | Character length of input string. | 28 |
outputLength |
Number | Character length of output string. | 24 |
paddingRemoved |
Number | Count of = characters stripped. |
2 |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"inputLength": 28,
"outputLength": 24,
"paddingRemoved": 2,
"converted": "eyJzdWIiOiIxMjM0In0-w_1"
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "Invalid standard Base64: String contains Base64URL 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 Base64 to Base64URL?
Integrating the Base64 to Base64URL API into OAuth services, JWT signing pipelines, or AI agent tool calling provides essential advantages:
- Rapid Script Validation: Safely formats encrypted tokens for transmission within URL query parameters and HTTP redirection headers without percent-encoding bloat.
- Optimized Token Efficiency for AI Agents: LLMs often retain
=padding characters in URL-safe outputs. Calling the API normalizes strings deterministically without hallucination. - Deterministic Accuracy Without Hallucinations: Ensures 100% strict character mapping and configurable padding retention.
Native Usage
How to convert standard Base64 to Base64URL locally in terminal environments or scripts:
Windows (CMD / PowerShell)
# Convert Base64 to Base64URL in PowerShell
$b64 = "eyJzdWIiOiIxMjM0In0+w/1=="
$b64url = $b64.Replace('+', '-').Replace('/', '_').TrimEnd('=')
Write-Output "Base64URL: $b64url"Linux / Unix (Bash)
# Convert Base64 to Base64URL in Linux
echo -n "eyJzdWIiOiIxMjM0In0+w/1==" | tr '/+' '_-' | tr -d '='Python
Using Python:
def base64_to_base64url(b64_str, preserve_padding=False):
b64url = b64_str.replace('+', '-').replace('/', '_')
return b64url if preserve_padding else b64url.rstrip('=')
token = "eyJzdWIiOiIxMjM0In0+w/1=="
print("Base64URL:", base64_to_base64url(token))Java
Using Java:
public class Base64ToBase64UrlExample {
public static String toBase64Url(String base64, boolean preservePadding) {
String urlSafe = base64.replace('+', '-').replace('/', '_');
return preservePadding ? urlSafe : urlSafe.replaceAll("=+$", "");
}
public static void main(String[] args) {
String standard = "eyJzdWIiOiIxMjM0In0+w/1==";
System.out.println(toBase64Url(standard, false));
}
}