Base64 Encoder & Decoder API — Files, Text & Data URIs
Pricing
Pay per event
Base64 Encoder & Decoder API — Files, Text & Data URIs
Encode text or any file URL to Base64 and get a ready-to-paste data: URI back, or decode Base64 to text and downloadable files. Batch input, URL-safe alphabet, strict validation. $0.0002 per text item, $0.0005 per file; failed items never charged.
Pricing
Pay per event
Rating
0.0
(0)
Developer
Broke to Built
Maintained by CommunityActor stats
0
Bookmarked
61
Total users
46
Monthly active users
3 days ago
Last modified
Categories
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, CSSurl(), 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:
| Field | When | Meaning |
|---|---|---|
mode | always | encode or decode |
processedAt | always | ISO timestamp for that item |
base64 | encode | The Base64 string (standard or base64url if urlSafe) |
dataUri | encode, file | Complete data:<mime>;base64,... — paste straight into <img src> or CSS |
contentType | encode, file | MIME from the server's header, or sniffed from magic bytes |
inputBytes | encode | Size of the source text/file in bytes |
alphabet | encode | standard or base64url |
url | encode, file | The file URL you supplied |
base64Key / base64Url | encode, huge files | Set instead of base64 when the result exceeds ~3 MB; the payload goes to the key-value store |
text | decode | Decoded content, when the bytes are valid UTF-8 |
kind | decode | text or file |
decodedBytes | decode | Byte length of the decoded payload |
declaredMime | decode | MIME declared inside a data: URI, if there was one |
fileKey / downloadUrl | decode, binary | Key-value store key and a signed, shareable download URL |
error | any failure | Plain-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
| Field | Type | Default | Notes |
|---|---|---|---|
mode | encode | decode | encode | |
text | string | sample text | One text to encode, or a Base64 string / data URI to decode |
items | string[] | [] | Batch — one dataset row per item |
fileUrls | string[] | [] | Encode mode: public files to download & encode |
urlSafe | boolean | false | Output base64url (-/_, no padding). Decode accepts both alphabets always |
decodeToFile | boolean | false | Decode mode: always store the decoded bytes as a downloadable file |
maxFileSizeMb | integer | 25 | Skip downloads larger than this (recorded, unbilled) |
One gotcha worth 10 seconds:
textships 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 ApifyClientclient = 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():print(row.get("text") or row.get("downloadUrl") or row.get("error"))
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
Pay per event. Two events, and one event = one item, not one run:
| Event | What one event covers | Price |
|---|---|---|
text-converted | One text string encoded, or one Base64 string decoded to text | $0.0002 |
file-converted | One remote file downloaded and encoded, or one decoded payload stored as a file | $0.0005 |
At those prices 1,000 text conversions cost $0.20 and 1,000 file conversions cost $0.50. There is no start fee, no monthly fee, and no minimum.
Scheduled change: on 27 August 2026 these rise to $0.001 per text item and $0.002 per file ($1.00 / $2.00 per thousand). The prices above are what you pay until then.
Why, since Apify's notification email does not carry a reason. The launch price was set low enough to be close to free, and it was under every other paid converter in this category — a position that does not pay for keeping the thing reliable. The new price is still at the cheap end of the same category (paid rivals in comparable conversion slots run roughly $0.00001–$0.005 per item, measured 2026-08-16), and nothing about the service is being reduced to justify it: failures stay free, data is still written before the charge, there is still no start fee, no monthly fee and no minimum, and the batching, size caps, validation and oversized-payload storage all stay. At the new rate a thousand conversions costs a dollar. If that changes your maths, the four lines of code note below is honest advice and it still stands — we would rather you keep the run you actually need than pay for one you do not.
Anything that fails — invalid Base64, a dead URL, an oversized download — is written to the dataset with an error field and never billed. Data is pushed before the charge call, so even a run that hits your spending limit keeps everything it already produced.
Honest comparison: encoding Base64 is four lines of code in any language, and if you are already writing a script, write those four lines instead. What you are paying for here is the hosted, batched, validated version with retries, size caps, storage of oversized payloads, and a dataset you can hand to the next step — worth $0.0002 only when the alternative is building and hosting that glue yourself.
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
base64Urlinstead ofbase64. fileUrlsapplies 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; 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.
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.