Skip to main content

    Base64 Encoder & Decoder

    Encode text to Base64 or decode Base64 back to text. Supports UTF-8 and Unicode.

    Free to use. Runs in your browser.

    Paste text or a file and click Encode to get Base64 output, or paste Base64 and click Decode to recover the original. Works offline, your data never leaves your browser.

    What Is Base64 and When Do You Need It?

    Base64 is a way of representing binary data using only text characters. It converts raw bytes into a string of letters, numbers, plus signs, and slashes, characters that survive being passed through systems that only handle text (like email, JSON, or HTML).

    Think of it like spelling out a phone number in words: "oh-seven-seven-oh" instead of 0770. The information is the same, just represented in a text-safe format. The trade-off? Base64 output is about 33% larger than the original data. That's the cost of text-safety.

    Important: Base64 is encoding, not encryption. Anyone can decode it instantly. Never use Base64 to "hide" passwords, tokens, or sensitive data, it provides zero security.

    Common Base64 Use Cases

    Use CaseWhy Base64?Example
    Data URIs in HTML/CSSEmbed small images directly in code<img src="data:image/png;base64,...">
    Email attachments (MIME)SMTP only handles 7-bit ASCII textContent-Transfer-Encoding: base64
    JSON payloadsJSON can't contain raw binary{"file": "SGVsbG8..."}
    JWT tokensHeader and payload are Base64URL encodedeyJhbGciOiJIUzI1NiJ9...
    HTTP Basic AuthCredentials encoded (not encrypted!)Authorization: Basic dXNlcjpwYXNz
    SVG in CSSInline SVG backgrounds without extra requestsbackground: url("data:image/svg+xml;base64,...")

    What this means for you: If you're embedding small icons (under 2KB) in CSS, Base64 data URIs save HTTP requests. For anything larger, a regular image file with proper caching is more efficient.

    Base64 vs Other Encodings

    EncodingCharacters UsedSize OverheadBest For
    Base64A-Z, a-z, 0-9, +, /+33%Binary data in text contexts
    Base64URLA-Z, a-z, 0-9, -, _+33%URLs, JWTs (no +/= characters)
    Hex0-9, a-f+100%Hash digests, colour codes
    URL encoding%XX formatVariableSpecial characters in URLs

    Common Base64 Mistakes

    Mistake

    Using Base64 for "security". Base64 is trivially reversible. Encoding a password or API key in Base64 provides zero protection. Use proper encryption (AES) or hashing (bcrypt) for sensitive data.

    Mistake

    Base64-encoding large images in CSS. A 50KB image becomes 67KB as Base64, and it can't be cached separately from the stylesheet. Only inline images under 2KB, anything larger should be a regular file with HTTP caching.

    Mistake

    Mixing Base64 and Base64URL. Standard Base64 uses + and / which break in URLs. JWTs use Base64URL (with - and _ instead). Decoding one with the other's alphabet produces garbage. Check which variant you need.

    Related Tools

    How to use this tool

    1

    Enter text or Base64 string in the input

    2

    Click Encode or Decode

    3

    Copy the result or swap input/output

    Common uses

    • Embedding small images in HTML/CSS as data URIs
    • Encoding binary data for JSON payloads
    • Decoding JWT token components
    • Preparing email attachments for MIME transport
    • Converting files for inline SVG backgrounds

    Share this tool

    Frequently Asked Questions

    What is Base64 encoding?
    Base64 is a binary-to-text encoding scheme that represents binary data using only ASCII characters (A-Z, a-z, 0-9, +, /). It's how email attachments travel through SMTP, how small images get embedded in CSS, and how JWT tokens encode their header and payload. The trade-off is a 33% size increase.
    Is Base64 encryption?
    No, and this is a critical distinction. Base64 is encoding, not encryption. Anyone can decode it instantly with zero effort. Never use Base64 to 'hide' passwords, API keys, or sensitive data. It provides exactly zero security. Use it for data transport only.
    Does this tool support Unicode and emojis?
    Yes. We use TextEncoder/TextDecoder to properly handle UTF-8 characters, including emojis, CJK characters, Arabic, and other non-Latin scripts. Standard btoa() breaks on Unicode, our implementation handles it correctly.
    What's the difference between Base64 and Base64URL?
    Standard Base64 uses + and / characters, which have special meaning in URLs. Base64URL replaces them with - and _ and removes padding (=). JWTs use Base64URL, not standard Base64. This tool uses standard Base64 encoding.
    Why does Base64 make data 33% larger?
    Base64 converts every 3 bytes of input into 4 ASCII characters. Three bytes = 24 bits, divided into four 6-bit groups, each mapped to one of 64 characters. That 4/3 ratio means roughly 33% size overhead, the cost of text-safety.
    When should I use Base64 data URIs vs regular images?
    Use Base64 data URIs for tiny images under 2KB, icons, simple SVGs, 1x1 tracking pixels. For anything larger, a regular image file with proper HTTP caching is more efficient. A 10KB image becomes ~13.3KB in Base64 and can't be cached separately.
    How do I Base64 encode in JavaScript?
    For ASCII text: btoa('hello') gives 'aGVsbG8='. For Unicode: use TextEncoder to get bytes first, then btoa(). To decode: atob('aGVsbG8=') returns 'hello'. Node.js uses Buffer.from('hello').toString('base64') instead.
    Can I encode files and images to Base64?
    This tool encodes text to Base64. For files and images, you'd use FileReader.readAsDataURL() in JavaScript, or the command line: base64 image.png on macOS/Linux, or [Convert]::ToBase64String() in PowerShell.
    What characters are valid in Base64?
    Standard Base64 uses 64 characters: A-Z (26), a-z (26), 0-9 (10), + and / (2), plus = for padding. If your Base64 string contains any other character, it's invalid and will fail to decode.
    Why is Base64 used in email (MIME)?
    SMTP (email protocol) was designed for 7-bit ASCII text only. Binary attachments, images, PDFs, zip files, can't survive the journey. Base64 converts them to text that SMTP can handle, then the recipient's email client decodes them back.
    Is my data sent to a server?
    No. All encoding and decoding happens entirely in your browser using JavaScript's built-in btoa() and atob() functions. Your data never leaves your device, check the network tab in DevTools if you want proof.
    What's the maximum size I can encode?
    There's no hard limit in this tool, but browsers have practical limits. Most modern browsers handle strings up to several hundred MB. For very large files, use a streaming encoder or command-line tool instead.

    Results are for general informational purposes only and should be checked before use. They are not professional advice. See our Disclaimer and Terms of Service.