Base64 Encode & Decode Online — Text, Files and Data URLs

Encode text or files to Base64, turn images into data URIs with CSS and <img> snippets, and decode Base64 back to a previewable file. Nothing leaves your browser.

Base64
RnJlZVRvb2xzRm9yV2ViIOKAlCBCYXNlNjQgZW5jb2RlcyBieXRlcywgbm90IGNoYXJhY3RlcnMuIMOJbW9qaXMgd29yazog8J+Msg==
76 B in → 104 chars (+37%)

Runs entirely in your browser. Nothing you enter is sent to us or stored. Browse all free tools.

Found a problem, or something that could be better? We read every message and we fix things quickly.

This free Base64 encoder and decoder converts text and files to Base64 and back, in your browser. It handles UTF-8 correctly, so accented characters, Chinese text and emoji round-trip intact, which is where most quick online converters silently fail. Drop in an image or a font to get a data URI plus ready-made CSS background and <img> code, with the size overhead spelled out; or paste a data URI or bare Base64 to preview the image and download it as a file.

Base64 is not encryption and not compression; it is a way to carry binary data through channels that only accept text, such as JSON, email and URLs, at the cost of about 33 percent more bytes. Knowing that is most of knowing when to use it, and the notes below cover the rest.

How to use

  1. Choose Encode or Decode. For encoding, type or paste text; the Base64 appears as you type.
  2. Turn on URL-safe when the value will go in a URL or a JWT: + and / become - and _, and padding is dropped.
  3. To encode a file, open the “File → Base64 / data URI” tab and choose or drop it. Copy the raw Base64, the data URI, or the CSS and <img> snippets.
  4. To turn Base64 back into a file, open “Base64 / data URI → file” and paste it. The type is read from the data: prefix or detected from the bytes, images and media are previewed, and Download saves it with the right extension.
  5. Check the size line: if the encoded output is heading into megabytes, a plain file reference is almost always the better design.

Frequently asked questions

Is Base64 secure? Can I use it to hide data?

No. Base64 is an encoding, not encryption: anyone can decode it instantly, including with this page. It exists to make binary data safe to carry as text. If you need confidentiality, encrypt first and then Base64 the ciphertext if a text channel requires it.

Why does my decoded text show strange characters?

Usually because the original was not UTF-8, or because the Base64 was produced by a tool that encoded each character's code point instead of its UTF-8 bytes (the classic btoa() bug). This tool always encodes and decodes UTF-8 bytes. If the source was Latin-1 or UTF-16, the bytes are still correct; only the text rendering differs.

What is URL-safe Base64?

Standard Base64 uses + and /, both of which have meaning inside URLs, and pads with =, which URL encoders mangle. The URL-safe variant (RFC 4648 section 5) swaps them for - and _ and usually omits padding. JWTs, OAuth state values and many API tokens use it. The decoder here accepts both forms.

Should I embed images as Base64 data URLs?

For tiny assets (icons under a few kilobytes, a small inline SVG, a font subset) a data URL saves a round trip and is worth it. For anything larger, no: the file grows by a third, it cannot be cached separately from the page, and it blocks parsing of the HTML or CSS it lives in. A normal file reference wins above roughly 5 to 10 KB.

Is anything uploaded?

No. Text is converted with the browser's TextEncoder and btoa/atob, and files are read locally with the File API. Nothing is sent to a server.

How do I convert Base64 back to an image?

Paste the string into the “Base64 / data URI → file” tab. If it starts with data:image/png;base64, the type comes from that prefix; if it is bare Base64, the tool reads the first bytes (PNG, JPEG, GIF, WebP, AVIF, SVG, PDF, MP3, MP4 and other common signatures) to decide. The image is previewed on the page and Download saves it as a normal file.

How Base64 works, in one paragraph

Every three bytes of input (24 bits) are split into four 6-bit groups, and each group is written as one of 64 characters: A–Z, a–z, 0–9, + and /. That is why output length is always a multiple of four and roughly 4/3 of the input, and why = padding appears when the input is not a multiple of three bytes. Decoding reverses it exactly; there is no loss.

Where you meet Base64

• HTTP Basic authentication: the Authorization header carries user:password in Base64 (not encrypted, which is why it needs HTTPS).

• JWTs: header and payload are URL-safe Base64 JSON; decode one with our JWT decoder.

• Email attachments (MIME) and embedded images in HTML email.

• Data URLs in CSS and HTML, and image fields in some JSON APIs.

• Binary values in JSON and XML, which have no native byte type.

Data URI anatomy and size overhead

A data URI has the form data:[media type][;base64],data. data:image/png;base64,iVBORw0… carries a PNG; without ;base64 the data is percent-encoded text, which is often smaller for SVG. The media type is what the browser uses to render it, so a wrong one (image/png on JPEG bytes) can stop the image showing in some contexts.

Base64 turns every 3 bytes into 4 characters, so the payload grows by a third (33.3 percent, plus up to two padding characters) and the data: prefix adds a few more. gzip or Brotli on the HTML or CSS wins some of that back, but not all. The tool shows the exact figures for your file so you can judge whether inlining is worth it; for most images above 5 to 10 KB it is not.

Related free tools

  • JSON Formatter — Pretty-print, minify and validate JSON, with parse errors located by line and column. In your browser, no upload.
  • JWT Decoder — Decode a JWT's header and payload, read the expiry in plain language, verify HS, RS, PS and ES signatures, or sign a new token. Nothing leaves your browser.
  • Image Converter — Convert between AVIF, HEIC, TIFF, PNG, JPG, WebP, GIF, BMP and SVG. Most conversions never leave your browser.