What does the Base64 Encoder do?
The Base64 Encoder converts plain UTF-8 text strings and binary bytes into ASCII string representations using a standard 64-character alphabet (A-Z, a-z, 0-9, +, /). It also supports RFC 4648 URL-safe Base64 encoding (replacing + with - and / with _ while stripping trailing = padding) for query parameters and URL paths.
Core Concepts
Understanding Base64 encoding specifications:
- Radix-64 Encoding Scheme: Maps every 6 bits of binary data to one printable ASCII character, increasing total payload size by approximately 33%.
- URL-Safe Base64 (RFC 4648): Swaps
+and/characters for-and_, eliminating the need for URL percent-encoding in HTTP headers, cookies, and tokens. - Padding Syntax: Appends
=characters at the end of output strings to ensure total character count is a multiple of 4.
How to use the tool?
- Enter Plain Text: Paste your UTF-8 text into the input editor or click Sample.
- Select Encoding Mode: Optionally check URL-Safe Mode for web query parameters and URL paths.
- Live Encode & Copy: Encodes instantly in real time. Click Copy to copy the encoded string to your clipboard.
Related Developer Utilities
If you work with Base64 encoding, cryptographic tokens, and URL data, explore these complementary tools:
- Base64 Decoder: Decode standard and URL-safe Base64 strings back into UTF-8 text.
- Base64URL to Base64 Converter: Convert URL-safe Base64 strings to standard padded Base64.
- URL Encoder & Decoder: Percent-encode and decode URI strings.
- JWT Decoder: Parse and inspect JSON Web Token headers and claims.
REST API Integration
blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/base64/encoder) to programmatically encode UTF-8 plain text into standard or URL-safe Base64 strings.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
rawText |
String / Object | Plain UTF-8 text string or JS object to encode (aliases: text, payload, data, input, value). |
"Hello Blueutils!" |
isUrlSafe |
Boolean | Optional flag for URL-safe encoding (- and _, alias: urlSafe). Default: false. |
false |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/base64/encoder \
-H "Content-Type: application/json" \
-d '{
"rawText": "Hello Blueutils!",
"isUrlSafe": false
}'Python
import requests
url = "https://blueutils.com/api/base64/encoder"
payload = {
"rawText": "Hello Blueutils!",
"isUrlSafe": 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": "Hello Blueutils!",
"isUrlSafe": false
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/base64/encoder"))
.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 | Returns true if text was successfully encoded. |
true |
result |
String | Encoded Base64 output string. | "SGVsbG8gQmx1ZXV0aWxzIQ==" |
isUrlSafe |
Boolean | Confirms whether output uses URL-safe encoding. | false |
originalSize |
Number | Byte size of the original input string. | 16 |
encodedSize |
Number | Byte size of the generated Base64 output string. | 24 |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"result": "SGVsbG8gQmx1ZXV0aWxzIQ==",
"isUrlSafe": false,
"originalSize": 16,
"encodedSize": 24
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "Invalid input: Input text payload 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 encode Base64?
Integrating the Base64 Encoder API into automated ingestion scripts, API proxies, or AI agent tool calling provides key benefits:
- Rapid Script Validation: Embeds binary assets, basic authentication tokens, and webhook payloads into text-only transport layers.
- Optimized Token Efficiency for AI Agents: LLMs struggle with manual Base64 bitwise calculation and frequently corrupt padding. Invoking the API encodes strings accurately without hallucination.
- Deterministic Accuracy Without Hallucinations: Ensures 100% strict UTF-8 buffer encoding and RFC 4648 URL-safe substitution.
Native Usage
How to encode Base64 locally in terminal environments or scripts:
Windows (CMD / PowerShell)
# Encode Base64 in PowerShell
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("Hello Blueutils"))Linux / Unix (Bash)
# Encode Base64 in Linux
echo -n "Hello Blueutils" | base64Python
Using Python base64:
import base64
plain_text = "Hello Blueutils"
encoded = base64.b64encode(plain_text.encode("utf-8")).decode("utf-8")
print(encoded)Java
Using Java standard Base64:
import java.util.Base64;
import java.nio.charset.StandardCharsets;
public class Base64Example {
public static void main(String[] args) {
String original = "Hello Blueutils";
String encoded = Base64.getEncoder().encodeToString(original.getBytes(StandardCharsets.UTF_8));
System.out.println(encoded);
}
}