Home / Guides / How to encode or decode Base64 for text and files

How to encode or decode Base64 for text and files

Encode or decode Base64 for text and files. Start with built-in commands or a free local tool. Use the cloud Actor when you have many items or file links.

You have some text, or a small file, and you need it in Base64. That is a common job for data URIs, email-safe text, and APIs that only accept text. This page shows the honest options, starting with tools you may already have. We made the paid and free Tidy Byte Tools options below.

Base64 is encoding, not encryption. Anyone can turn it back into the original bytes. Do not use it to hide passwords or keys.

Try a built-in command first

If you only need to convert one short string, a tool already on your computer is often enough.

macOS and Linux

printf 'hello world' | base64
printf 'aGVsbG8gd29ybGQ=' | base64 --decode

On macOS the second command may need base64 -D instead of base64 --decode.

Python 3 (Windows, macOS, or Linux)

python3 -c "import base64; print(base64.b64encode(b'hello world').decode())"
python3 -c "import base64; print(base64.b64decode('aGVsbG8gd29ybGQ=').decode())"

Windows PowerShell

[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes('hello world'))
[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('aGVsbG8gd29ybGQ='))

If that already gives you the result, you are done.

Do not paste passwords, API keys, or private files into a random website. Many "online Base64" pages send what you paste to a server.

Free local tool: base64-lite

base64-lite is a free tool you run on your own computer. It has a command-line tool and an MCP server for AI apps. There is no API key and no account. We made it.

What it does

  • Encodes or decodes Base64 for text and local files.
  • Supports the URL-safe alphabet (- and _) and data-URI output.
  • Can auto-detect encode vs decode, or you can set the direction yourself.
  • Runs offline, so the file stays on your machine.

What it does not do

  • It does not fetch file links from the internet.
  • The MCP file tool has a 5 MB cap. The command line can read a larger local file.
  • Auto-detect can guess wrong on short or unusual strings. Set encode or decode when you already know the direction.
  • It does not inspect decoded bytes for viruses or hidden data.

Install and run

You need Python 3. The package is not on PyPI yet, so install it from GitHub:

pip install git+https://github.com/tidybytetools/base64-lite
printf 'hello world' | base64-lite --action encode
base64-lite photo.png --action encode --data-uri
printf 'aGVsbG8gd29ybGQ=' | base64-lite --action decode

To use it from Claude Desktop or Cursor, see the repository README. The product page is on our site.

Free HTTP API, with a daily cap

If you want a simple HTTPS call and the text is small (up to 16 KB), you can use our free Tidy Byte Tools API:

curl -sS https://tidybytetools.tidybytetools.workers.dev/v1/base64 \
  -H 'content-type: application/json' \
  -d '{"action":"encode","text":"hello world"}'

Anonymous use is 50 calls per IP per UTC day. A free key (POST /keys) raises that to 200 calls a day. This path is for short text, not large files and not file URLs.

When you need many items or file links

Use the cloud tool if you need any of these:

  • Many texts or files in one run (repeats in the same run are free)
  • A public file link, not a file already on your computer
  • A scheduled run in the cloud

Base64 Encoder & Decoder runs on Apify. It costs $0.001 per unique item. Failed items are free. We made this Actor too. You can also run it from Apify MCP.

If you only need one local string, the built-in commands or the free lite tool are the better fit.