Base64 Encoder and Decoder

Encode text or a file as Base64, or decode an image data URI with a preview.

Files stay on your device No sign-up Free to use
How this works

The tool runs in this browser. Your file or text is not uploaded to UseFreeTools. Check this tool's limits for anything it may save on your device.

Privacy details

Convert the value controls

Showing an example. Edit to see your own.

Paste text to encode or Base64 to decode. Leave this empty if you choose a file. Whitespace in Base64 is ignored.

Used when encoding. Decoding accepts either alphabet.

Drop your file here

or choose one from your device

Choose one file up to 12 MiB. Encoding produces a .txt download; decoding saves bytes as a .bin download.

    Adds the verified image type before the Base64 text. PNG, JPEG and WebP only.

    Processed in your browser. Your inputs stay on this device.

    How to use Base64 Encoder and Decoder

    1. Set Conversion to Text or file to Base64, or to Base64 to text or file.
    2. Pick a Base64 variant: standard, URL-safe or MIME.
    3. Paste text in Input, or choose one file up to 12 MiB. For an image file, you can turn on the data URI option.
    4. The converted value updates as you change the input. Copy the text or download the result.

    Example: Base64 Encoder and Decoder

    Encode a small PNG as an image data URI, then decode that value back to the image.

    You add
    Conversion: Text or file to Base64. Base64 variant: Standard. File: a small PNG. Make an image data URI when encoding an image file: on. Then set Conversion to Base64 to text or file and paste the printed value into Input.
    You get
    The encode result starts with data:image/png;base64, and offers an encoded-base64.txt download. Decoding the same value reports the decoded size as a PNG image, shows the preview and offers decoded.png.

    Options

    Conversion
    Encode turns text or a file into Base64. Decode turns Base64 back into text or a file. The decoder reads either alphabet, so the variant need not match the pasted value.
    Base64 variant
    Standard keeps + and /. URL-safe uses - and _ and drops padding. MIME keeps the standard alphabet and wraps long output for email.
    File (optional)
    One file up to 12 MiB. Encoding gives a .txt download. Decoding a recognized image uses its image extension; unknown binary stays .bin. Leave this empty when you paste text.
    Make an image data URI when encoding an image file
    When you encode a file, this includes its media type before the Base64 text, as in data:image/png;base64,... . Use the plain Base64 option if the receiving app expects only the encoded characters.

    Supported inputs and limits

    One run takes up to 5,000,000 characters of text or one file up to 12 MiB. Standard output keeps its = signs, URL-safe output drops them, and MIME output keeps them and breaks every 76 characters. Decoding ignores whitespace and accepts missing padding. Recognized image bytes get an image preview and extension; unknown binary stays .bin. An image data URI whose declared type conflicts with its real signature is rejected. Base64 is encoding, not encryption, and anyone can reverse it.

    Where your input is processed

    This tool processes your input in this browser. Your text and files are not uploaded to UseFreeTools. Check this tool's limits for anything it may save on your device.

    Three variants write three different strings

    The same bytes produce different text depending on the variant, and the difference is small enough to cause real bugs. Standard and MIME share the + and / characters. URL-safe swaps in - and _ and removes padding. Only MIME adds line breaks, at 76 characters with CRLF, which is the shape a MIME body part uses for its encoded content.

    RFC 4648, The Base16, Base32 and Base64 Data Encodings

    RFC 2045, MIME Part One

    Questions about Base64 Encoder and Decoder

    Why does my encoded text end with one or two = signs?

    Each = marks a group of three bytes the input did not fill, so a decoder knows the original length. Hello is five bytes, so the last group holds two and standard Base64 adds one =.

    My decode says the bytes are not valid UTF-8. What happened?

    The Base64 was valid, but the bytes are not text. A recognized image gets a preview and the matching image extension. Other binary data is kept off the page and offered as a .bin download.

    Is Base64 a way to hide a value?

    No. There is no key and no password, so anyone can decode the text. Use an encryption tool when the content must stay private, and keep the key in a separate channel.

    Which variant should I choose for a URL or an API token?

    URL-safe. It replaces + and / with - and _, so the value survives a query string or a file name, and drops the = signs some systems reject.

    Can I turn an image into a data URI and get it back?

    Yes. For example, choose mark.png, select standard Base64 and turn on Make an image data URI when encoding an image file. The output starts data:image/png;base64, followed by the encoded bytes. Paste that full value into Decode to get a PNG download and preview. The tool checks the declared image type against the bytes and rejects a mismatch.

    Project manager: Tony Hines · Content updated 29 September 2026 · Report a problem