Developer Utility Tools

Base64 Encode & Decode

Encode UTF-8 text, files and images to Base64 or data URIs, and decode Base64 from APIs, emails or tokens back into readable text or a downloadable file. Handles URL-safe Base64, missing padding and MIME line wrapping, and doubles as a Base64 gzip decoder: gzip and zlib/deflate payloads are detected and decompressed, and you can gzip data before encoding it.

Private by design: anything you enter is processed in your browser only. It is never uploaded to or logged on our servers. Files are encoded and decoded locally and never uploaded. Share links contain only the text you typed or pasted, never selected files.

0 characters

About Base64 encoding

Base64 represents binary data using 64 printable ASCII characters (A–Z, a–z, 0–9, + and /). Every 3 bytes of input become 4 characters of output, so encoded data is about 33% larger than the original, with = padding added when the input length is not a multiple of three. It is used wherever binary data has to travel through text-only channels: email attachments (MIME), JSON APIs, HTTP Basic authentication headers, JWTs and data URIs embedded in HTML or CSS.

Base64URL (RFC 4648 §5) replaces + and / with - and _ and usually drops the padding, so the result can be used in URLs, file names and JSON Web Tokens without further escaping. To read the header and claims of a token, paste it into the JWT decoder, which splits and decodes all three Base64URL parts at once. MIME Base64 (RFC 2045) wraps lines at 76 characters, which some email and PEM tooling still expects. This decoder accepts all of these variants automatically.

Text is encoded as UTF-8 first, so emoji and non-Latin scripts round-trip correctly, unlike the browser's built-in btoa() which fails on characters outside Latin-1. When decoding, the Base64 → File tab inspects the leading "magic bytes" to identify PNG, JPEG, GIF, WebP, PDF, ZIP and SVG content, lets you preview images and download the result with the right extension.

Base64 + gzip. Compressed data is often Base64-encoded so it can travel as text. Helm 3 stores each release in a Kubernetes Secret as Base64-encoded gzip of the release JSON (and Kubernetes Base64-encodes Secret data again), CloudWatch Logs subscription events arrive in Lambda as Base64-encoded gzip, the SAML HTTP-Redirect binding sends raw-DEFLATE-compressed, Base64-encoded messages, and gzipped files are sometimes kept in a ConfigMap's binaryData. This page recognises the gzip magic bytes 1f 8b and the zlib header (78 01, 78 9c, 78 da) and decompresses them with your browser's built-in DecompressionStream; raw deflate has no header, so pick it manually. Tick "Gzip before encoding" to produce the same kind of payload. To inspect SAML messages in full, use the SAML response analyzer.

Base64 is an encoding, not encryption: anyone can decode it, so never use it to hide secrets. Inlining small icons as data URIs can save HTTP requests, but for larger images the 33% overhead and lost caching usually make a separate file the better choice. Shrink an image with the image compressor or an SVG with the SVG optimizer before encoding it. Need HTML, JSON or JavaScript escaping instead? Use the String Escape & Unescape tool, and for query strings the URL encoder. Everything on this page runs locally in your browser.

Reference Guide

The Base64 alphabet (RFC 4648). Each character carries 6 bits:

ValuesStandardURL-safe (Base64URL)
0–25A–ZA–Z
26–51a–za–z
52–610–90–9
62+-
63/_
Padding= pads the output to a multiple of 4 characters=, usually omitted (JWTs never pad)

Example: the bytes FB FF BF encode to +/+/ in standard Base64 and -_-_ in Base64URL.

Size and padding. Every 3 input bytes become 4 characters, so the encoded length is 4 × ceil(n / 3) with padding, or ceil(4n / 3) without. MIME wrapping adds a line break every 76 characters.

InputBytesBase64Padding
M1TQ==2 characters (n mod 3 = 1)
Ma2TWE=1 character (n mod 3 = 2)
Man3TWFuNone (n mod 3 = 0)
1 MB file1,048,5761,398,104 charactersAbout 33% larger

Data URI format: data:[<media type>][;base64],<data>, for example data:image/png;base64,iVBORw0KGgo... or data:text/plain;charset=utf-8;base64,SGVsbG8=.

Command-line and code equivalents:

PlatformEncodeDecode
Linux (GNU)base64 -w 0 file.pngbase64 -d file.txt > file.png
macOSbase64 -i file.pngbase64 -D -i file.txt -o file.png
A string (shell)printf '%s' 'Hello' | base64echo 'SGVsbG8=' | base64 --decode
OpenSSLopenssl base64 -A -in file.pngopenssl base64 -d -A -in file.txt
PowerShell[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes('Hello'))[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('SGVsbG8='))
PowerShell (file)[Convert]::ToBase64String([IO.File]::ReadAllBytes("$PWD\file.png"))[IO.File]::WriteAllBytes("$PWD\file.png", [Convert]::FromBase64String($b64))
Node.jsBuffer.from(text).toString('base64')Buffer.from(b64, 'base64').toString('utf8')
Pythonbase64.b64encode(data)base64.b64decode(s)
PHPbase64_encode($data)base64_decode($s, true)

Compressed payloads inside Base64:

FormatFirst bytes (hex)Base64 usually starts withDecode on the command line
gzip (RFC 1952)1f 8b 08H4sIecho "$b64" | base64 -d | gunzip
zlib (RFC 1950)78 01, 78 5e, 78 9c, 78 daeA, eF, eJ, eNecho "$b64" | base64 -d | python3 -c "import sys,zlib; sys.stdout.buffer.write(zlib.decompress(sys.stdin.buffer.read()))"
Raw deflate (RFC 1951)no headervaries... | python3 -c "import sys,zlib; sys.stdout.buffer.write(zlib.decompress(sys.stdin.buffer.read(), -15))"
Helm 3 release secretgzip, Base64-encoded twiceSDRzSU in the Secret datakubectl get secret sh.helm.release.v1.NAME.v1 -o jsonpath='{.data.release}' | base64 -d | base64 -d | gunzip
Create gzip + Base64gzip -c file.json | base64 -w 0 (GNU) or gzip -c file.json | base64 (macOS)

GNU base64 wraps output at 76 characters unless you pass -w 0. In the browser, btoa() only accepts Latin-1 characters, so encode text to UTF-8 bytes first. For Base64URL use 'base64url' in Node.js or base64.urlsafe_b64encode in Python.

Example input

Hello, World! Grüße 👋

This sample loads automatically when you open the tool. Use Load Sample to bring it back.

Frequently Asked Questions

Base64 represents binary data using 64 printable ASCII characters, so files and images can travel safely inside text formats such as JSON, HTML, CSS, email and data URIs. Encoded output is about 33% larger than the original.

No. Base64 is an encoding, not encryption. Anyone can decode it, so never use it to hide passwords or secrets.

URL-safe Base64 replaces + with - and / with _ and usually drops the = padding, so the value can be used in URLs, filenames and JWTs without extra escaping.

No. Encoding and decoding happen entirely in your browser, so your text and files never leave your device.