Base64 Encoder & Decoder

Encode text and files into Base64 strings, or decode Base64 back to its original content, right in your browser.

๐Ÿ“ Drag & drop file here, or click to select โ€” generates Base64 + data URI
Images, fonts, PDFs, any file ยท Read in browser only ยท Max 8MB

Result

๐Ÿ”’ Your text and files are processed locally in your browser and are never sent to a server. Base64 is an encoding, not encryption, meaning anyone can reverse it. Do not use it to hide passwords or sensitive information.

What is the Base64 Encoder & Decoder?

Instantly encode text or files to Base64, or decode a Base64 string back to its original content. This tool is perfect for web developers creating data URIs to embed images or fonts directly into CSS and HTML, or for anyone needing to transmit binary data as plain text. Simply paste your content for real-time conversion. You can also drag and drop any file to generate both a Base64 string and its corresponding data URI. All operations happen entirely within your browser for complete privacy; your data is never uploaded.

How to use

  1. Paste text into the 'Input' box, or drag and drop a file onto the dashed area.
  2. The conversion appears instantly in the 'Result' field. For files, a 'Data URI' is also generated.
  3. Click '๐Ÿ“ Text โ†’ Base64' or '๐Ÿ”“ Base64 โ†’ Text' to switch between encoding and decoding.
  4. Check 'URL-safe' or 'Wrap every 76 chars (MIME)' to format the output as needed.
  5. Use the 'Copy' button to grab the result or the 'Save' button to download it as a file.

Base64 Encoder & Decoder guide

How this tool is used in real work, and what to watch out for.

Base64 Is Not Encryptionโ€”It's a Common Pitfall

Base64 is simply a way to represent binary data using only 64 common characters (Aโ€“Z, aโ€“z, 0โ€“9, +, /). There's no key or secret; anyone can revert it to the original text with a click of the 'Decode' button on this very page. Yet, it's often misused to 'hide' things just because the output isn't human-readable, leading to security vulnerabilities.

Here are some common mistakes: embedding API keys in frontend code as Base64, storing user roles in a Base64-encoded cookie, or sending payment amounts as Base64 parameters. In all three cases, anyone who can open their browser's developer tools can read, modify, and resubmit the data.

  • To hide information โ†’ Use encryption (e.g., AES). It requires a key to be decrypted.
  • To prevent tampering โ†’ Use a digital signature (e.g., HMAC, JWT). Validation fails if the value is changed.
  • To transfer data without corruption โ†’ Use Base64. This is its intended purpose.
The `Authorization: Basic dXNlcjpwYXNz` header in HTTP Basic Authentication is just the username and password (`user:pass`) encoded in Base64. Without HTTPS, it's transmitted in plain text. Never report a Base64-encoded value as 'encrypted'.

Why Text Gets Garbledโ€”The Crucial Role of UTF-8

Base64 operates on bytes, not characters. To encode text, it must first be converted into bytes, and the result depends entirely on the character encoding used for this step. This tool always uses UTF-8. For example, the Korean word "์•ˆ๋…•" ('hello') is 6 bytes in UTF-8, so its Base64 output is 8 characters long.

If your decoded text looks garbled, it's almost always an encoding mismatch. If a legacy system or some Java code generates Base64 from bytes using an older encoding like EUC-KR (CP949), decoding it as UTF-8 here will produce question marks or garbled characters. The reverse is also true.

  • Getting an error with `atob(btoa(text))` โ€” JavaScript's native `btoa` function assumes one byte per character and throws an error on multi-byte characters like those in Korean or emojis. This tool uses a `TextEncoder` to first create UTF-8 bytes before encoding, ensuring accurate results for all characters, including emojis ๐ŸŽ‰.
  • The entire decoded result is broken โ€” The original was likely encoded from EUC-KR bytes. The source that generated the Base64 string needs to be updated to use UTF-8.
  • A 'โš  Not UTF-8 text โ€” appears to be binary data' warning appeared โ€” This is normal. It means you've decoded a file like an image or PDF, which isn't meant to be readable as text.

When to Use the URL-safe Option

Standard Base64 includes three characters that have special meanings in URLs: `+`, `/`, and `=`. The `+` can be interpreted as a space in query strings, `/` is a path separator, and `=` can separate keys and values. If your Base64 string needs to be part of a URL or a filename, check the 'URL-safe' box. This replaces `+` with `-`, `/` with `_`, and removes the trailing `=` padding.

SituationURL-safeReason
Putting the value in a URL query string or pathOnAvoids conflicts with URL syntax characters `+`, `/`, `=`
Handling JWTs (JSON Web Tokens)OnThe JWT standard specifies `base64url` encoding
Using the value as a filenameOnThe `/` character is not allowed in most filesystems
Creating a data URIOffBrowsers only understand standard Base64
Email attachments (MIME)OffThe standard requires standard Base64, often with 76-character line wrapping
This tool will correctly decode URL-safe strings. Just paste the value inโ€”it automatically converts `-_` back to the standard characters and re-applies any necessary padding.

Data URIs: Embedding Files Directly in Code

When you drop a file onto the dropzone, a 'Data URI' field will appear along with the Base64 output. This string, which looks like `data:image/png;base64,iVBORโ€ฆ`, can be pasted directly into an `<img>` tag's `src` attribute or a CSS `background-image: url(...)` property. It allows you to display a file without needing a separate network request.

This is best for specific use cases: a few small PNG/SVG icons, a logo in an HTML email, or a font in an environment that can't load external files. It's a bad choice for large images. The encoding increases file size by about 33%, and because the image is embedded in the HTML or CSS, it can't be cached separately by the browser, forcing re-download on every page load.

The 'Data URI' field always generates standard Base64 (with padding, no line breaks). If you copy the value from the main 'Result' field while the 'URL-safe' or 'Wrap every 76 chars' options are enabled, browsers won't be able to read it. Always copy data URIs from their dedicated field.

Why Size Increases & What the 76-char Wrap Is For

Base64 encodes 3 bytes of data into 4 characters, so the output is always 4/3 the size of the originalโ€”an increase of about 33%. This is why the 'Size change' stat is usually around +33%. This overhead is unavoidable. If you need to send a file through a system with a 10 MB attachment limit, the original file can't be larger than about 7.5 MB.

The 'Wrap every 76 chars' option is for email. The MIME standard limits line length, and some old mail servers might truncate a single, very long line of text. You don't need to enable this unless you're embedding the Base64 string directly into the body of an email.

bash
# For large files, the terminal is faster (macOS/Linux)
base64 -i logo.png -o logo.b64      # Encode
base64 -d logo.b64 > logo.png       # Decode

# The browser dropzone only accepts up to 8MB

Frequently asked questions

Is Base64 a form of encryption?

No. Base64 is an encoding method, not encryption. It translates data into a text representation based on a public rule, so anyone can reverse it. It should not be used to protect sensitive data like passwords.

Will my non-English characters get corrupted?

No, your text is safe. This tool correctly handles all UTF-8 characters, including emojis (๐ŸŽ‰), Korean, and Japanese, ensuring perfect conversion and restoration without any data loss.

What is the 'data URI' that appears for files?

A data URI is a way to embed a file, like an image, directly into HTML or CSS code as text. This can help speed up web pages by reducing server requests. This tool automatically creates a ready-to-use data URI when you upload a file.

When should I use the 'URL-safe' or 'Wrap' options?

Use 'URL-safe' to make the output compatible with URLs or filenames by replacing '+' and '/' with '-' and '_'. The 'Wrap every 76 chars (MIME)' option is for compatibility with older systems that require line breaks in long strings.