Is Base64 the same as encryption?
No. Base64 is encoding, not encryption. It converts binary data to printable ASCII text for safe transmission through text-only protocols. Anyone can decode it instantly — it provides no security or confidentiality. For security, use HTTPS for transmission and AES-256 encryption for data at rest.
What is the difference between Base64 and Base64URL?
Standard Base64 uses A–Z, a–z, 0–9, +, and /. URL-safe Base64 (Base64URL) replaces + with - and / with _ to avoid characters that have special meaning in URLs and HTTP headers. JWTs use Base64URL for their header and payload sections. Use URL-safe Base64 whenever embedding the output in a URL, cookie, or JWT.
Why does Base64 output end with = or ==?
Base64 processes input in 3-byte groups. When input length is not a multiple of 3, the final group is padded to produce a complete 4-character block. One = means one padding byte was added; == means two were added. The total output length is always a multiple of 4 characters.
Can Base64 encode binary files, not just text?
Yes. Base64 encodes any binary data — images, PDFs, audio, executables. The output is always ASCII text regardless of input type. Binary content produces valid Base64 but the decoded output must be handled as binary (saved as a file), not displayed as text in a text area.
Why does my decoded output look like gibberish?
The encoded input is likely a binary file (image, PDF, zip archive) rather than text. Base64 encodes any binary data, but displaying binary bytes as text produces unreadable characters. Download the decoded output as a file rather than reading it as text.
What is the size overhead of Base64 encoding?
Base64 output is always approximately 33% larger than the input. Every 3 bytes of input produces 4 Base64 characters. Including line breaks (MIME format adds one every 76 characters), the overhead rises slightly to about 37%. If file size matters, compress the data first.
How do I encode a file to Base64 in JavaScript?
Use the FileReader API: reader.readAsDataURL(file) gives a data URI with Base64 content after the comma. For just the Base64 string without the data: prefix, use FileReader.readAsArrayBuffer() then convert the array buffer to Base64 manually, or use a library like js-base64.
What is a Base64 data URI?
A data URI embeds file content directly in an HTML src or CSS url() attribute: data:image/png;base64,iVBOR.... The browser decodes and displays it without a separate HTTP request. Best used for small files (under 10 KB) — larger files increase HTML size and block rendering.
How do I decode Base64 in Python?
Use the base64 module: import base64; decoded = base64.b64decode('SGVsbG8=').decode('utf-8'). For URL-safe Base64, use base64.urlsafe_b64decode(). Always call .decode('utf-8') after b64decode to get a string from bytes. If the input has missing padding, add = characters: base64.b64decode(s + '==') safely handles most cases.
How do I decode Base64 in JavaScript?
Use atob() for standard Base64: const text = atob('SGVsbG8='); // 'Hello'. For URL-safe Base64 (used in JWTs), replace - with + and _ with / first: atob(base64url.replace(/-/g, '+').replace(/_/g, '/')). For binary data or files, use Uint8Array from atob() output or the browser FileReader API.
What is Base64 used for in JWT tokens?
JWT (JSON Web Token) uses Base64URL encoding (a URL-safe variant) to encode the header and payload sections. The format is header.payload.signature — each dot-separated part is independently Base64URL-encoded. The payload contains JSON claims (sub, exp, iat, etc.). Decoding the middle section gives you readable JSON without needing the signing secret. Paste a JWT into the JWT Decoder to inspect claims directly.
Can I encode an image to Base64 for use in HTML?
Yes. Drop your image into this tool and get the full data URI string: data:image/jpeg;base64,/9j/4AA.... Copy it into an HTML img src attribute: <img src="data:image/jpeg;base64,..." />. This embeds the image directly in your HTML without a separate server request. Best for icons and small images under 10 KB; larger images slow down page load because they block HTML parsing.
How do I encode a space or special characters in Base64?
Base64 handles all byte values including spaces — there is no special treatment needed. The input is converted to bytes first (via UTF-8 encoding), then every 3 bytes become 4 Base64 characters. A space character (0x20) is encoded as part of the byte stream normally. The issue arises if you need to embed Base64 output inside a URL — in that case, use URL-safe Base64 (replace + with - and / with _) so the encoded string doesn't break URL parsing.
Why does the same input produce different Base64 output sometimes?
Standard Base64 is deterministic — identical input always produces identical output. However, if the character encoding changes (UTF-8 vs Latin-1 vs Windows-1252), the underlying bytes differ and the Base64 output changes. This tool always uses UTF-8 encoding. If your Base64 output differs from another tool's output, check whether both are encoding the input text in the same character set.