# Base64 Encoder & Decoder: Text, Files, Data URI (`ucchiii/base64-encoder-decoder`) Actor

Encode or decode Base64 in bulk from texts, file URLs or a dataset column. Standard and URL-safe, data URI creation and parsing with MIME detection. Decoded binary is saved to storage with a link. Failed items are free. Empty input = free demo.

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

## Pricing

from $0.70 / 1,000 conversions

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

**Base64 encode and decode in bulk: texts, files, data URIs**

**Returns Base64 (or the decoded text or file) for every text, file URL or dataset value you give it.** For anyone who has a list of things to convert and does not want to paste them into a web page one by one: image URLs that must become `data:` URIs for an HTML e-mail or a JSON payload, a column of Base64 strings from a scraper that must become readable text or real image files, tokens that need the URL-safe form. This Actor encodes and decodes **standard and URL-safe Base64**, **builds and takes apart data URIs** (the MIME type is detected), and for decoded binary it **saves the file to storage and gives you a link**. It works from the Console form, no code.

**Try it free: leave input empty and press Start** (clear the prefilled texts first; the demo is not charged and rows carry `_demo: true`).
**$1 per 1,000 conversions** ($0.001 each). One conversion = one text, one file or one dataset value. **Items that fail are free**, and so are runs with no result and the demo. The $5 monthly free credit covers about 5,000 conversions. No scraping, no API keys.

### Sample

Input `{"operation": "encode", "texts": ["Hello, world!", "<<???>>>"], "alphabet": "urlsafe", "padding": false}`:

| input | result | resultType | mime |
|---|---|---|---|
| Hello, world! | SGVsbG8sIHdvcmxkIQ | base64 | text/plain |
| <<???>>> | PDw_Pz8-Pj4 | base64 | text/plain |

Input `{"operation": "decode", "texts": ["SGVsbG8sIHdvcmxkIQ==", "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"]}`:

| input | result | resultType | mime | fileUrl |
|---|---|---|---|---|
| SGVsbG8sIHdvcmxkIQ== | Hello, world! | text | text/plain | |
| data:image/gif;base64,R0lGOD… | | file | image/gif | link to the saved .gif |

### What it does

- **Encode**: text (UTF-8, Shift_JIS, EUC-JP, Latin-1 or UTF-16) or the bytes of a file at a public URL. Standard or URL-safe alphabet, with or without `=` padding, optional line breaks every 64 or 76 characters.
- **Data URI maker**: `data:<type>;base64,...` for texts and files. The MIME type comes from the server's Content-Type, then from the file's first bytes (PNG, JPEG, GIF, WebP, PDF, ZIP, SVG and more), then from the file extension.
- **Decode**: standard and URL-safe at once; whitespace and line breaks are ignored and missing `=` are added. A `data:` URI is taken apart automatically: you get the MIME type and the charset it names.
- **Decoded result**: readable text is returned in the `result` column. Binary (images, PDFs, archives) is saved to the key-value store and the row has `fileKey` and a `fileUrl` download link. Choose *always text* or *always a file* if you want to force one.
- **Dataset columns**: pick an Apify dataset and the columns to convert (dot paths such as `image.base64`); every value becomes one row. Copy other columns (for example `id`) onto the result rows to match them back. Tick *values are file URLs* to download and encode the files a column points to.
- **Long results** (default over 256 KB) go to the key-value store as a text file instead of a table cell, so the dataset stays small.

### Input example

```json
{
  "operation": "encode",
  "fileUrls": ["https://example.com/logo.png"],
  "makeDataUri": true
}
```

Decode a column of a dataset: `{"operation": "decode", "datasetIds": ["<id>"], "datasetFields": ["imageBase64"], "keepFields": ["id"]}`.

### Output

- **Dataset**: one row per item with `status`, `operation`, `source` (text, file or dataset), `input` (a short preview, or the file URL), `result`, `resultType` (`base64`, `data-uri`, `text` or `file`), `mime`, `inputBytes`, `outputBytes`, `fileKey`, `fileUrl`, `error`; dataset rows also carry `datasetId`, `rowIndex` and `field`.
- **STATS** record (key-value store): items processed, converted, failed, skipped empty values, conversions charged, whether the run stopped at a limit, bytes downloaded.

### Rules worth knowing

- Decoding needs valid Base64: a row with an impossible character or length gets `status: error` and a plain explanation, and is not charged.
- A decoded file whose type is unknown is saved as `.bin`. The `mime` column says what was detected.
- Decoding a file URL expects a **text** file that contains Base64 or a data URI; a binary file there is reported as an error.
- Empty or missing dataset values are skipped (counted in STATS), not charged.

### Limits (cannot be raised past these by input)

- Files: **10 MB each by default** (set up to 50 MB), 200 MB downloaded per run, 500 file URLs per run, 30 seconds timeout per attempt by default, up to 4 retries only for timeouts, 429 and 5xx answers.
- Files are fetched **one at a time with a pause of at least 0.5 s between requests to the same host**; redirects are followed up to 5 times. Only public `http` and `https` links; addresses on internal networks (localhost, private ranges, cloud metadata) are blocked, also after redirects.
- 100,000 items per run (default 1,000), set by *Max items*.

### Pricing

Pay per event: **$1 per 1,000 conversions** (event `conversion`, $0.001 each): 2,500 conversions cost $2.50. Failed items, values that cannot be read and the demo are free. Set a maximum charge per run: the Actor then stops at that budget (never past it) and says so in the run summary.
On the Apify Free plan, the $5 of monthly platform credit covers about **5,000 conversions** a month.

### Use cases

- Turn image URLs into data URIs for HTML e-mails, CSS, SVG or JSON files
- Turn a scraper column of Base64 images or documents back into real files with download links
- Decode a list of Base64 strings (config values, API payloads, e-mail attachments) to readable text
- Produce URL-safe, unpadded Base64 for tokens, links and file names
- Inspect a data URI: its type, charset and size

### FAQ

**Is it the same as a Base64 web page?** The conversion is the same standard (RFC 4648, with data URIs as in RFC 2397). What you get here is a list at once, files by URL, dataset columns and saved files with links.
**Is Base64 encryption?** No. Anyone can decode it. Do not use it to hide secrets.
**Why was my decoded text turned into a file?** Its bytes were not readable text in the chosen character set (or looked like an image or archive). Pick the right *Text character set*, or *Always text*.
**Does it change my source dataset?** No. It only reads it and writes a new dataset.

If this Actor saved you time, a rating on the Store helps others find it.

### More tools from the same developer

- [Bulk File Downloader](https://apify.com/ucchiii/bulk-file-downloader) — download files from URL lists or dataset fields into storage, with links, SHA-256 and an optional ZIP
- [Image Converter](https://apify.com/ucchiii/image-converter) — convert images between JPG, PNG, WebP and AVIF, with optional resize
- [JSON to CSV Converter](https://apify.com/ucchiii/json-to-csv) — turn nested JSON files or datasets into one flat CSV file
- [Dataset Transform](https://apify.com/ucchiii/dataset-transform) — flatten, filter, rename and convert any Apify dataset, export CSV / JSON / JSONL with a link
- [HTML to Markdown Converter for LLM and RAG](https://apify.com/ucchiii/html-to-markdown) — clean Markdown from URLs, raw HTML or datasets for LLM and RAG

# Actor input Schema

## `operation` (type: `string`):

Encode turns text or a file into Base64 (or a data URI). Decode turns Base64 or a data URI back into text, or into a stored file when the content is binary. Default: encode.

## `texts` (type: `array`):

The texts to convert, one per line. When decoding, each line is Base64 or a full data URI. Clear this list, the file URLs and the datasets to run the free demo.

## `fileUrls` (type: `array`):

Public http(s) links to files (up to 500 per run). Encode: the file itself is encoded, so images, PDFs and fonts work. Decode: the file must be text that contains Base64 or a data URI. Links to internal networks are blocked.

## `datasetIds` (type: `array`):

Datasets whose columns you want to convert (the 'defaultDatasetId' of a finished run). You can paste a dataset URL from Apify Console too. Needs 'Dataset columns to convert'. The source dataset is never changed.

## `datasetFields` (type: `array`):

Dataset only. Names of the columns to convert, such as 'title' or 'image.base64'. Dot paths reach into nested objects. Each value becomes one output row (and one charged conversion); empty values are skipped.

## `keepFields` (type: `array`):

Dataset only. Columns copied unchanged onto every output row so you can match results back to the source, for example 'id' or 'url'. Dot paths work.

## `valuesAreUrls` (type: `boolean`):

Dataset only. Treat each value in the chosen columns as a file URL to download and convert, instead of as text. Subject to the same size limit and pause per host.

## `alphabet` (type: `string`):

Encode only. URL-safe replaces + and / with - and \_ so the result can sit in a URL or file name. Decoding always accepts both. Default: standard.

## `padding` (type: `boolean`):

Encode only. Keep the trailing = characters. Turn off for the short form used in JWTs and URLs. Decoding works with or without padding. Default: on.

## `lineWrap` (type: `string`):

Encode only, plain Base64 (not data URIs). Insert a line break after this many characters. Default: none.

## `makeDataUri` (type: `boolean`):

Encode only. Return 'data:<type>;base64,...' instead of bare Base64. The MIME type comes from the server, the file content or the file extension; texts get text/plain. The type is also in the 'mime' column.

## `textEncoding` (type: `string`):

How text is turned into bytes when encoding, and bytes into text when decoding (a charset named inside a data URI wins). Files are always encoded byte for byte. Default: UTF-8.

## `decodeAs` (type: `string`):

Decode only. Automatic returns text when the bytes are readable text and saves everything else (images, PDFs, archives) to the key-value store with a download link. Default: automatic.

## `maxInlineKb` (type: `integer`):

A result longer than this is not put in the table cell but saved as a text file in the key-value store (see 'fileUrl'). Keeps the dataset small. Default: 256.

## `maxItems` (type: `integer`):

Stop after this many items (texts, files and dataset values together). Caps run time and cost ($1 per 1,000 conversions). When it stops early, 'truncated' is true in the run summary. Default: 1,000.

## `maxFileSizeMb` (type: `number`):

Largest file that is downloaded. Bigger files are skipped with an error and are free. One run downloads at most 200 MB in total. Default: 10.

## `timeoutSecs` (type: `integer`):

How long to wait for a server before giving up on one attempt. Default: 30.

## `retries` (type: `integer`):

Extra attempts when a server times out or answers 429 or 5xx, with a growing pause. Other errors (404, 403) are not retried. Default: 2.

## `delayPerHostSecs` (type: `number`):

Minimum pause between two downloads from the same host. Files are fetched one at a time. Default: 0.5.

## Actor input object example

```json
{
  "operation": "encode",
  "texts": [
    "Hello, world!",
    "Base64 makes bytes safe for text."
  ],
  "valuesAreUrls": false,
  "alphabet": "standard",
  "padding": true,
  "lineWrap": "0",
  "makeDataUri": false,
  "textEncoding": "utf-8",
  "decodeAs": "auto",
  "maxInlineKb": 256,
  "maxItems": 1000,
  "maxFileSizeMb": 10,
  "timeoutSecs": 30,
  "retries": 2,
  "delayPerHostSecs": 0.5
}
```

# Actor output Schema

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

One row per converted text, file or dataset value: the Base64 or decoded text, the type, the MIME type, sizes and, for files, a download link. Download as CSV, JSON, Excel and more.

## `stats` (type: `string`):

Record STATS: items processed, converted and failed, units charged, whether the run stopped at a limit and the bytes downloaded.

## `files` (type: `string`):

The key-value store that holds decoded binary files and results too long for a table cell.

# 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 = {
    "texts": [
        "Hello, world!",
        "Base64 makes bytes safe for text."
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ucchiii/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 = { "texts": [
        "Hello, world!",
        "Base64 makes bytes safe for text.",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("ucchiii/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 '{
  "texts": [
    "Hello, world!",
    "Base64 makes bytes safe for text."
  ]
}' |
apify call ucchiii/base64-encoder-decoder --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ucchiii/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/xWNGGHMX57iB2DPg4/builds/i89EPiktDoFr6RKRE/openapi.json
