# Base64 Encoder & Decoder — Text, Files, Images to Data URI (`steadyscrape/base64-encoder-decoder`) Actor

Base64 encode and decode text, files, image links and key-value store records: Base64, base64url and data URIs with the MIME type found from the bytes, size and SHA-256. Decode Base64 or data URIs back to text or a file with a link. Export to JSON, CSV or Excel, or via API.

- **URL**: https://apify.com/steadyscrape/base64-encoder-decoder.md
- **Developed by:** [Steady Scrape](https://apify.com/steadyscrape) (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 $1.00 / 1,000 text encoded or decodeds

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/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 Encoder & Decoder — Text, Files, Images to Data URI

**Base64 Encoder & Decoder** turns texts, files, image links and key-value store records into **Base64**,
**base64url** and ready **data URIs**, with the **MIME type found from the file's own bytes**, its size and its
**SHA-256** — and decodes Base64, base64url or data URIs back to **text** or to a **file with a download link**. One
dataset row per item, so it fits an API call, an n8n, Make or Zapier step, or an AI agent's tool. Invalid input is a
free row that says what is wrong. Export to JSON, CSV or Excel, or call it via API.

### What this Base64 encoder and decoder does

- **Encode text to Base64** as UTF-8 (emoji and accents included). A JSON, HTML or SVG text gets its own type in the
  data URI (`data:image/svg+xml;base64,…` is ready for CSS).
- **Encode files and images to Base64** from links: images, PDFs, Office documents, audio, video, fonts, archives.
  Google Drive, Dropbox and GitHub share links are read as the file they share. Upload files in the form, or pick a
  key-value store and encode its records (screenshots, downloads, exports from other Actors).
- **MIME type from the bytes**: PNG, JPEG, GIF, WebP, AVIF, HEIC, SVG, PDF, DOCX, XLSX, PPTX, OpenDocument, EPUB, ZIP,
  MP3, MP4, WebM, WOFF2 and more are recognised by their signature, so a file served as `application/octet-stream`
  still gets `data:image/png;base64,…`. The row says where the type came from (`bytes`, `content-type`, `file-name`).
- **Three outputs**: standard Base64 (RFC 4648, padded), **base64url** (URL-safe, no padding: JWTs, URLs, file names)
  and **data URI**. Optional **MIME line wrapping** at 76 characters (email, RFC 2045) or 64 (PEM).
- **Decode Base64 to text or to a file**: standard or URL-safe, padded or not, line breaks ignored; data URIs
  (Base64 or percent-encoded, with their charset and `name=`); PEM blocks. Auto mode gives text for text and a file for
  images, PDFs and other binaries; decoded files are saved with a link that opens without a login.
- **Size and SHA-256** of every file and text, to check integrity or deduplicate.
- **Large outputs are never cut**: when a row would pass the dataset's 9 MB limit, each output is saved whole in the
  run's key-value store and linked from the row.
- **Invalid input is free**: a value that is not Base64 says which character is wrong and where; a dead link, a
  private address or an empty file is a row with its reason, and the run goes on.

### Use cases

- **Image to Base64 for LLM vision APIs** (OpenAI, Claude, Gemini): give image links, get data URIs to paste into a
  request.
- **Embed images and fonts in HTML, CSS and emails**: data URIs for inline images, icons, SVG backgrounds and fonts;
  MIME-wrapped Base64 for email attachments.
- **File to Base64 for APIs** that take attachments as Base64 strings (email senders, e-signature, document and OCR
  APIs, webhooks).
- **Decode Base64 attachments** received from an API or a webhook back to a PDF, an image or a text, with a link.
- **Automation steps**: an n8n, Make or Zapier flow, or an MCP agent, that needs Base64 in or out without code.
- **Chain other Actors**: encode the screenshots, images or downloads another Actor left in a key-value store.

### How to encode or decode Base64

1. To encode, write a **Text**, add **File or image links**, upload files, or **pick a key-value store**.
2. To decode, paste a **Base64 value or data URI** (or many). Choose **Decode to**: Auto, text, or a file.
3. Choose the **Encoded output** (Base64, base64url, data URI) and, for email, a **line length** of 76.
4. Run it. Each item is a dataset row; decoded files and large outputs have their links in the row.

#### Input example

```json
{
    "text": "Hello, World! 👋",
    "fileUrls": ["https://www.w3.org/Icons/w3c_home.png"],
    "base64Inputs": ["SGVsbG8sIFdvcmxkIQ==", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="],
    "outputFormats": ["base64", "dataUri"],
    "decodeTo": "auto"
}
```

### Output: Base64, data URI, decoded text or file link

An encoded image:

```json
{
    "item": 2,
    "operation": "encode",
    "inputType": "link",
    "input": "https://www.w3.org/Icons/w3c_home.png",
    "status": "ok",
    "fileName": "w3c-72x48.png",
    "mimeType": "image/png",
    "mimeTypeFrom": "bytes",
    "extension": "png",
    "sizeBytes": 1848,
    "sha256": "590608bf256237f22d84bbab2a0a1afc0d4f20db6350bbac2c6841f1f3e13b01",
    "base64": "iVBORw0KGgoAAAANSUhEUgAAAEgAAAAw…",
    "dataUri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAAAw…",
    "base64Length": 2464
}
```

A decoded text, and a decoded file:

```json
{ "item": 4, "operation": "decode", "inputType": "base64", "status": "ok", "text": "Hello, World!", "mimeType": "text/plain", "sizeBytes": 13 }
{ "item": 5, "operation": "decode", "inputType": "dataUri", "status": "ok", "mimeType": "image/png", "sizeBytes": 70, "fileKey": "decoded-005.png", "fileUrl": "https://api.apify.com/v2/key-value-stores/…/records/decoded-005.png?signature=…" }
```

A value that is not Base64 (free):

```json
{ "item": 6, "operation": "decode", "status": "invalid", "reason": "the character \"!\" at position 8 is not Base64 (A–Z, a–z, 0–9, + and /, or - and _ for base64url, = only at the end)" }
```

#### Fields

| Field | What it holds |
|---|---|
| `item` | The item's place in the run: texts, then links, store records, values to decode |
| `operation` | `encode` or `decode` |
| `inputType` | `text`, `link`, `record`, `base64` or `dataUri` |
| `input` | The text, the link (tokens masked), the record, or the start of the value decoded |
| `status` / `reason` | `ok`, or `invalid`, `unreadable`, `too_large` with the reason (free rows) |
| `fileName`, `mimeType`, `mimeTypeFrom`, `extension` | The file's name and type, and where the type came from |
| `sizeBytes`, `sha256` | Size and SHA-256 of the raw bytes |
| `base64`, `base64url`, `dataUri` | The encodings asked for |
| `base64Length` | Length of the padded Base64, also when it is in the store |
| `text` | The decoded text |
| `fileKey`, `fileUrl` | A decoded file (or a long decoded text) in the run's key-value store, with a link that opens for anyone |
| `outputLinks` | Encodings too large for a row, each saved whole as a text record with its link |
| `outputBytes`, `extraOutputUnits` | Bytes of output, and the started 10 MB past the first 20 MB that were charged |

The run's `SUMMARY` record counts what was encoded and decoded and lists every problem.

### Pricing

Pay per event, nothing else: **US$0.001 per text** encoded or decoded, **US$0.002 per file** (a link, an upload or a
store record encoded, or a Base64 value decoded to a file). Each includes the first 20 MB of output; a very large file
adds **US$0.001 per further started 10 MB** of output (a 7.5 MB file with Base64 and data URI never does, a 25 MB one
adds US$0.005). Invalid values, dead links, empty files and anything not converted are free. A run stops cleanly at
your spending limit, before an item it could not pay for.

### Limits

- Files up to 200 MB each (25 MB by default, set **Most megabytes per file**).
- A dataset row holds at most 8 MB of outputs; above that, the outputs are linked from the row (set **Most megabytes
  in a dataset row** lower to always get links, 0 for links only).
- Links must be public: a private address, a sign-in page or a link that needs a login is a free row with its reason.
  Video and music platforms' pages are pages, not files: link to a file itself.
- Up to 1,000 records from one key-value store per run when no record is named.

### Is it legal?

It converts what you give it and reads only the links you name, as one download each, like a browser would. Encode
only files you have the right to use. No site is scraped and no personal data is collected.

This Actor is not affiliated with, endorsed by or sponsored by any service named on this page (Google Drive, Dropbox,
GitHub, W3C, OpenAI, Anthropic, Google Gemini, n8n, Make or Zapier); their names only say where a file or a result can
come from or go.

# Actor input Schema

## `text` (type: `string`):

One text to encode to Base64 (as UTF-8). It may span several lines, and JSON, HTML or SVG get their own type in the data URI.

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

Many texts at once, one dataset row each. Through the API, any string works, line breaks included.

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

Links to any file: images, PDFs, documents, audio, fonts, archives. Google Drive, Dropbox and GitHub share links are read as the file they share. Each gives its Base64, a data URI with the MIME type found from the file's own bytes, its size and its SHA-256.

## `uploadedFiles` (type: `array`):

Files from your computer, encoded the same way as the links above.

## `keyValueStore` (type: `string`):

Pick a key-value store whose records are files (another Actor's screenshots, downloads or exports). Picking it here is what lets this run read it.

## `recordKeys` (type: `array`):

The keys of the records to encode. Leave empty to encode every record of the store (up to 1,000; its INPUT record is left out).

## `base64` (type: `string`):

One Base64 value (standard or URL-safe, padded or not, line breaks ignored), a data URI (data:image/png;base64,…) or a PEM block, decoded back to text or to a file.

## `base64Inputs` (type: `array`):

Many values at once, one dataset row each. A value that is not valid Base64 is a free row saying which character is wrong and where.

## `decodeTo` (type: `string`):

Auto: text when the bytes are text (plain text, JSON, HTML, CSV…), a file otherwise (images, PDFs, archives…). A file is saved in the run's key-value store with a link that opens without a login.

## `outputFormats` (type: `array`):

Base64 (RFC 4648, padded), base64url (URL-safe, no padding: JWTs, URLs, file names) and data URI (data:<MIME type>;base64,…, ready for HTML, CSS, JSON, emails and LLM vision APIs). Choose one or more.

## `lineLength` (type: `integer`):

0 keeps the Base64 on one line. 76 gives MIME lines for email (RFC 2045), 64 the lines of PEM. Lines end in CRLF. Only the Base64 output is wrapped; base64url and data URIs stay on one line.

## `maxInlineMegabytes` (type: `integer`):

A row whose outputs would pass this size gets them as links instead: each output is saved whole in the run's key-value store as a text record (outputLinks), and a decoded text as a file (fileUrl). Apify allows at most 9 MB per dataset row; 0 always gives links.

## `maxFileMegabytes` (type: `integer`):

A bigger file is a free too_large row and is not downloaded whole.

## Actor input object example

```json
{
  "text": "Hello, World! 👋",
  "fileUrls": [
    "https://www.w3.org/Icons/w3c_home.png"
  ],
  "base64Inputs": [
    "SGVsbG8sIFdvcmxkIQ==",
    "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
  ],
  "decodeTo": "auto",
  "outputFormats": [
    "base64",
    "dataUri"
  ],
  "lineLength": 0,
  "maxInlineMegabytes": 8,
  "maxFileMegabytes": 25
}
```

# Actor output Schema

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

No description

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

No description

## `summary` (type: `string`):

No description

# 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 = {
    "text": "Hello, World! 👋",
    "fileUrls": [
        "https://www.w3.org/Icons/w3c_home.png"
    ],
    "base64Inputs": [
        "SGVsbG8sIFdvcmxkIQ==",
        "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("steadyscrape/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 = {
    "text": "Hello, World! 👋",
    "fileUrls": ["https://www.w3.org/Icons/w3c_home.png"],
    "base64Inputs": [
        "SGVsbG8sIFdvcmxkIQ==",
        "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("steadyscrape/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 '{
  "text": "Hello, World! 👋",
  "fileUrls": [
    "https://www.w3.org/Icons/w3c_home.png"
  ],
  "base64Inputs": [
    "SGVsbG8sIFdvcmxkIQ==",
    "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
  ]
}' |
apify call steadyscrape/base64-encoder-decoder --silent --output-dataset

```

## MCP server setup

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