Skip to content
  • Image CompressorImage Tools · Make photos and graphics smaller by re-encoding them as JPG or WebP, with a quality slider and optional downscaling.
  • Image ResizerImage Tools · Change the width and height of an image in pixels or by percentage, with high-quality downscaling.
  • Image ConverterImage Tools · Change the format of one or many images to JPG, PNG or WebP, with control over quality and transparency.
  • Image CropperImage Tools · Cut out part of an image with a draggable selection, aspect ratio presets and exact pixel inputs.
  • Rotate & Flip ImageImage Tools · Turn a picture by 90° or 180° and mirror it horizontally or vertically, with a live preview.
  • Merge PDFPDF Tools · Combine several PDF files into one document, in the order you choose, with optional page ranges per file.
  • Split PDFPDF Tools · Extract pages into a new PDF or split a document into several files by page, range or fixed page count.
  • Reorder PDF PagesPDF Tools · Change the page order of a PDF with drag and drop, delete unwanted pages and save the result.
  • Rotate PDFPDF Tools · Turn individual pages or the whole document by 90° steps, preview the result and save the corrected PDF.
  • Images to PDFPDF Tools · Combine photos and scans into a single PDF, one image per page, with page size, orientation and margin options.
  • JSON Formatter & ValidatorDeveloper Tools · Validate JSON with precise error locations, then pretty-print, minify or sort keys without changing any value.
  • Base64 Encoder & DecoderDeveloper Tools · Encode text or files to Base64 (standard or URL-safe) and decode Base64 or data: URLs back to text or a downloadable file.

Base64 Encoder & Decoder

Encode text or files to Base64 (standard or URL-safe) and decode Base64 or data: URLs back to text or a downloadable file.

Runs locally in your browser – your data is not uploaded

Loading tool…

About the Base64 Encoder & Decoder

Base64 writes arbitrary bytes using 64 printable characters (A–Z, a–z, 0–9, + and /), so binary data can travel through channels that only handle text: JSON and XML documents, e-mail, HTTP headers, environment variables or data: URLs in HTML and CSS. Every 3 bytes become 4 characters, which makes the encoded form about a third larger than the original.

This tool converts text (encoded as UTF-8) and files to Base64 and back. It supports the URL-safe variant known as Base64url, optional padding and MIME-style line wrapping, and it understands data: URLs. When decoding, readable text is shown straight away; anything else is offered as a file, with the type detected from the data where possible.

The conversion runs entirely in your browser. Files are read on your device and nothing is uploaded.

How to use it

  1. Choose Encode or Decode under Direction.
  2. To encode, pick Text and type or paste into Text to encode, or pick File and choose a file of up to 25 MB. Tick Add data: URL prefix to get a ready-made data: URL.
  3. Adjust the options if needed: URL-safe alphabet (- and _), Padding (=) and Wrap lines at 76 characters.
  4. To decode, paste Base64 or a complete data: URL into the box, or use Open a text file. Readable UTF-8 text appears under Decoded text; other data appears under Decoded file with its size, type and a hex preview.
  5. Use Copy result or Copy text, Download .txt or Download file to keep the result, Swap to send it to the other direction, and Clear to start again.

Features

  • Text and files: Text is converted as UTF-8, so accents, non-Latin scripts and emoji work. Files of any type up to 25 MB are supported, without the size and Unicode problems of the browser’s btoa function.
  • Standard and URL-safe Base64: Produce either alphabet, with or without = padding. The decoder accepts both alphabets, missing padding, spaces and line breaks.
  • Clear validation: Invalid input is explained precisely: which character is not allowed and at which position, a length that cannot be valid Base64, or padding in the wrong place.
  • data: URLs in both directions: Turn a file into a data: URL that uses its MIME type, or paste a data: URL to decode it with the type it declares.
  • Text or file output: Decoded bytes that are valid UTF-8 are shown as text. Other data is offered for download, with PNG, JPEG, GIF, WebP, PDF and ZIP recognised from their first bytes, an image preview where possible and a hex dump of the first 64 bytes.

Examples

Building a Basic authentication header

Encoding the text user:pa55word gives dXNlcjpwYTU1d29yZA==, which goes into the header Authorization: Basic dXNlcjpwYTU1d29yZA==. Remember that anyone who sees the header can decode it again.

Reading the payload of a JSON Web Token

The middle part of a JWT is Base64url without padding. Decoding eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkFkYSBMb3ZlbGFjZSJ9 shows {"sub":"1234567890","name":"Ada Lovelace"}. Decoding does not verify the token’s signature.

Embedding a small icon in CSS

Choose File, pick a small PNG and tick Add data: URL prefix. The result starts with data:image/png;base64, and can be used directly in background-image: url(…) or an <img> src attribute.

Saving a file returned by an API

Some APIs return documents as a Base64 string inside JSON. Paste the string in Decode mode: if it is a PDF, the tool detects application/pdf and Download file saves it as decoded.pdf.

Limitations and notes

  • Files up to 25 MB can be encoded, and text files up to 40 MB can be opened for decoding. Very long results are shown as a preview in the box; Copy and Download always use the full result.
  • File types are recognised from content only for PNG, JPEG, GIF, WebP, PDF and ZIP. Other binary data is saved as a .bin file unless a data: URL states its type.
  • Text is always treated as UTF-8. Base64 of text in another encoding, such as UTF-16 or Windows-1252, is not shown as text but offered as a file instead.
  • Line breaks you type or paste into a text box are normalised to LF by the browser, so text with Windows (CRLF) line endings is encoded with LF. Encode the file itself if the exact bytes matter.
  • Wrapped output uses LF line breaks. Strict MIME uses CRLF, but decoders – including this one – accept both.
  • Base64 is an encoding, not encryption: it does not protect data, and anyone can decode it.

Frequently asked questions

Is Base64 a form of encryption?

No. Base64 only changes how bytes are written down, and decoding needs no key. Use it to transport data through text-only channels, never to hide passwords or other secrets.

Why does Base64 often end with = or ==?

Base64 works in groups of 3 bytes. When the input length is not a multiple of 3, the last group is padded with one or two = signs so the text length is a multiple of 4. Many formats, such as JWTs, leave the padding out; this decoder accepts both forms.

What is the difference between Base64 and Base64url?

Base64url (RFC 4648, section 5) replaces + with - and / with _ so the text can be used in URLs and file names without escaping. Apart from those two characters – and usually missing padding – the encoding is identical.

Why do I get "Invalid length" when decoding?

Base64 text without padding can never have a length of 4n + 1 characters, because one character holds only 6 bits – not enough for a whole byte. This usually means the text was cut off or a character was added while copying.

Why is the Base64 text bigger than my file?

Every 3 bytes are written as 4 characters, so the encoded text is about 33% larger than the original (plus line breaks if wrapping is on). That is the price for using only safe, printable characters.

Are my files or text uploaded?

No. Encoding and decoding are done by JavaScript in this page, and files are read locally. Nothing is sent to a server.

More free tools