Back to All Tools

Base64 Encode & Decode

Encode text to Base64 or decode Base64 back to text. Full UTF-8 support, padding and wrapped lines handled, and a Swap button to check the round trip.

Complete Guide

About the Base64 Encode & Decode

Base64 turns arbitrary bytes into a safe alphabet of letters, digits, plus and slash so binary data can travel through channels that only tolerate plain text. This tool converts text to Base64 and back in both directions with full UTF-8 safety, so emoji, Devanagari script and other multi-byte characters survive intact. A Swap button drops your last result straight into the input for a round-trip check, and nothing you type is ever transmitted.

Why Base64 exists at all

It was designed to carry binary through a text-only channel, not to hide anything. Early mail and terminal systems could reliably move seven-bit ASCII text and nothing else, so a JPEG, a font file or a byte array with values above 127 had no safe representation. Base64 solves that by re-expressing every group of three bytes as four printable characters from a fixed 64-letter alphabet: A to Z, a to z, 0 to 9, plus + and slash /. Every one of those is unambiguous in text, JSON, a URL query or a config file, which is why the format turned up in MIME email attachments, HTTP Basic auth headers, data URLs and JSON Web Tokens. The cost is size.

See also: URL Encoder & Decoder·Verified exam photo and signature specs

The 4:3 ratio and the 33% overhead

Three bytes in, four characters out — that is the arithmetic of the format. When the input length divides evenly by three the output is exactly one third longer, because 4 ÷ 3 = 1.3333. 'Man' is three bytes and encodes to 'TWFu', four characters. When it does not divide evenly the last group is padded with one or two '=' signs, so short inputs cost more: 'Rupix Tools' is 11 bytes and comes out at 16 characters, 45% larger, and a single 'M' becomes 'TQ=='. Pad up to a multiple of three bytes and the overhead settles back to exactly a third. So the honest statement is: Base64 costs about a third more space than the bytes it carries, plus up to two padding characters. It is a transport format, not a compression format.

Standard Base64 versus URL-safe Base64

RFC 4648 defines two alphabets. The standard one uses + and slash for the last two values and pads with =. The URL-safe variant, usually called Base64URL, swaps those for hyphen - and underscore _ and drops the padding, because + and slash need percent-encoding to survive a URL path. JSON Web Tokens use Base64URL for exactly that reason. A plain Base64 decoder rejects a Base64URL string outright: feed it a segment containing '-' or '_' and the browser throws an InvalidCharacterError rather than producing something plausible. That is a safety feature. Substitute the two characters back and add padding if the length needs it, or use the JWT decoder on this site, which normalises them for you.

See also: JWT Decoder

UTF-8, and the failure modes you will hit

The browser's legacy btoa function only accepts code points below 256, so calling it directly on an emoji or on Hindi text throws. This tool routes the string through a UTF-8 encoder first and mirrors that on the way back, which is why multi-byte characters round-trip here. The decoder is forgiving in useful ways: leading and trailing whitespace is ignored, so are newlines anywhere inside the string, and a missing trailing '=' is tolerated — 'YWI' decodes to 'ab' exactly as 'YWI=' does. What it will not accept is a character outside the alphabet. Three cases account for nearly every failure: a data URI pasted whole ('data:image/png;base64,iVBORw0KGgo=' fails, because the prefix is not Base64 — cut everything up to the comma), a Base64URL string with '-' or '_', and a length exactly one character modulo four. When the bytes were never meant to be text, decoding succeeds and still looks wrong: the PNG header bytes iVBORw0KGgo come back as replacement characters.

See also: JSON Formatter & Validator

Simple Step-by-Step Guide

How to Use Base64 Encode & Decode Online

Follow these simple steps to use Base64 Encode & Decode securely in your web browser.

  1. 1

    Choose Encode or Decode

    Encode turns your text into Base64. Decode turns a Base64 string back into readable text.

    Choose Encode or Decode — Base64 Encode & Decode
  2. 2

    Paste or type your input

    Put the text (or the Base64 string) in the box. Multi-byte characters such as emoji and other scripts are handled.

    Paste or type your input — Base64 Encode & Decode
  3. 3

    Copy the result

    Click Copy to put the converted value on your clipboard, or Swap to feed the result back in and check the round trip.

Technical Specs

Features & Specifications

Standard

RFC 4648 Base64 (standard alphabet, A-Z a-z 0-9 + /)

Character Encoding

UTF-8 via TextEncoder/TextDecoder

Engine

Native btoa/atob with Uint8Array buffers

Size cost

4 characters per 3 bytes, plus = padding

Privacy Status

100% In-Browser Local Processing

100% Free & Private In-Browser Processing

Every tool on this site runs on a zero-upload architecture. All computations, file parsing, and transformations occur locally inside your web browser. No document bytes, sensitive text, or personal data are ever uploaded or transmitted to remote servers.

Highlights

Why use Rupix Base64 Encode & Decode?

UTF-8 Character Safety

Handles multi-byte Unicode characters, non-Latin alphabets, and emojis without the corruption naive converters produce.

Forgiving Decoder

Leading and trailing whitespace, embedded newlines and a missing trailing '=' are all tolerated; anything outside the alphabet is rejected clearly.

Swap for Round Trips

One tap feeds your last result back in as the input, so you can confirm a value survives the trip in both directions.

Zero Data Transmission

Operates 100% client-side via TextEncoder and TextDecoder.

Q&A

Frequently Asked Questions

Pick the encode mode, type or paste your text, and the Base64 string appears below as you type. The conversion runs in your browser, so nothing is uploaded. You can check it immediately by pressing Swap, which feeds the result back in as the input for decoding.
Switch to decode mode and paste the Base64 string in. Line breaks and spaces are ignored, and a missing trailing '=' is tolerated, so wrapped or unpadded values still decode. Anything outside the 64-character alphabet is rejected with a message rather than a wrong answer.
Because three bytes become four characters. When the byte count divides by three exactly, the output is one third longer: 'Man' is 3 bytes and 4 characters. Short inputs cost more because the last group is padded out with '=' — 'Rupix Tools' is 11 bytes and 16 characters, 45% larger.
Padding under RFC 4648. Output always comes in groups of four characters, so a final group that is only one or two bytes short is filled with one or two '=' signs. Do not trim them before storing a value, even though most decoders will re-add them for you.
The input contains a character outside the Base64 alphabet, so the browser refuses it rather than guessing. The usual causes are a pasted data URI prefix such as 'data:image/png;base64,' and a Base64URL string containing '-' or '_' instead of '+' and '/'.
Yes. Input is converted to a UTF-8 byte stream before encoding and back after decoding, so emojis, Devanagari, CJK and accented characters survive the round trip instead of throwing or turning into replacement characters.
The header and payload usually decode directly, since JWT segments use the URL-safe alphabet and a decoder tolerates missing padding. If a segment happens to contain '-' or '_', it will be rejected — use the JWT decoder, which normalises those two characters and prints the issued-at and expiry dates for you.
No. Base64 is a reversible encoding with no key, so anyone can undo it in seconds and it must never be used to hide a credential. Your privacy here is a separate matter: every conversion runs in local browser memory with no network request, so the text itself is never sent anywhere.
Chat on WhatsApp