Skip to main content
Glama

base64-lite

License: MIT Python 3.10+ MCP server Tests

Free tool that encodes or decodes Base64 for text and local files. Optional URL-safe alphabet and data-URI output.

Need it at scale in the cloud? The pay-per-use Base64 Encoder & Decoder on Apify costs $0.001 per unique item. Failed items are free.

Plain code, not AI, so the same input always gives the same output. Runs on your own computer. MIT license. Works with Python 3.10 and newer, on Windows, Mac and Linux.

Also searched as: ES: codificar base64, decodificar base64 / PT: codificar base64 / DE: Base64 kodieren / FR: encoder en base64 / JA: Base64エンコード、Base64デコード

Related MCP server: mcp-base64

Before and after

Before (plain text):

hello world

After (Base64):

aGVsbG8gd29ybGQ=

Decode works the other way, including data URIs like data:text/plain;base64,aGVsbG8gd29ybGQ=.

Install

pip install base64-lite

Or straight from GitHub: pip install git+https://github.com/tidybytetools/base64-lite

Or use pipx, which keeps it in its own space:

pipx install base64-lite

Or just download base64_lite.py and run it with python3. That one file uses only Python's standard library. (Installing with pip also adds the mcp package, which the MCP server needs.)

Use it

printf 'hello world' | base64-lite --action encode
base64-lite photo.png --action encode --data-uri
printf 'aGVsbG8gd29ybGQ=' | base64-lite --action decode
base64-lite note.b64 --action decode
base64-lite file.bin --action decode --output out.bin   # when the bytes are not text
printf 'hello world' | base64-lite --json               # {"ok": true, "action": "encode", "base64": "..."}

--action auto (the default) decodes if the input looks like Base64, otherwise it encodes. Use --action encode or --action decode when you already know the direction. --url-safe uses - and _ instead of + and / when encoding. Decoding always accepts both forms.

From Python:

from base64_lite import convert
convert("hello world", None, action="encode")["base64"]  # 'aGVsbG8gd29ybGQ='

When you run it in a terminal it prints one short line about the Apify version to stderr after the result. It never goes into your output, it only shows when you are looking at a terminal, and --quiet turns it off.

Known limits

  • auto can guess wrong on short or unusual strings. Use encode or decode when you already know the direction.

  • Local files only. This free tool does not fetch file links from the internet. The Apify version does.

  • 5 MB cap in the MCP file tool. The command line will read a larger local file, but very large jobs are a better fit for Apify.

  • It does not inspect decoded bytes for viruses or hidden data.

Lite vs Apify

lite (free, this repo)

Apify cloud version

Encode and decode text or files

yes, on your computer

yes, in the cloud

URL-safe alphabet and data URIs

yes

yes

Fetch file links

no

yes

Many items in one run

you can loop on your own

yes, and repeats in the same run are free

MCP server for local AI apps

yes

use Apify MCP for the cloud tool

Price

free

$0.001 per unique item. Failed items are free

Use it from Claude Desktop or Cursor (MCP)

There is a small free MCP server built in. It gives your AI app two tools. Both only read. They never write or change files, and they never use the internet. It needs uv.

Run it by hand to check it starts (it waits quietly for an app to talk to it):

uvx base64-lite mcp

Claude Desktop (claude_desktop_config.json) or Cursor (~/.cursor/mcp.json):

{
  "mcpServers": {
    "base64-lite": {
      "command": "uvx",
      "args": ["base64-lite", "mcp"]
    }
  }
}

uvx --from base64-lite base64-lite-mcp starts the same server.

Tools:

  • convert_text(text, action="auto", url_safe=false, data_uri=false): for text or Base64 in the chat.

  • convert_file(path, action="auto", url_safe=false, data_uri=false): for a local file, up to 5 MB. For decode, the file must be UTF-8 text of Base64.

Encoded results include base64 (and dataUri if you asked). Decoded results include text when the bytes are UTF-8, or isText false if they are not.

For AI agents

  • Use when: you need to encode text or a local file to Base64, or decode Base64 / a data URI.

  • Don't use when: you need to fetch a file from a URL, or the file is bigger than 5 MB in MCP. Use the Apify version for those jobs.

  • Input: text on stdin or a file path. Optional --action auto|encode|decode, --url-safe, --data-uri, --output FILE.

  • MCP: uvx base64-lite mcp gives two read-only tools, convert_text and convert_file.

  • Output: with --json, one object such as {"ok": true, "action": "encode", "base64": "...", "bytesIn": 11}. On error ok is false. Exit code 0 ok, 1 error.

  • Hint lines go to stderr only, and only in a terminal, so stdout is always clean. See also llms.txt.

Tests

pip install "mcp>=1.10,<2"
python3 -m unittest discover tests

The MCP tests are skipped if mcp is not installed.

FAQ

What input does it take? Text on stdin, or a local file. Use --action encode or --action decode if you already know the direction.

Do my files leave my computer? No. The tool runs on your computer and never uses the internet.

How is this different from the Apify version? The Apify version runs in the cloud, can fetch file links, and can process many items in one run ($0.001 per unique item, failed items free). This lite tool is free and local.

Does it work with AI apps? Yes. It includes a free MCP server. No API key.

License

MIT. See LICENSE.

Available Tools

2 tools
convert_fileEncode or decode a local file as Base64A
Read-onlyIdempotent

Read a local file and encode its bytes to Base64, or decode a Base64 text file.

Use this when the data is in a file on this computer, so you don't have to paste it. The file is only read, never changed. Files larger than 5 MB are rejected; use the Apify version for bigger jobs. For decode, the file must be UTF-8 text containing Base64 (or a data URI), not a binary file.

path: full path to a file, up to 5 MB.

Returns the same result object as convert_text. If the decoded bytes are not UTF-8 text, "isText" is false and "text" is null.

Inputs: path (required), action, data_uri, url_safe.

convert_textEncode or decode Base64 textA
Read-onlyIdempotent

Encode pasted text to Base64, or decode Base64 (or a data URI) back to text.

Use this when you have text or a Base64 string in the conversation. It is plain code, not an AI model, so the same input always gives the same output and nothing is made up. Do not use it for a file on disk (use convert_file for files), and do not use auto on short or unusual strings if you already know the direction — pass encode or decode instead.

Returns a result object. Encoded results include "action", "base64", "bytesIn", and "dataUri" plus "mime" when data_uri is true. Decoded results include "action", "bytesOut", "isText", and "text" (UTF-8 text, or null if the bytes are not text).

Inputs: text (required), action, data_uri, url_safe.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.5/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools split cleanly along input source: convert_text handles strings in the conversation, convert_file handles data on disk. The descriptions explicitly cross-reference each other ("Do not use it for a file on disk (use convert_file for files)"), leaving no realistic chance of misselection.

    Naming Consistency5/5

    Both names follow the same verb_noun pattern with the same verb (convert_text, convert_file), making the pair predictable and self-documenting. The noun directly encodes the distinguishing dimension.

    Tool Count3/5

    Two tools is on the thin side, though the two-way split (text vs file) is the only meaningful axis for a base64 encoder. It is a defensible minimal surface, but a single parameterized tool could arguably cover both, so it sits at the borderline.

    Completeness4/5

    Encode/decode is covered for both text and file inputs, with data URI handling, MIME reporting, and text-vs-binary detection returned as structured output. Gaps are minor conveniences only (e.g. URL-safe base64 alphabet, files above 5 MB which are explicitly punted to another tool).

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Provides tools to encode files to Base64 strings and decode Base64 content back to files, supporting both text and binary formats.
      2
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables encoding and decoding of text between Base64, Base64URL, Base32, and Hex formats, supporting offline keyless operations.
      71 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to encode text to base64 or decode base64 back to plaintext, with support for standard and URL-safe variants and pay-per-call micropayments via x402.
      MIT