Base64 converter (text & file)
Encode/decode Base64 for text and files. URL‑safe mode, padding control, Data URI support, and large-file processing — fully in your browser.
About this Base64 tool
Base64 is one of those technical curiosities that ends up touching every developer's life eventually, usually in a context where the underlying concept (binary data encoded as ASCII text) is less important than the specific encoding details that the receiving system happens to require. The standard Base64 alphabet uses 64 characters — A-Z, a-z, 0-9, +, / — to represent 6 bits of binary data per character, with = signs at the end as padding. The variants (URL-safe Base64 substitutes - and _ for + and /, MIME Base64 wraps lines at 76 characters, no-padding variants drop the trailing = signs, and so on) all use the same fundamental encoding but disagree on the surface details. When two systems use different variants, the encoded data appears identical but doesn't decode cleanly between them, which is the source of an entire category of frustrating debugging sessions.
The most common everyday use of Base64 is embedding binary data in text-based protocols where binary doesn't transmit cleanly. Email attachments use Base64 internally because SMTP was designed for ASCII text and binary data needs a textual representation to survive the trip. Data URIs (the data:image/png;base64,...... scheme used to embed images directly in CSS or HTML) use Base64 to put binary image data inside text-based markup. JSON Web Tokens use Base64-URL to put binary cryptographic signatures inside text-based authentication tokens. HTTP Basic auth uses Base64 to put a username:password string inside an HTTP header. The pattern is always the same: a textual transport meets binary content, and Base64 bridges them.
Encoding text to Base64 has a UTF-8 nuance that catches people regularly. The string 'café' contains four characters but five bytes when encoded as UTF-8 (the é takes two bytes). Base64-encoding the string produces a different result depending on whether the encoder treats the input as a sequence of characters (some implementations) or as a sequence of bytes (correct implementations). The path here treats input as UTF-8 bytes, which is the consistent and correct behaviour, and the encoded output decodes cleanly back to the original UTF-8 string regardless of which non-ASCII characters were involved. For ASCII-only input the distinction doesn't matter; for international text it absolutely does.
URL-safe Base64 is the variant most often needed for web work. The standard alphabet uses + and / characters, both of which have special meanings in URLs (+ is sometimes interpreted as a space, / is the path separator), so encoded data containing those characters needs additional URL-encoding before it can travel safely in a URL. URL-safe Base64 sidesteps this by substituting - and _ in place of + and /, producing output that's directly safe to drop into a URL parameter without further escaping. JWT tokens use URL-safe Base64 specifically because they're designed to travel through URLs and headers; modern web frameworks generally default to URL-safe variants for similar reasons.
Padding is the third axis of variation worth understanding. Standard Base64 pads encoded output to a multiple of 4 characters using = signs at the end (so a 1-byte input becomes 4 characters: 2 data + 2 padding, a 2-byte input becomes 4 characters with 1 padding sign, a 3-byte input becomes 4 characters with no padding). Some systems, particularly in cryptography contexts, drop the padding because it carries no information beyond what the length of the encoded string already implies. The decoder needs to know whether to expect padding or not — feeding padded input to a strict no-padding decoder produces an error, and vice versa. The flexible decoder here accepts both forms.
File-to-Base64 conversion is the case that distinguishes a complete tool from a text-only one. Encoding a file as Base64 produces a long string that can be embedded in JSON payloads, configuration files, or other text-based contexts where the underlying binary needs to travel. Decoding Base64 back to a file is the reverse: the encoded string becomes a downloadable file with the original bytes preserved. For developers building data:URIs for prototype work, encoding test fixture files for CI configurations, or troubleshooting why a Base64 payload doesn't decode correctly, having both directions in one tool with predictable behaviour matters.
Performance characteristics worth knowing because Base64 is occasionally used at scale. Encoding is roughly 33% size growth — a 100-byte input becomes a 136-byte encoded output, plus padding. The cost is straightforward and unavoidable; if compactness matters, Base64 is the wrong tool and binary protocols are the right one. The browser-based implementation here handles inputs of several megabytes without issue, runs in chunks for very large inputs to keep the UI responsive, and operates entirely client-side so no data ever leaves the browser. For genuinely huge inputs (hundreds of megabytes or more), command-line tools are faster, but for everyday development work the browser implementation is more than adequate.
Common pitfalls deserve a separate mention because they're the source of most Base64 debugging sessions. Whitespace in encoded data is the classic gotcha — Base64 strings copied from emails, terminal output, or PDF files often pick up newlines, spaces, or invisible Unicode characters that confuse strict decoders. The decoder here strips whitespace by default, which makes it forgiving against the most common copy-paste corruption mode. Another pitfall is the URL-encoded plus sign: a Base64 string in a URL parameter sometimes has its + characters automatically decoded to spaces by the receiving system, which corrupts the encoded data; URL-safe Base64 avoids this entire class of problems.
Security context matters when working with Base64. The encoding is not encryption — anyone who sees a Base64 string can decode it back to its original content with a single function call, and there's no key or password involved. Encoded passwords or secrets in Base64 form are exactly as exposed as if they were in plain text, just slightly less obvious to a casual viewer. The encoding is for transport, not for protection, and treating Base64 as a security mechanism is one of the most common confusion points for developers new to the format. If actual confidentiality is needed, the data should be encrypted (with a real key) before being Base64-encoded for transport.
Operationally the tool is one workspace with text and file modes side by side. Paste text or drop a file, choose encode or decode, configure the variant (standard or URL-safe, with or without padding), see the result update in real-time, copy or download. Files are processed entirely in the browser, never uploaded, never stored. Multiple inputs can run through the same session — useful when working through a series of related encoding tasks rather than handling a single one-off case. The interface remains responsive on inputs of several megabytes; for genuinely huge inputs (hundreds of megabytes) the browser tab will struggle, but for everyday development work the response is essentially instant.
Common API integrations where this tool earns regular use are predictable. SMS gateway providers often use Basic auth with Base64-encoded credentials in the Authorization header. Payment gateway sandboxes typically expect Base64-encoded webhook payloads or signature blocks. Cloud storage providers (S3, Google Cloud Storage) accept Base64-encoded checksums in their upload protocols. Public-facing webhook receivers sometimes wrap the body content in Base64 to preserve binary data through JSON transport. For developers integrating with any of these, having a quick way to encode test inputs and decode responses without leaving the browser tab is a meaningful workflow accelerator.
There's a subtle thing about line wrapping worth knowing because it bites occasionally. The MIME variant of Base64 wraps lines at 76 characters with a CRLF line ending, which is the format you'll see in raw email source. Some systems strictly require this wrapping and reject unwrapped Base64; other systems strictly require unwrapped output and reject anything with embedded line breaks. The tool here can produce output in either form, defaulting to unwrapped because that's the more common modern preference, but the option is there for legacy systems that still need MIME-style wrapping. A small detail, but the kind of detail that turns a five-minute integration into a two-hour debugging session if you don't know to look for it.
Use cases
Base64 is often used to transport credentials in formats like HTTP Basic Auth, but it’s not encryption. Use it to encode bytes for transfer, and rely on TLS + proper secrets handling for security.
Need to embed a small icon into HTML/CSS? Convert a PNG/JPG/SVG to Base64 and optionally output a ready-to-use data:mime/type;base64,... Data URI.
Many APIs return files as Base64. Paste the response, fix whitespace/newlines if needed, and download the decoded file with the correct name and extension.
JWT segments are URL‑safe Base64 without padding. Toggle URL‑safe output and padding control when you’re generating or debugging token-like strings.
Base64 copied from emails, logs, or terminals often includes line breaks. Use “Remove whitespace”, “Fix URL‑safe”, and “Add padding” to normalize inputs.
Base64 increases size by roughly 33%. Use the byte/char counters to estimate payload size before embedding in JSON, query strings, or Data URIs.
Common problems & fixes
If you see an invalid character error, the string likely contains non‑Base64 characters (quotes, commas, or copied markup). Trim the input and remove whitespace.
Some systems omit '=' padding. If strict padding is enabled, add the missing padding or turn strict mode off.
If the input uses '-' and '_' but your decoder expects '+' and '/', use the “Fix URL‑safe” helper or enable URL‑safe handling.
Data URIs start with data:...;base64,. The tool auto-detects them and extracts the Base64 part so you can decode correctly.
If the Base64 represents a binary file, decoding to text will fail. Switch to File mode and download the bytes as a file.
For big strings and files, enable whitespace handling only when necessary, and let the Web Worker finish—your browser stays responsive during processing.
Examples
Hello, Omnvert! 👋🌍\nBase64 is not encryption.
SGVsbG8sIE9tbnZlcnQhIPCfkYvwn4yNCkJhc2U2NCBpcyBub3QgZW5jcnlwdGlvbi4
data:text/plain;base64,SGVsbG8sIE9tbnZlcnQhIPCfkYvwn4yNCkJhc2U2NCBpcyBub3QgZW5jcnlwdGlvbi4=
FAQ
Is Base64 encryption?
No. Base64 is an encoding used to represent bytes as ASCII text. It does not hide or protect the content.
Why does Base64 get bigger?
Base64 expands data by about 33% (4 characters for every 3 bytes), plus optional Data URI prefixes.
Can I decode Base64 that contains newlines or spaces?
Yes. Enable the “Allow spaces/newlines” option, or use the “Remove whitespace” helper.
What is URL‑safe Base64?
URL‑safe Base64 replaces “+” and “/” with “-” and “_” so the string works better in URLs, JWTs, and web tokens.
What does padding '=' mean?
Padding makes Base64 length a multiple of 4. Some systems require it; others omit it (common for URL‑safe tokens).
I get “invalid padding” — how do I fix it?
Try removing whitespace, converting URL‑safe characters back to standard, or adding missing '=' padding.
Why does Base64 decode to “invalid UTF‑8”?
The Base64 content may be a binary file (image/pdf/zip), not text. Use File mode to decode and download it as a file.
Can I convert a file to a Data URI?
Yes. In File → Base64 mode, enable “Output as Data URI” to get a string like data:mime/type;base64,...
Do you upload my text or file?
No. This tool runs fully in your browser; nothing is uploaded.
Can it handle large files (50MB+)?
Yes. Large inputs are processed in a Web Worker with chunking to keep the UI responsive.