Base64 Encoder / Decoder
Base64 is an encoding scheme for representing binary data in text format. It uses 64 characters (A-Z, a-z, 0-9, +, /) to represent data. This tool allows you to encode text data to Base64 format or decode Base64 data to text. You can process data up to 5120 characters.
How to use
About this tool
This Base64 encoder decoder lets you encode text to Base64 or decode Base64 back to text in one place. Use it for tokens, config values, data URIs, and quick debugging when an API or file expects ASCII-safe content. Base64 is encoding, not encryption. Anyone can decode the output, so do not treat it as a way to hide secrets. Switch between encode and decode as needed, then copy the result into your editor, terminal, or ticket. Conversion runs in your browser. The tool is free and requires no account. When you need the same encode/decode steps in a loop from Cursor, Claude, or your own scripts, use Thousand API MCP for automation.
How to use
Switch encode/decode, type or paste in the text field. Results update in real time; copy as needed.
Options
Direction: Switch between Encode (text→Base64) and Decode (Base64→text).
Use cases
• Embedding API keys and auth tokens (e.g. HTTP Basic Auth headers) • Embedding binary data in JSON or XML payloads • Converting images to data URIs for HTML/CSS • Inspecting JWT payloads during debugging (header and payload are Base64URL-encoded)
Code Examples
1// Encode (UTF-8 is stored as bytes; no extra conversion needed)
2$encoded = base64_encode('Hello, 世界');
3
4// Decode; true = strict mode (reject invalid characters)
5$decoded = base64_decode($encoded, true);
6
7// If the source is not UTF-8, convert first
8$utf8 = mb_convert_encoding($text, 'UTF-8', 'SJIS');
9$encoded = base64_encode($utf8);1use Illuminate\Support\Facades\Storage;
2
3// Embed an image as a data URI in a JSON response
4$bytes = Storage::disk('local')->get('logo.png');
5$base64 = base64_encode($bytes);
6
7return response()->json([
8 'image' => 'data:image/png;base64,' . $base64,
9]);1import base64
2
3encoded = base64.b64encode('Hello, 世界'.encode('utf-8')).decode('ascii')
4decoded = base64.b64decode(encoded).decode('utf-8')
5
6# URL-safe variant (uses - and _ instead of + and /)
7urlsafe = base64.urlsafe_b64encode(b'data').decode('ascii')1// Encode UTF-8 text
2const encoded = Buffer.from('Hello, 世界', 'utf8').toString('base64');
3
4// Decode back to UTF-8
5const decoded = Buffer.from(encoded, 'base64').toString('utf8');Privacy and data
Encoding and decoding happen in the browser; input is never sent to a server.
FAQ
- Q: What is Base64?
- A: An encoding that represents binary data as ASCII text using 64 characters (A–Z, a–z, 0–9, +, /). Common in tokens, data URIs, JSON/XML payloads, and config values.
- Q: What is the difference between Base64 and URL-safe Base64?
- A: Standard Base64 uses + and /, which have special meaning in URLs. URL-safe Base64 replaces + with - and / with _, so the string can be used in URLs and filenames without percent-encoding. JWT header and payload use URL-safe Base64 (Base64URL), typically without padding.
- Q: Does Base64 encrypt my data?
- A: No. Base64 is encoding, not encryption. Anyone can decode it without a key. Do not use Base64 to hide secrets; use a proper encryption algorithm or a secrets manager.
- Q: Can I encode large files or images?
- A: This page handles text up to 5,120 characters. For files or images, use the Base64 File Converter or Image to Base64 tools, which process files in the browser. Very large files may slow the browser because processing is in-memory.
- Q: Why does Base64 encoding increase size by about 33%?
- A: Base64 maps every 3 bytes (24 bits) to 4 characters of 6 bits each. 4/3 ≈ 1.333, so the encoded string is about 33% larger than the original, plus optional = padding to a multiple of 4 characters.
