# Base64 Encoder & Decoder API — Text & Data URIs (`seemuapps/base64-encoder-decoder`) Actor

Batch encode text to Base64 or decode Base64 back to text, with URL-safe and data URI output modes, in one API call.

- **URL**: https://apify.com/seemuapps/base64-encoder-decoder.md
- **Developed by:** [Andrew](https://apify.com/seemuapps) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 item processeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Base64 Encoder & Decoder API — Text & Data URIs

Batch-encode text to Base64 or decode Base64 back to text — with URL-safe alphabet and data URI support — in a single API call.

### What you get

- Encode or decode any number of strings in one run
- Standard or URL-safe Base64 alphabet (`+`/`/` vs `-`/`_`, with or without padding)
- Wrap encoded output as a data URI (`data:<mime>;base64,...`) with one input field
- Automatic `data:...;base64,` prefix stripping when decoding
- Per-item validation — invalid Base64 input is reported with a clear error instead of silently returning garbage

### Use cases

- Batch-convert a list of strings or tokens to/from Base64 inside a no-code automation (Zapier/Make/n8n via the Apify API)
- Generate data URIs for small assets to embed directly in HTML/CSS/JSON
- Validate whether a field from an upstream system is genuinely Base64-encoded

### How to use

1. Choose **Mode**: Encode or Decode
2. Paste your strings into **Inputs** (one per line)
3. Optionally turn on **URL-safe alphabet**, or set **Wrap encode output as data URI** to a MIME type like `image/png`
4. Run the actor — results appear in the **Dataset** tab

### Output format

Each dataset record:

```json
{
  "mode": "encode",
  "input": "Hello, world!",
  "output": "SGVsbG8sIHdvcmxkIQ==",
  "byteLength": 13,
  "error": null
}
```

If an input isn't valid Base64 in decode mode, `output` is `null` and `error` explains why — the record is still returned so a downstream automation can count/handle failures without dropping items.

# Actor input Schema

## `mode` (type: `string`):

Encode plain text to Base64, or decode Base64 back to text.

## `inputs` (type: `array`):

One string per line to encode or decode. For decode mode, a leading 'data:<mime>;base64,' prefix is stripped automatically.

## `urlSafe` (type: `boolean`):

Use the URL-safe Base64 alphabet (- and \_ instead of + and /, no padding) for encode output, or accept it for decode input.

## `dataUriMimeType` (type: `string`):

Encode mode only. If set, e.g. 'image/png' or 'text/plain', wraps each output as 'data:<mime>;base64,<data>' instead of raw Base64.

## Actor input object example

```json
{
  "mode": "encode",
  "inputs": [
    "Hello, world!"
  ],
  "urlSafe": false
}
```

# Actor output Schema

## `results` (type: `string`):

One record per input. Fields: mode, input, output, byteLength, error.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "inputs": [
        "Hello, world!"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("seemuapps/base64-encoder-decoder").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "inputs": ["Hello, world!"] }

# Run the Actor and wait for it to finish
run = client.actor("seemuapps/base64-encoder-decoder").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "inputs": [
    "Hello, world!"
  ]
}' |
apify call seemuapps/base64-encoder-decoder --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,seemuapps/base64-encoder-decoder"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/la2S5bhfZm4mTJR74/builds/bGZX8iHDJbZNY8kev/openapi.json
