Base64 Encoder & Decoder API — Files, Text & Data URIs avatar

Base64 Encoder & Decoder API — Files, Text & Data URIs

Pricing

Pay per event

Go to Apify Store
Base64 Encoder & Decoder API — Files, Text & Data URIs

Base64 Encoder & Decoder API — Files, Text & Data URIs

Encode text or file URLs to Base64 and data URIs, or decode Base64 to text and downloadable files. Batch and base64url support. Free-plan rates: $0.001 per text item, $0.002 per file; Store discounts available. Failed items are not charged.

Pricing

Pay per event

Rating

0.0

(0)

Developer

Broke to Built

Broke to Built

Maintained by Community

Actor stats

0

Bookmarked

66

Total users

50

Monthly active users

4 days ago

Last modified

Share

Base64 Encoder & Decoder — Text, Files & Data URIs

Give it text or a file URL, get Base64 plus a ready-to-paste data: URI back — or give it Base64 and get the text or the original file back. Batch input, strict validation, URL-safe alphabet, and per-item billing where failed items are never charged.

Who this is for

  • Developers who need an image, PDF, or any file as a Base64 string inside a JSON payload, an email, or a config file — without writing the fetch-and-encode glue.
  • Front-end and email builders turning image URLs into data: URIs to inline into HTML, CSS url(), or email templates.
  • API integrators whose upstream sends Base64 blobs (webhook payloads, attachments, JWT segments) and who need the decoded text or file back out.
  • Automation builders (Make, Zapier, n8n) who need encode/decode as one hosted step between two other apps.
  • AI agents that receive or must produce Base64 mid-task, via API or Apify MCP.

What you get

One dataset row per item. Fields, exactly as the actor emits them:

FieldWhenMeaning
modealwaysencode or decode
processedAtalwaysISO timestamp for that item
base64encodeThe Base64 string (standard or base64url if urlSafe)
dataUriencode, fileComplete data:<mime>;base64,... — paste straight into <img src> or CSS
contentTypeencode, fileMIME from the server's header, or sniffed from magic bytes
inputBytesencodeSize of the source text/file in bytes
alphabetencodestandard or base64url
urlencode, fileThe file URL you supplied
base64Key / base64Urlencode, huge filesSet instead of base64 when the result exceeds ~3 MB; the payload goes to the key-value store
textdecodeDecoded content, when the bytes are valid UTF-8
textKey / textUrldecode, long textComplete decoded text in the run key-value store, with a signed download URL
textTruncatedInline / textCharactersdecode, long texttrue when text is a preview; length of the complete decoded text
kinddecodetext or file
decodedBytesdecodeByte length of the decoded payload
declaredMimedecodeMIME declared inside a data: URI, if there was one
fileKey / downloadUrldecode, binaryKey-value store key and a signed, shareable download URL
errorany failurePlain-language reason. The row is stored; this item is never charged

Examples

All three outputs below are copied from real runs of this actor, only the long Base64 bodies are trimmed.

1. Encode a file URL to a data URI

Input:

{ "mode": "encode", "fileUrls": ["https://apify.com/favicon.ico"] }

Output row:

{
"mode": "encode",
"url": "https://apify.com/favicon.ico",
"contentType": "image/x-icon",
"inputBytes": 15086,
"alphabet": "standard",
"base64": "AAABAAMAMDAAAAEAIACoJQAANgAAACAgAAABACAA...",
"dataUri": "data:image/x-icon;base64,AAABAAMAMDAAAAEAIACoJQAANgAAACAgAAABACAA...",
"processedAt": "2026-08-15T16:09:30.845Z"
}

2. Decode a batch, including a data: URI

Input:

{ "mode": "decode", "text": "", "items": ["SGVsbG8sIHdvcmxkIQ==", "data:text/plain;base64,QnJva2UgdG8gQnVpbHQ="] }

Output rows:

[
{ "mode": "decode", "kind": "text", "text": "Hello, world!", "decodedBytes": 13, "declaredMime": null, "processedAt": "2026-08-15T16:09:12.694Z" },
{ "mode": "decode", "kind": "text", "text": "Broke to Built", "decodedBytes": 14, "declaredMime": "text/plain", "processedAt": "2026-08-15T16:09:12.746Z" }
]

3. Invalid Base64 is reported, not silently mangled

Input:

{ "mode": "decode", "text": "", "items": ["not-valid-base64!!"] }

Output row (recorded, not charged):

{
"mode": "decode",
"input": "not-valid-base64!!",
"error": "Not valid Base64 (after accepting url-safe alphabet, whitespace and data: URIs).",
"processedAt": "2026-08-15T16:09:12.799Z"
}

A plain Buffer.from(s, 'base64') would have returned garbage bytes here without complaining. This actor validates first.

Input

FieldTypeDefaultNotes
modeencode | decodeencode
textstringsample textOne text to encode, or a Base64 string / data URI to decode
itemsstring[][]Batch — one dataset row per item
fileUrlsstring[][]Encode mode: public files to download & encode
urlSafebooleanfalseOutput base64url (-/_, no padding). Decode accepts both alphabets always
decodeToFilebooleanfalseDecode mode: always store the decoded bytes as a downloadable file
maxFileSizeMbinteger25Skip downloads larger than this (recorded, unbilled)

One gotcha worth 10 seconds: text ships with a demo string prefilled. In decode mode, clear it (or overwrite it with your own Base64) or you get one extra "not valid Base64" row from the leftover demo text. That row is free, but it is noise in your dataset.

Call it from code

curl — synchronous run, results straight back:

curl -X POST "https://api.apify.com/v2/acts/eliai~base64-encoder-decoder/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"mode":"encode","fileUrls":["https://example.com/logo.png"]}'

Python (pip install apify-client):

from apify_client import ApifyClient
from urllib.request import urlopen
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("eliai/base64-encoder-decoder").call(
run_input={"mode": "decode", "text": "", "items": ["SGVsbG8gd29ybGQ=", "bm90IHNlY3JldA=="]}
)
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
if row.get("error"):
print(row["error"])
elif row.get("textTruncatedInline"):
# The inline text is only a preview. Retrieve the complete decoded document.
with urlopen(row["textUrl"], timeout=30) as response:
print(response.read().decode("utf-8"))
elif row.get("kind") == "text":
print(row.get("text", ""))
else:
print(row.get("downloadUrl", ""))

Node.js (npm install apify-client):

import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('eliai/base64-encoder-decoder').call({
mode: 'encode',
fileUrls: ['https://example.com/logo.png'],
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items[0].dataUri); // ready for <img src="...">

Automate it

Everything the Apify platform offers works here with zero extra code: schedule recurring runs, fire a webhook when a run finishes, or drop it into Make, Zapier, or n8n with the standard Apify app — pass the JSON input above and use the dataset rows downstream. Agents can call it directly over Apify MCP.

Pricing

One successful item produces one charge event. These are the current rates, checked September 5, 2026.

Apify planText item (text-converted)File item (file-converted)
Free$0.001$0.002
Bronze$0.00093$0.00186
Silver$0.00087$0.00174
Gold$0.0008$0.0016
Platinum$0.00073$0.00146
Diamond$0.00067$0.00134

At Free-plan rates, 1,000 text conversions cost $1.00 and 1,000 file conversions cost $2.00. A text item is one string encoded or decoded to text. A file item is one remote file encoded or one decoded payload stored as a file. Long decoded text keeps the text event even when its full content is delivered through a download link.

Failed items return an error record and are not charged. There is no Actor subscription or start event. Check the Store Pricing tab for your account's current tier.

For code already running in Python or Node.js, the standard Base64 library may be sufficient. This Actor provides a hosted batch step, URL downloads, validation, and stored outputs for automation workflows.

When NOT to use this

  • You are already in a script or notebook. base64.b64encode(open(f,'rb').read()) is free and instant. Use this when you need it as a hosted step, not as a library.
  • The file is behind a login, a paywall, or a private network. This actor only fetches public URLs you hand it — no cookies, no auth headers, no crawling.
  • You want encryption. Base64 is encoding, not security. Anyone can decode it. If you need secrecy, encrypt first and Base64 the ciphertext.
  • You need to encode a file you have locally but not online. There is no file upload — the input is a URL. Host the file somewhere reachable first.
  • You need Base64 of a whole website or of a crawl. This does not crawl; it processes the exact URLs and strings you list.

Honest limits

  • File downloads are capped at maxFileSizeMb (default 25 MB, hard max 100 MB) with a 60-second timeout per file.
  • Content-type detection covers common formats by magic bytes (PNG, JPEG, GIF, WebP, PDF, ZIP, XML); unknown binaries are labelled application/octet-stream — the bytes are always exact, only the label can be generic.
  • Base64 results over ~3 MB are moved to the key-value store; the dataset row then carries base64Url instead of base64.
  • Decoded text over 100,000 characters has a preview in text and the complete original bytes at textUrl. It remains one text conversion, with no extra file event.
  • fileUrls applies to encode mode only. To decode a file, pass its Base64, not its URL.

FAQ

How do I convert an image URL to a Base64 data URI? Encode mode with the URL in fileUrls. The result row includes the raw Base64 and a complete data:<mime>;base64,... URI ready for an <img src>, a CSS url(), a JSON payload, or an email template.

How do I decode a Base64 string back to a file? Decode mode. Valid UTF-8 payloads come back as plain text; above 100,000 characters, text is a preview and textUrl downloads the complete content. Binary payloads are written to the key-value store with the content type detected from magic bytes, and the row carries a signed downloadUrl. Set decodeToFile: true to force file output even for text.

What is URL-safe Base64 and when do I need it? The RFC 4648 §5 alphabet: - and _ instead of + and /, with padding stripped. It is required inside URLs, JWTs, and filenames. Set urlSafe: true when encoding; decoding accepts both alphabets automatically, so you can paste a JWT segment straight in.

Can I decode a JWT with this? You can decode each dot-separated segment — paste a segment into items and you get the header or payload JSON back as text. It does not verify the signature, so never trust a decoded JWT as proof of anything.

What happens with invalid Base64 input? It is validated before decoding and returned as an error row — recorded, never charged, and never the silently corrupted bytes a bare Buffer.from(s, 'base64') hands you.

Is there a size limit for files? maxFileSizeMb caps each download (default 25 MB, max 100 MB, 60 s each). Encoded results over ~3 MB move to the key-value store with a download URL, so dataset row limits never truncate your data.

Can I process many items in one run? Yes. Put texts or Base64 strings in items and file URLs in fileUrls — mix both in one encode run if you like. Each produces its own dataset row, and one bad item never stops the rest.

Does Base64 make my data secure? No. It is a reversible encoding designed to move binary data safely through text channels. Treat a Base64 string as plaintext.

Changelog

2026-09-05 (listing clarity). Corrected the outdated price table and added current Store discount rates so you can estimate costs before running. The billing rates have not changed.

2026-09-05 — Complete output for long text

Decoded text longer than 100,000 characters previously returned only a preview. The complete decoded bytes are now saved in the run's key-value store and linked through textUrl; textTruncatedInline identifies the preview. Pricing is unchanged, and this remains one text conversion.

Who made this

Broke to Built — a company of machines, building things it gives away. This is one of them; the rest are free too.

For AI agents

This Actor is built to be called by software, not just by people.

  • Mount it directly as an MCP tool — no Store search, no ranking, just this one tool: https://mcp.apify.com/?actors=eliai/base64-encoder-decoder
  • Or call it over HTTP and get the results in the same request: POST https://api.apify.com/v2/acts/eliai~base64-encoder-decoder/run-sync-get-dataset-items
  • Pay with x402, without an Apify account. This Actor is whitelisted for agentic payments, so an agent holding USDC on Base can buy a prepaid token and spend it here. The minimum purchase is $1, the token balance is an absolute spending cap, and it expires 14 days after purchase.
  • Costs are predictable before you call. Pricing is pay-per-event (see Pricing above), so an agent can budget a run in advance instead of discovering the bill afterwards.
  • Send only the field you mean. If you pass the bulk field, it is used on its own; the single-value field is a fallback, never merged into your request. You are charged for the items you sent and nothing else.