Encoding and security

Base64 Encode and Decode Online

Convert text and files to Base64 and back, live in both directions, with Base64url, data URIs and downloads that get the right file type.

  • Free foreverNo trial, no paywall, no usage limits.
  • No sign-upOpen the page and start. We never ask for an email to use a tool.
  • PrivateEverything runs in your browser. Your input is never uploaded or stored on our servers.
  • Works offlineOnce the page has loaded, the tool keeps working without a connection.
Type in either box: text becomes Base64 and Base64 becomes text, live.Turn any file into Base64 or a data URI, or turn Base64 back into a downloadable file.
Base64url (RFC 4648 §5) swaps + and / for - and _ so the result can sit in a URL, file name or JWT without escaping. Decoding accepts both alphabets either way.
Adds = signs so the length is a multiple of 4. Required by many decoders; JWTs and most URL uses drop it. Decoding works with or without.
Breaks lines every 76 characters, as MIME email (RFC 2045) and many PEM-style tools expect. Leave off for JSON, URLs and data URIs.

Text

Plain text is turned into UTF-8 bytes first, so every language and emoji round-trips exactly (unlike the browser's btoa).
Copy textDownload text.txtClear both

Base64

Paste Base64, Base64url or a data URI here to decode it. Whitespace and line breaks are ignored.
CopyDownload base64.txt
Type in either box — it converts live, both ways. Nothing leaves your browser.

Need a secure web app built around this? Talk to our team

Quick answer

Base64 is an encoding that writes any bytes using 64 printable characters (A–Z, a–z, 0–9, + and /), so binary data can travel through text-only channels such as JSON, email and URLs. It is not encryption: anyone can decode it. In Playxoft's Base64 tool, type text to encode it or paste Base64 to decode it; switch to File to convert images, PDFs and other files.

  • Live both ways
  • UTF-8 safe
  • Base64url and padding
  • MIME wrap at 76
  • File to data URI
  • Base64 to file download
  • Error position

How to use the Base64 Encoder and Decoder

  1. 1Type or paste text into Text to encode it, or paste Base64 into Base64 to decode it. Both boxes update live as you type.
  2. 2Turn on URL-safe for Base64url (JWTs, URLs, file names), switch off Padding to drop the trailing = signs, or enable Wrap at 76 for MIME email.
  3. 3Choose File and drop any file to copy its Base64, a data URI, or a ready-made CSS or HTML snippet for images.
  4. 4To rebuild a file, paste Base64 or a data URI into Base64 to file, check the detected type and click Download file.
  5. 5If decoding fails, click Show me to jump straight to the first character that is not valid Base64.

What is Base64 encoding?

Base64 turns arbitrary bytes into plain ASCII text. It takes the input 3 bytes (24 bits) at a time, splits them into four 6-bit groups, and maps each group (a number from 0 to 63) to one character of a 64-character alphabet: A–Z, a–z, 0–9, + and /. The encoding is defined in RFC 4648.

InputBytes (binary)6-bit groupsBase64
Man01001101 01100001 0110111019 · 22 · 5 · 46TWFu
Ma01001101 0110000119 · 22 · 4TWE=
M0100110119 · 16TQ==

When the input is not a multiple of 3 bytes, the last group is filled with zero bits and = padding brings the output to a multiple of 4 characters. Text is converted to bytes first — almost always as UTF-8 — which is why café encodes to Y2Fmw6k=: the é is the two bytes C3 A9.

Is Base64 encryption?

No. Base64 is an encoding: a reversible change of representation with no key and no secret. Anyone who sees dXNlcjpwYXNz can decode it to user:pass in a millisecond — which is exactly what an HTTP Basic Authorization header contains. Kubernetes Secrets, JWT payloads and many config files are Base64 too, and none of them are protected by it.

Encoding (Base64)Hashing (SHA-256)Encryption (AES-GCM)
Reversible?Yes, by anyoneNoYes, with the key
Needs a key?NoNoYes
PurposeCarry bytes through textFingerprint and integrityConfidentiality

If data must stay private, encrypt it (for example AES-GCM via Web Crypto or libsodium) and then Base64-encode the ciphertext for transport. To fingerprint data, use the hash generator; to read a token's claims, use the JWT decoder.

Why is Base64 33% bigger than the original?

Every 3 bytes become 4 characters, so the encoded size is 4 × ⌈n / 3⌉ — about 4/3 of the input, or +33%. Padding adds up to two characters, MIME line breaks add two more bytes (CRLF) per 76 characters, and a data URI adds its data:<type>;base64, prefix.

Original sizeBase64 sizeOverhead
1 byte4 characters+300%
3 bytes4 characters+33%
1,024 bytes (1 KB)1,368 characters+33.6%
1,048,576 bytes (1 MB)1,398,104 characters+33.3%

That overhead is why inlining is a trade-off. A data URI saves an HTTP request, but the bytes grow by a third, cannot be cached separately and are re-downloaded with every copy of the page or stylesheet that embeds them. Inline small icons and tiny fonts; serve photos and large files as normal files.

Base64 vs Base64url: what is the difference?

Standard Base64 uses + and /, which have special meanings in URLs and file paths. Base64url (RFC 4648 §5) swaps them for - and _ and usually drops the padding.

VariantCharacters 62 and 63PaddingLine lengthWhere you meet it
Standard (RFC 4648 §4)+ /RequiredNoneJSON payloads, data URIs, most APIs
Base64url (RFC 4648 §5)- _Usually omittedNoneJWTs, URL parameters, file names
MIME (RFC 2045)+ /Required76Email attachments
PEM (RFC 7468)+ /Required64Keys and certificates

A classic bug: putting standard Base64 in a query string without escaping it. Form decoding turns each + into a space and the value breaks. Either use Base64url or URL-encode the value. Data URIs are the opposite case: browsers decode them with the standard alphabet only, so never use Base64url there. This decoder accepts both alphabets, with or without padding and line breaks.

How do I encode and decode Base64 in code?

Every language has a built-in. Modern browsers (Baseline since September 2025) convert bytes directly with Uint8Array.prototype.toBase64() and Uint8Array.fromBase64(), including the URL-safe alphabet. The one trap in older code is btoa(), which only accepts Latin-1 and throws on emoji or most non-English text, so convert to UTF-8 bytes first:

// JavaScript (modern browsers): bytes in, Base64 out
const bytes = new TextEncoder().encode("Hello, 世界");
bytes.toBase64();                                         // "SGVsbG8sIOS4lueVjA=="
bytes.toBase64({ alphabet: "base64url", omitPadding: true });
new TextDecoder().decode(Uint8Array.fromBase64("SGVsbG8sIOS4lueVjA=="));

// JavaScript (older browsers): UTF-8 safe btoa
const b64 = btoa(String.fromCharCode(...bytes));          // "SGVsbG8sIOS4lueVjA=="
const text = new TextDecoder().decode(Uint8Array.from(atob(b64), (c) => c.charCodeAt(0)));

// Node.js
Buffer.from("Hello, 世界").toString("base64");     // standard
Buffer.from("Hello, 世界").toString("base64url");  // URL-safe, no padding

# Python
import base64
base64.b64encode("Hello, 世界".encode()).decode()          # standard
base64.urlsafe_b64encode(b"\xfb\xff").decode()            # "-_8="

// Go
base64.StdEncoding.EncodeToString([]byte("Hello, 世界"))
base64.RawURLEncoding.EncodeToString(data) // URL-safe, no padding

// C#
Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello, 世界"));
Encoding.UTF8.GetString(Convert.FromBase64String(b64));

On the command line, base64 file.png encodes (GNU base64 wraps at 76 columns; add -w 0 for one line) and base64 -d decodes. The spread-into-fromCharCode trick above is fine for short strings; for files, encode in chunks or use FileReader.readAsDataURL.

Frequently asked questions

btoa() only accepts strings where every character is a single byte (Latin-1). Emoji, Chinese, Arabic and many accented characters are not, so it throws. Convert the text to UTF-8 bytes with TextEncoder first, then Base64-encode the bytes. This tool does that automatically, so any Unicode text round-trips exactly.
Usually because the data is binary, such as an image, PDF, ZIP or encrypted blob, rather than text. The tool detects this, shows the file type from its magic bytes and offers a download instead. Less often the text was encoded in UTF-16 or Latin-1 rather than UTF-8.
They are padding. Base64 works in groups of 4 characters, and one or two = signs fill the last group when the input length is not a multiple of 3 bytes. Padding carries no data, so Base64url and JWTs usually leave it out. This decoder accepts input with or without it.
MIME email wraps Base64 at 76 characters and PEM keys at 64, so line breaks are common. Strict RFC 4648 decoders reject them, but most real-world decoders, including this one, ignore whitespace and line breaks.
Choose File, drop the image, and pick the output you need: raw Base64, a data URI for an img src or CSS url(), or a ready-made CSS or HTML snippet. Keep inlined images small, because Base64 makes them a third larger and they can no longer be cached on their own.
No. Encoding, decoding and file conversion all run in your browser, so text and files never leave your device. Remember that Base64 itself offers no protection: anyone who gets the encoded text can decode it.

Last updated by the Playxoft engineering team.

From the engineers who built this tool

Building something bigger than a quick fix?

Auth, payments, dashboards and security are where web apps get hard. We have shipped them many times. Share your idea and we will map out a realistic plan and estimate, free and with no obligation.

More free tools

See all tools

JWT Decoder

Decode JWTs, explain every claim and expiry, verify signatures and sign new tokens.

Open tool

URL Encoder and Decoder

Percent-encode or decode URLs and query values, and inspect every parameter.

Open tool

Hash Generator

MD5, SHA-1, SHA-256, SHA-384 and SHA-512 for text or files, with HMAC and checksum verify.

Open tool

UUID Generator

Generate v4 and v7 UUIDs in bulk, and decode any UUID's version and timestamp.

Open tool

Nanoid Generator

Generate nanoid IDs with any alphabet and length, and check how long until a collision.

Open tool

ULID Generator

Generate sortable ULIDs in bulk, decode their timestamps and convert them to UUIDs.

Open tool