DEV Community

miccho27
miccho27

Posted on • Edited on • Originally published at rapidapi.com

Encode & Decode Base64 in One HTTP Call — Free API, No SDK Required (2026)

TL;DR: Get production-ready results in 1 HTTP call. No signup, no credit card, no rate limit.

👉 Try all 40+ Free APIs on RapidAPI

Free Base64 Encoder/Decoder API - Encode & Decode Data Instantly

Base64 encoding/decoding is common but varies by language and use case. You need URL-safe encoding, URL decoding, binary data handling, Unicode support, and validation. Libraries exist but require installation. What if you could encode/decode Base64 via REST API without dependencies?

The Base64 Encoder/Decoder API converts data to/from Base64 instantly: text encoding, URL-safe variants, decoding with validation, binary data support, padding options. Perfect for API payloads, data transmission, image embedding, authorization headers, and data obfuscation.

Why Use This API?

Base64 encoding matters:

  • API Payloads – Safely transmit binary data in JSON
  • Authorization – Encode credentials for Basic Auth
  • Data URLs – Embed images in HTML without separate files
  • Webhooks – Transmit data safely through untrusted channels
  • URL Parameters – Encode data for URL paths
  • Email Attachments – Encode files for MIME messages

Quick Example - cURL

# Encode text to Base64
curl -X POST "https://base64-api.p.rapidapi.com/encode" \
  -H "X-RapidAPI-Key: YOUR_KEY" \
  -H "X-RapidAPI-Host: base64-api.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{"data": "Hello, World!"}'
Enter fullscreen mode Exit fullscreen mode

Response:

{
  "success": true,
  "original": "Hello, World!",
  "encoded": "SGVsbG8sIFdvcmxkIQ==",
  "length": 16,
  "encoded_length": 24
}
Enter fullscreen mode Exit fullscreen mode

Python Example

import requests

url = "https://base64-api.p.rapidapi.com/encode"
headers = {
    "X-RapidAPI-Key": "YOUR_API_KEY",
    "X-RapidAPI-Host": "base64-api.p.rapidapi.com",
    "Content-Type": "application/json"
}

# Encode API credentials for Basic Auth
username = "user@example.com"
password = "secret123"

credentials = f"{username}:{password}"
payload = {"data": credentials, "url_safe": False}

response = requests.post(url, json=payload, headers=headers)
data = response.json()

auth_header = f"Basic {data['encoded']}"
print(f"Authorization header: {auth_header}")

# Use in API request
api_response = requests.get(
    "https://api.example.com/data",
    headers={"Authorization": auth_header}
)
Enter fullscreen mode Exit fullscreen mode

JavaScript / Node.js Example

const axios = require("axios");

const encodeBase64 = async (data, urlSafe = false) => {
  const response = await axios.post(
    "https://base64-api.p.rapidapi.com/encode",
    { data, url_safe: urlSafe },
    {
      headers: {
        "X-RapidAPI-Key": process.env.RAPIDAPI_KEY,
        "X-RapidAPI-Host": "base64-api.p.rapidapi.com"
      }
    }
  );

  return response.data.encoded;
};

const decodeBase64 = async (encoded) => {
  const response = await axios.post(
    "https://base64-api.p.rapidapi.com/decode",
    { data: encoded },
    {
      headers: {
        "X-RapidAPI-Key": process.env.RAPIDAPI_KEY,
        "X-RapidAPI-Host": "base64-api.p.rapidapi.com"
      }
    }
  );

  return response.data.decoded;
};

// Embed image as data URL
const embedImage = async (imagePath) => {
  const imageData = fs.readFileSync(imagePath, "base64");
  const encoded = await encodeBase64(imageData);

  const dataUrl = `data:image/png;base64,${encoded}`;

  return `<img src="${dataUrl}" alt="embedded">`;
};
Enter fullscreen mode Exit fullscreen mode

Encoding Variants

Variant Safe For Example
Standard JSON, HTML SGVsbG8=
URL-Safe URL parameters, filenames SGVsbG8 (replaces /+)
With Padding Compliance, compatibility SGVsbG8= (ends with =)
No Padding URL parameters SGVsbG8 (no trailing =)

Real-World Use Cases

1. HTTP Basic Authentication

Encode credentials for API requests.

def create_basic_auth_header(username, password):
    credentials = f"{username}:{password}"
    encoded = encode_base64(credentials)
    return f"Basic {encoded}"

# Use in headers
headers = {
    "Authorization": create_basic_auth_header("user", "pass")
}
Enter fullscreen mode Exit fullscreen mode

2. Embed Images in HTML

Convert images to Base64 for inline embedding.

def create_data_url(image_path):
    image_data = read_file_as_base64(image_path)
    return f"data:image/png;base64,{image_data}"

# Use in HTML
html = f'<img src="{create_data_url("logo.png")}" />'
Enter fullscreen mode Exit fullscreen mode

3. Encode API Payloads

Safely transmit binary data in JSON APIs.

def send_encrypted_payload(data, encryption_key):
    encrypted = encrypt(data, encryption_key)
    encoded = encode_base64(encrypted)

    api_payload = {
        "encrypted": encoded,
        "version": "1.0"
    }

    return requests.post("https://api.example.com/secure", json=api_payload)
Enter fullscreen mode Exit fullscreen mode

4. Decode Webhook Data

Receive and decode Base64-encoded webhook payloads.

def handle_webhook(webhook_data):
    # Webhook contains Base64-encoded content
    encoded_content = webhook_data["content"]

    decoded = decode_base64(encoded_content)

    # Process decoded data
    process_data(decoded)
Enter fullscreen mode Exit fullscreen mode

5. Obfuscate Configuration

Base64 encode config values (not for security, just obfuscation).

def obfuscate_config(config):
    obfuscated = {}
    for key, value in config.items():
        obfuscated[key] = encode_base64(str(value))

    return obfuscated
Enter fullscreen mode Exit fullscreen mode

6. JWT Token Handling

Encode payload for JWT creation.

def create_jwt_payload(user_id, claims):
    header = encode_base64(json.dumps({"alg": "HS256", "typ": "JWT"}))
    payload = encode_base64(json.dumps({"user_id": user_id, **claims}))

    signature = sign(f"{header}.{payload}", secret_key)

    return f"{header}.{payload}.{signature}"
Enter fullscreen mode Exit fullscreen mode

Size Comparison

Data Type Original Base64 Encoded Overhead
Text (100 bytes) 100 136 +36%
Binary (1KB) 1,024 1,368 +33%
Image (100KB) 102,400 136,533 +33%

Note: Base64 increases size by ~33% due to 4-char encoding of 3 bytes.

Pricing

Plan Cost Requests/Month Best For
Free $0 500 Testing, development
Pro $5.99 50,000 Production APIs
Ultra $14.99 500,000 High-volume encoding

Related APIs

  • JWT Decoder API – Decode and verify JWT tokens
  • String Utilities API – Pre/post-process strings
  • Hash Generator API – Hash encoded data
  • URL Shortener API – Encode data for URLs

Get Started Now

Encode/decode Base64 free on RapidAPI

No credit card. 500 free requests for encoding and decoding.


Using Base64 for data transmission? Share your use case in the comments!

Top comments (0)