Base64 Encoder / Decoder
Encode text or files to Base64 and decode Base64 strings instantly. Supports URL-safe Base64URL and Data URI generation.
How it works
- 1Select the Text or File tab depending on what you want to encode.
- 2For text: type or paste your input, then click Encode or Decode. Live mode auto-encodes as you type.
- 3For files: drop or browse for any file, optionally enable Data URI mode, then click Convert.
- 4Copy the output or download it as a .txt file.
Frequently asked questions
What Is Base64 and Why Does It Exist?
Base64 is an encoding scheme that converts binary data into a sequence of printable ASCII characters. It was invented to solve a specific problem: many communication systems and protocols were originally designed for plain text and could not reliably transmit arbitrary binary data. Email systems (SMTP), older FTP servers, and many network protocols would corrupt binary files by misinterpreting certain byte sequences as control characters or line endings.
The solution was to map every 3 bytes of binary data to 4 printable ASCII characters, using only 64 safe characters: uppercase letters (A–Z), lowercase letters (a–z), digits (0–9), plus + and /, with = used for padding. This guaranteed that any binary content could be safely embedded in text-based systems without corruption. Today, Base64 encoding is ubiquitous in web development, APIs, email attachments, and data storage.
Base64 Is Not Encryption
This is the most important thing to understand about Base64: it provides no security whatsoever. Base64 is a reversible encoding, not encryption. Anyone with access to a Base64 string can decode it instantly using any Base64 decoder — including this tool. There is no key, no password, and no secret involved.
Do not use Base64 to “hide” passwords, API keys, or sensitive data. Seeing a Base64 string and assuming it is protected is a common and dangerous mistake. For actual security, use proper encryption algorithms like AES-256 (symmetric) or RSA (asymmetric). Base64 is only for encoding — making binary data safe for text channels — not for protecting data.
Common Use Cases for Base64
Data URIs — embedding images in HTML and CSS. Instead of referencing an external file, you can embed an image directly in your HTML or CSS using a data URI: <img src="data:image/png;base64,iVBORw0KGgo..." />. This eliminates an HTTP request, making it useful for small images like icons, logos, and favicons in performance- critical scenarios. Our tool's File tab with Data URI mode generates the full data URI string ready to paste into your code.
API payloads. REST APIs typically exchange JSON, which is text-based. Binary data like images, PDFs, or audio cannot be embedded directly in JSON. Base64 encoding converts binary files to text strings that JSON can carry. Many upload APIs accept Base64-encoded file data rather than multipart form uploads.
Email attachments. The MIME standard uses Base64 to encode email attachments. When you receive a PDF via email, your email client is transparently decoding a Base64 string back into the original file. This is why email file sizes appear slightly larger than the original file.
JSON Web Tokens (JWT). JWTs use a variant called Base64URL (see below) to encode the header and payload sections. The token header eyJhbGciOiJIUzI1NiJ9 is just {'alg':'HS256'} in Base64. Use our JSON Formatter to inspect decoded JWT payloads.
CSS background images. Small background images, patterns, and gradients can be inlined as Base64 data URIs in CSS files: background-image: url("data:image/svg+xml;base64,..."). This reduces HTTP requests and ensures the background loads with the stylesheet.
Base64 vs Base64URL
Standard Base64 uses +, /, and = characters. These characters have special meanings in URLs: + represents a space, / is a path separator, and = is used in query strings. Embedding standard Base64 in a URL therefore requires percent-encoding these characters, making the URL longer and harder to read.
Base64URL solves this by substituting + with -, / with _, and omitting or replacing = padding (this tool uses ~). The result is a Base64 string that can be safely included in URLs and filenames without encoding. JWTs, OAuth tokens, and URL-safe identifiers all use Base64URL. Toggle the “URL-safe” option in this tool to switch between the two variants.
File Size Increase with Base64
Base64 encoding increases the size of data by approximately 33–36%. This happens because every 3 bytes of binary data are represented as 4 ASCII characters (a 4/3 = 1.333× increase), plus padding characters and any line breaks added by the encoder. A 1 MB image becomes approximately 1.37 MB when Base64-encoded.
This size increase has practical implications. Base64 data URIs in HTML and CSS increase page weight. Base64-encoded API payloads are larger than equivalent binary uploads. Email attachments are heavier than the original files. For performance-critical applications, only use Base64 for small assets (under ~10 KB) where the elimination of an extra HTTP request outweighs the size penalty.
Frequently Asked Questions
Is Base64 encoding the same as encryption?
No. Base64 is a reversible encoding scheme with no security properties. Any Base64 string can be decoded instantly without a key or password. For actual security, use AES encryption. Base64 only makes binary data safe for text channels — it does not protect the data.
Why does my Base64 string end with == or =?
Base64 works on groups of 3 bytes at a time. If your input is not a multiple of 3 bytes, padding characters (=) are added to complete the final group. One padding character means the last group had 2 bytes; two padding characters means it had 1 byte. Padding can be stripped in systems that know the original length.
What is the maximum file size I can encode?
This tool supports files up to 10 MB. Larger files can be encoded in principle but may cause browser performance issues since the entire file is held in memory as a JavaScript string. For very large files, use a command-line tool: base64 -i input.bin -o output.txt on macOS/Linux.
Can I decode an image from Base64 to view it?
If the Base64 string represents an image and you have its MIME type, paste the full data URI (data:image/png;base64,...) directly into a browser address bar to view the image. Our tool decodes Base64 text back to the original text — for binary files, you would need a specialized tool that reconstructs the binary from the decoded bytes.
What characters are valid in a Base64 string?
Standard Base64 uses only: A–Z, a–z, 0–9, +, /, and = (padding). Any other character in a supposed Base64 string indicates it is either corrupt, URL-encoded, or using a variant like Base64URL. If you see - and _, it is Base64URL — enable the URL-safe toggle before decoding.
How do I use Base64 to embed an image in HTML?
Upload your image in the File tab, enable “Data URI mode,” click Convert, and copy the output. Use it directly as an img src: <img src="data:image/png;base64,..." alt="..." />. The image loads with the HTML page — no separate HTTP request. Best for small images under 10 KB.
What is the difference between btoa() and atob() in JavaScript?
btoa() (binary to ASCII) encodes a binary string to Base64. atob() (ASCII to binary) decodes a Base64 string back to binary. Both are built into browsers. For Unicode text, you need to encode to UTF-8 bytes first: btoa(unescape(encodeURIComponent(str))) — which is exactly what this tool does internally.
Keep going
Related Tools
URL Encoder / Decoder
Encode and decode URLs, and parse URL components including query parameters
HTML Entity Encoder / Decoder
Encode and decode HTML entities, plus a complete entity reference table
UUID Generator
Generate UUID v1, v4 and v7 identifiers in bulk with multiple formats
Hash Generator
Generate MD5, SHA-1, SHA-256, SHA-512 hashes from text or files
JWT Decoder
Decode and inspect JWT tokens — view header, payload and expiration
Password Generator
Generate strong, random passwords with custom length and character options
CSS Box Shadow Generator
Visually create CSS box shadows with live preview and multi-layer support
Image to Base64 Converter
Convert any image to a Base64 data URI for embedding in HTML, CSS, or code