Developer ToolsFeatured2026-05-10

How to Use a Base64 Encoder Decoder – Encode & Decode Data Online

Base64 encoding is one of those technologies that sits invisibly in the background of nearly every web application you use, yet few developers fully understand how it works or when to use it correctly. At its core, Base64 is a binary-to-text encoding scheme that converts arbitrary binary data—images, PDF files, audio bytes, encryption outputs—into a string of 64 printable ASCII characters (A-Z, a-z, 0-9, +, and /, with = for padding). The purpose is simple: many systems, protocols, and data formats are designed to handle text only, and binary data would break them. Email attachments travel through SMTP servers that expect 7-bit ASCII text—Base64 bridges the gap. JSON APIs cannot embed raw binary bytes—Base64 encodes them into a JSON-safe string. HTML and CSS data URIs let you embed small images directly in markup without a separate HTTP request—Base64 makes that possible. Our free online Base64 encoder and decoder handles both text-to-Base64 and Base64-to-text conversions, supports file uploads for encoding images and documents, automatically detects URL-safe Base64 (which replaces + with - and / with _ for use in URLs and filenames), and runs every operation entirely in your browser. Zero data is uploaded to any server, making it safe for proprietary files, sensitive documents, and personal data. But understanding Base64 requires knowing its limitations: it is encoding, not encryption (anyone can decode it instantly), it increases data size by approximately 33%, and it is impractical for files larger than about 1 MB. This article explains what Base64 actually is, when to use it, and how to avoid the most common mistakes developers make with it.

code

Base64 Encoder / Decoder

Free · No registration

Try this tool for free →open_in_new

Step-by-Step Guide

1

Choose Encode Mode or Decode Mode Based on Your Goal

Select the "Encode" tab to convert plain text or binary file data into a Base64 string. The encoding process takes your input, divides it into 6-bit groups, and maps each group to one of 64 ASCII characters according to the Base64 index table (A=0, B=1, ..., Z=25, a=26, ..., z=51, 0=52, ..., 9=61, +=62, /=63). If the input length is not a multiple of 3 bytes, one or two = padding characters are appended to make the output length a multiple of 4 characters. Select the "Decode" tab to reverse the process—converting a Base64 string back into its original text or binary form. For encoding, you can either type or paste plain text directly into the input field, or upload a file (images, PDFs, documents, audio files, etc.). The file is read locally in your browser using the FileReader API and never transmitted anywhere. For decoding, paste the Base64 string you want to convert back. The tool automatically detects whether the input is standard Base64 (using + and /) or URL-safe Base64 (using - and _) and handles both variants without manual configuration.

2

Provide Your Input and Configure Optional Settings

If encoding text, type or paste your string into the input area—the tool accepts any text including Unicode characters, emoji, and special symbols. If encoding a file, upload it using the file picker; the tool accepts files up to 1 MB, which is the practical ceiling for Base64 encoding given that the output will be roughly 33% larger than the input. For decoding, paste the Base64 string into the input field. The tool strips any whitespace or line breaks from the pasted string automatically, so you can paste multi-line Base64 output from other tools without pre-processing. If you need URL-safe output (for use in URLs, JSON Web Tokens, or filenames), enable the URL-safe toggle—this replaces the standard + character with - and / with _, and optionally omits the = padding (since = has special meaning in URL query strings). The character count of both input and output is displayed in real time so you can verify the expected 33% size increase when encoding and confirm successful decoding when the decoded size matches expectations.

3

Copy the Output or Download the Decoded File

After encoding, click "Copy" to copy the full Base64 string to your clipboard. The output is a single continuous string (no line breaks) by default, matching what you would get from the btoa() JavaScript function or the base64 command-line utility. For decoded text output, the original string is displayed and copyable. For decoded binary files (images, PDFs, etc.), do not paste the decoded output into a text editor—binary bytes will appear as garbled characters. Instead, use the "Download as file" button to save the decoded binary data as a proper file with the correct extension. The tool preserves the original MIME type information when available, so a decoded PNG image will download as a .png file that opens correctly in any image viewer. For developers working with data URIs, the tool can prepend the appropriate MIME type prefix (e.g., data:image/png;base64,) so you can copy the complete data URI directly into HTML src attributes or CSS url() values. For JWT inspection, paste a JSON Web Token's second segment (the payload between the first and second dots) to decode and inspect the token's claims.

Tips & Best Practices

check_circle

Base64 encoding increases data size by exactly 33.3% (4/3 ratio). Every 3 bytes of binary input produce 4 bytes of Base64 output. A 150 KB image becomes a 200 KB Base64 string. For files over 100 KB, the size penalty nearly always outweighs the convenience of embedding—use a regular file URL instead of a data URI.

check_circle

Base64 is encoding, not encryption. Anyone who sees a Base64 string can decode it instantly—there is no key, password, or secret involved. Never use Base64 to protect passwords, API keys, or sensitive user data. If security matters, use AES-256-GCM or a similar authenticated encryption algorithm, then optionally Base64-encode the encrypted binary output for text-safe storage or transmission.

check_circle

For JWT (JSON Web Tokens), each segment (header, payload, signature) is Base64URL-encoded independently. The format is header.payload.signature, with each part separated by a dot. Paste the middle segment into our decoder to inspect the token's claims (user ID, expiration time, issuer, scopes) without needing a JWT library.

check_circle

When embedding images in HTML or CSS as data URIs, always specify the correct MIME type: data:image/png;base64, for PNG images, data:image/jpeg;base64, for JPEGs, or data:image/svg+xml;base64, for SVG. An incorrect MIME type causes the browser to misinterpret the binary data and display a broken image. For SVG, consider using the text-based data:image/svg+xml, format instead of Base64—it is smaller and human-readable.

check_circle

URL-safe Base64 replaces the + character with - and / with _ to make the encoded string safe for use in URLs, query string parameters, and filenames without percent-encoding. Standard + and / have special meanings in URL contexts (+ represents a space in query strings, / is the path separator). Always use URL-safe Base64 when embedding encoded data in a URL.

check_circle

Do not Base64-encode files larger than 1 MB. Beyond that threshold, the 33% size increase plus browser memory overhead makes encoding slow and produces unwieldy strings hundreds of thousands of characters long. For large files, use multipart/form-data uploads, direct file URLs, or cloud storage object URLs instead.

check_circle

Hex encoding (Base16) is an alternative to Base64 that uses 16 characters (0-9, A-F) and doubles the data size (100% overhead vs Base64's 33%). Use Base64 when you need compact text representation of binary data. Use hex when you need byte-level readability for debugging—each byte becomes exactly two hex characters, making it easy to inspect individual bytes.

check_circle

The = padding characters at the end of a Base64 string indicate how many bytes of the final 3-byte block were missing in the original data. One = means 2 bytes of padding (input was 1 byte short of a full block). Two == means 4 bytes of padding (input was 2 bytes short). A Base64 string with no = has an input length that was exactly divisible by 3. The padding is mathematically required for decoding but can be omitted in URL-safe contexts if the decoder infers the correct length.

check_circle

In email systems, Base64 is used by the MIME (Multipurpose Internet Mail Extensions) standard to encode binary attachments within the text-based email format. When you attach an image or PDF to an email, your email client Base64-encodes the file and wraps it in MIME headers that tell the recipient's client what the original file type was and how to decode it. This is the same Base64 encoding you see in raw email source with Content-Transfer-Encoding: base64 headers.

Frequently Asked Questions

Base64 is a binary-to-text encoding method that converts arbitrary binary data (images, files, bytes) into a string of 64 printable ASCII characters: uppercase letters A-Z, lowercase letters a-z, digits 0-9, and the symbols + and /, with = used for padding. It is used whenever binary data must travel through systems designed for text only. The most common use cases are: embedding images directly in HTML/CSS via data URIs (avoiding extra HTTP requests for small icons and logos), encoding binary data inside JSON and XML API payloads (since JSON cannot hold raw bytes), attaching files to emails via the MIME standard (SMTP servers historically only supported 7-bit ASCII text), storing binary data in text-based databases or configuration files, and encoding the payload segments of JSON Web Tokens (JWTs). Base64 is universal—every programming language has built-in or library support for it—and its 64-character alphabet was specifically chosen to avoid characters that have special meaning in text protocols.

Base64 encoding bridges the gap between binary data and text-only systems—it powers data URIs, email attachments, JWT tokens, and API payloads across the web. Understanding its mechanics, limitations, and security implications makes you a more effective developer. Our free tool handles encoding and decoding in both standard and URL-safe variants, runs entirely in your browser, and works with text and files. Bookmark it for your next data URI, JWT inspection, or binary encoding task. Try it now: paste any text or upload any file and see the Base64 output instantly.

Try this tool for free →open_in_new