Text and data

Base64, both ways

Paste text to encode it, paste Base64 to decode it, or drop in a file to get a data URI. The direction is worked out from what you give it, and the UTF-8 and URL-safe details that trip up most converters are handled rather than assumed away.

On this device

Paste or drop

Text goes in the box; a file can be dropped below it. Whichever you use, the conversion runs here.

The direction is worked out from what you paste, and shown below. Change it whenever the guess is wrong.

    Opened on this device · never transmitted

    What this tool does, exactly

    Both alphabets
    Standard Base64 uses + and /, which have their own meanings in a URL and get mangled when one is pasted into a browser. The URL-safe variant uses - and _ instead. Both are decoded automatically, whichever arrives, and either can be chosen when encoding.
    UTF-8 done properly
    The classic Base64 bug is text that survives the round trip in English and breaks on an accent, an emoji or any non-Latin script, because the encoder treated characters as bytes. Text here is encoded as UTF-8 and decoded as UTF-8, so anything you can type comes back exactly as you typed it.
    Files and data URIs
    Drop in a file and you get its Base64, and optionally a complete data: URI with the right media type on the front — the form you can paste straight into HTML or CSS. Paste a data URI back and it is recognised, the file recovered, and offered as a download with its type intact.
    The size goes up, not down
    Base64 is an encoding, not compression: it represents three bytes with four characters, so anything you encode gets about a third larger. It exists to move binary data through channels that only carry text, and it is worth knowing before you paste a two-megabyte image into a stylesheet.
    Padding is tolerated, not demanded
    Base64 that has lost its trailing = signs is extremely common and perfectly decodable. It is decoded rather than rejected. Whitespace and line breaks inside the input are ignored too, so pasting a wrapped block out of an email or a certificate works.

    About this tool

    Is Base64 a form of encryption?

    No, and treating it as one is a real and common mistake. It is a reversible encoding with no key and no secret — anybody can decode it instantly, including this page, which is exactly what it is doing. It hides nothing. If something needs to be unreadable to others, it needs encryption; Base64 only makes binary data survive a text-only channel.

    Why did my text come back with strange characters?

    Almost always a UTF-8 problem in whatever produced the Base64: non-ASCII characters were encoded one byte at a time as though they were Latin-1. This decoder reads UTF-8 correctly, so if the result still looks wrong, the original encoding was lossy and the characters were damaged before they got here.

    What is the URL-safe variant, and when do I need it?

    Standard Base64 uses + and / , which mean other things inside a URL and get rewritten or broken when a value is passed as a query parameter or a path segment. The URL-safe alphabet swaps them for - and _ . You need it whenever the result will travel in a URL — JWTs use it for exactly this reason. Decoding here accepts either without being told which.

    Can I convert an image to Base64 for use in CSS?

    Yes — drop the image in and take the data URI, which is the complete string including the media type prefix, ready to paste into a stylesheet or an img tag. Bear in mind it will be about a third larger than the file, and that a large image inlined this way cannot be cached separately by the browser.

    Is there a size limit?

    Only your device's memory, because the conversion happens in this tab. Files of a few megabytes are unremarkable; a very large file on a phone may not be. There is no server-side limit because there is no server.

    More text and data tools · All 25 · How they work