Ttooleras
🔄

Base64 Encoder/Decoder

Encoders & Decoders

Encode and decode Base64 strings, files, and images instantly. Free, private — all processing in your browser.

Advertisement

Base64 turns any data — text, an image, a PDF — into a string of 64 "safe" characters (A–Z, a–z, 0–9, plus + and /) that survives being pasted into JSON, a URL, an email header, or a CSS file without getting mangled. This tool goes both ways: type or paste text to encode it, paste a Base64 string to decode it back, or drop a file in to get its Base64 — with a live preview if the file is an image.

Flip on URL-safe mode to swap + and / for - and _ and drop the = padding — that's the variant tokens and query strings use. Everything runs in your browser: a file you encode here never leaves your machine, which is the whole reason to do it locally instead of on some server.

How to use the Base64 Encoder/Decoder

  1. 1

    Choose encode or decode

    Select the Encode tab to convert text or files to Base64, or the Decode tab to convert Base64 back to text.

  2. 2

    Paste or type your input

    In the input field, paste the text you want to encode, the Base64 string you want to decode, or drop a file to encode.

  3. 3

    Select the variant

    Toggle between standard Base64 (for general use, email, databases) and URL-safe Base64 (for URLs, JWT tokens, OAuth).

  4. 4

    Choose padding option

    Enable padding for strict RFC 4648 compliance. Disable it for JWT and other contexts where padding is omitted.

  5. 5

    Copy the result

    The output updates instantly. Click Copy to put it on your clipboard, or Download to save it as a file.

Base64 Encoder/Decoder — examples

Encode plain text

Standard Base64 encoding of a simple string.

Input
Hello, World!
Output
SGVsbG8sIFdvcmxkIQ==

Decode Base64 string

Reverse the encoding to get the original text back.

Input
VG9vbGVyYXMgaXMgZnJlZSE=
Output
Tooleras is free!

HTTP Basic Auth

Encode username:password pair for the HTTP Authorization header.

Input
admin:s3cr3t
Output
YWRtaW46czNjcjN0

URL-safe Base64 for JWT

URL-safe variant replaces + with - and / with _, and often omits padding.

Input
{"sub":"1234567890","name":"John Doe","admin":true}
Output
eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9

Data URI for small image

Base64-encoded image ready to use in HTML or CSS.

Input
<1x1 red pixel PNG file>
Output
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==

Unicode text with emoji

UTF-8 multi-byte characters work correctly.

Input
Hello 世界 🌍
Output
SGVsbG8g5LiW55WMIPCfjI0=

Base64 Encoder/Decoder — key features

Encode any text to Base64

Convert plain text, including Unicode (emoji, CJK, accents), to Base64. UTF-8 is used by default. Output appears instantly as you type.

Decode Base64 back to text

Paste a Base64 string and get the decoded UTF-8 text. Malformed input is detected and reported clearly.

Encode files to Base64

Drop any file (images, PDFs, fonts, binaries) into the tool and get a Base64 string ready to embed in a data URI, JSON payload, or SQL INSERT.

Standard and URL-safe variants

Toggle between standard Base64 (+, /, =) and URL-safe Base64 (-, _, optional padding) used by JWT, OAuth, and URL-embedded data.

Optional padding

Enable or disable the = padding characters. Required for strict RFC 4648 Section 4, optional for URL-safe Section 5 and JWT.

Copy, download, and share

Copy the output to clipboard or download as a .txt file. Perfect for pasting into email, APIs, or config files.

Live encoding and decoding

Results update as you type — no need to click a button. Speed is limited only by your browser.

100% private, client-side

All encoding and decoding happens in your browser using the native btoa() and atob() functions. Your data is never uploaded to any server.

Common use cases for the Base64 Encoder/Decoder

Web development

  • Embed images as data URIs: Encode small images (icons, sprites, logos) as Base64 and embed them in CSS or HTML with `data:image/png;base64,...` to save HTTP requests.
  • Embed fonts in CSS: Include custom web fonts directly in stylesheets as data URIs for simpler deployment and no CORS issues.
  • Inline SVG and PDFs: Embed small SVGs or PDFs inline without separate file requests.

APIs and authentication

  • HTTP Basic Authentication: Encode username:password as Base64 for the Authorization header: `Authorization: Basic dXNlcjpwYXNz`.
  • JWT tokens: JSON Web Tokens consist of three Base64URL-encoded parts (header.payload.signature). Decode them to inspect claims and verify structure.
  • OAuth client credentials: Encode client_id:client_secret as Base64 for OAuth 2.0 client credentials grant.
  • API payloads with binary data: Send images, files, or binary blobs inside JSON or XML by encoding them as Base64 strings.

Email and messaging

  • MIME email attachments: Email attachments are Base64-encoded in the MIME body. Decode them to inspect raw content.
  • SMTP debugging: When debugging SMTP traffic, decode Base64-encoded SASL authentication and attachment bodies.

Storage and debugging

  • Store binary in text databases: When a database column accepts only text, store binary data as Base64 strings (PostgreSQL, MySQL, SQLite).
  • Inspect webhook payloads: Some webhooks send binary data as Base64 inside JSON. Decode to inspect the original content.
  • Debug encoding issues: When data looks garbled, check whether it is Base64-encoded. Decoding it reveals the original bytes.

Technical details

How it works. Base64 takes three bytes (24 bits) at a time and re-slices them into four 6-bit groups, each mapped to one of 64 printable characters. Because it turns 3 bytes into 4 characters, the output is always about 33% larger than the input — Base64 is for *safe transport*, never for saving space. When the input isn't a multiple of three bytes, one or two = characters pad the end.

Text and Unicode. This tool encodes text as UTF-8 before Base64, so emoji, accents, and non-Latin scripts round-trip correctly — a common place naïve encoders break.

URL-safe variant. Standard Base64 uses + and /, which have meaning inside URLs. The URL-safe alphabet swaps them for - and _ and usually omits padding. JWTs, for example, are URL-safe Base64. Decoding a URL-safe string with a standard decoder (or vice-versa) fails — match the variant.

Data URIs. data:text/plain;base64,... (or data:image/png;base64,...) lets you embed a small asset directly in HTML or CSS with no extra request. Handy for tiny icons; wasteful for anything large because of the 33% overhead.

Troubleshooting

Treating Base64 as a way to hide secrets

Base64 is trivially reversible — it offers zero protection. If a value needs to stay secret, encrypt it. Base64 only makes binary data safe to paste into text channels.

Expecting Base64 to shrink data

It does the opposite: output is ~33% larger than input. Base64 is for safe transport, not compression. If you need smaller, gzip it first.

URL-safe vs standard mismatch

A string encoded URL-safe (with - and _) won't decode with a standard decoder, and vice-versa. If decoding fails, toggle the URL-safe switch to match how it was encoded.

Decoding produces garbled characters

Usually the source wasn't UTF-8 text, or it was actually binary (an image, a key). Binary decodes to non-printable bytes — that's expected, not an error.

Stray whitespace or line breaks in the input

Copied Base64 sometimes carries newlines or spaces that break strict decoders. Trim it, or paste a clean single block.

How it compares

Base64 vs encryption. This is the big one: Base64 is not security. It's a reversible encoding — anyone can paste your string into this very tool and read it. Never use it to "hide" a password, API key, or token. If you need secrecy, encrypt.

Base64 vs URL-encoding. Percent-encoding (%20) is for making *text* URL-safe. Base64 is for cramming *binary* data into a text-only channel. Different jobs — see the URL Encoder/Decoder.

Base64 vs gzip. Gzip makes data smaller; Base64 makes it bigger. If size matters, compress — don't Base64.

When to inline a Base64 image. Only for very small assets (a favicon, a tiny SVG). For anything real, a normal <img src> is smaller and cacheable; inlining defeats browser caching and adds 33%.

Base64 Encoder/Decoder — FAQ

Is Base64 a form of encryption?

No. It's a reversible encoding, not security. Anyone can decode a Base64 string in seconds — including in this tool. Never use it to protect passwords, keys, or tokens; use real encryption for that.

Does encoding a file upload it anywhere?

No. File reading and encoding happen entirely in your browser via the FileReader API. Nothing is sent to a server, which is why it's safe for private documents.

Why is my Base64 output bigger than the input?

Base64 represents every 3 bytes as 4 characters, so output is about 33% larger. That's inherent to the format — it trades size for the ability to travel safely through text-only channels.

What is URL-safe Base64 and when do I need it?

It replaces + and / (which are special in URLs) with - and _, and usually drops = padding. Use it for anything going into a URL or token — JWTs are URL-safe Base64. Toggle the switch to match your data.

Can I turn an image into Base64?

Yes — drop the file in and you'll get its Base64 plus a preview. This is mainly useful for embedding tiny images as data URIs in HTML/CSS; for normal images a regular file reference is smaller and cacheable.

Why does my Base64 fail to decode?

Three common causes: it's actually URL-safe (toggle the switch), it has stray whitespace/newlines, or the padding was stripped. Clean the string and match the variant.

Additional resources

Advertisement

Learn more

Explore more tools

200+ free tools that run in your browser.

Browse all tools →