Base64 Encode Decode

Encode text to Base64 or decode it back, with UTF-8 emoji support and a URL-safe option. Runs entirely in your browser.

Base64 encoder and decoder
Mode

    Text is encoded as UTF-8 before conversion, so accented letters, symbols and emoji work correctly. Everything runs in your browser; nothing you paste is sent anywhere. Base64 is an encoding, not encryption, so it doesn't protect secrets.

    On this page

    The Base64 encoder and decoder converts text to Base64 and back, handling accented letters, symbols and emoji correctly through UTF-8. “Hello, World!” encodes to SGVsbG8sIFdvcmxkIQ==, and decoding that string gives the original text back. Switch on the URL-safe option to get output that can be used in web addresses and file names. Everything happens in your browser, so the text you paste never leaves your device.

    Developers use Base64 every day in APIs, emails, configuration files, data URLs and authentication headers. This tool makes it quick to check what a Base64 string contains or to produce one for testing.

    How to use the Base64 tool

    1. Choose Encode or Decode.
    2. Type or paste your text into the box. For decoding, paste the Base64 string; spaces and line breaks are ignored.
    3. Tick URL-safe if you need the variant that uses – and _ and leaves out = padding.
    4. Select Encode or Decode. The result appears with its length and size, and you can copy it or use it as the next input to reverse the conversion.

    What is Base64?

    Base64 is a way of representing any binary data, such as images, files or encrypted bytes, using only 64 safe text characters: the capital letters A to Z, the small letters a to z, the digits 0 to 9, and + and /. The = sign is used as padding at the end. Because those characters pass safely through systems designed for plain text, Base64 is used wherever binary data has to travel through text-only channels.

    The standard version is defined in RFC 4648, which also describes the URL-safe variant used in web tokens and addresses.

    How Base64 encoding works

    1. The text is converted to bytes using UTF-8.
    2. The bytes are grouped into blocks of three, which is 24 bits.
    3. Each 24-bit block is split into four groups of 6 bits.
    4. Each 6-bit group, a number from 0 to 63, is replaced with the matching character from the Base64 alphabet.
    5. If the last block has only one or two bytes, the output is padded with one or two = signs.

    Worked example

    The word “Man” is the bytes 77, 97 and 110, which in binary are 01001101 01100001 01101110. Split into 6-bit groups, that’s 010011, 010110, 000101 and 101110, or 19, 22, 5 and 46, which map to T, W, F and u. So “Man” encodes to TWFu. “Hello, World!” is 13 bytes, which needs five full blocks and one leftover byte, so it ends with two padding characters: SGVsbG8sIFdvcmxkIQ==.

    Base64 makes data bigger

    Every 3 bytes become 4 characters, so Base64 output is about 33% larger than the original data, plus a little padding. A 1 MB image becomes roughly 1.33 MB when Base64-encoded. That’s why Base64 is used for convenience and compatibility, not for compression. The calculator shows the size increase for every encoding.

    UTF-8, accents and emoji

    Base64 works on bytes, not characters. Plain English letters each take one byte in UTF-8, but other characters take more: é and ë take two bytes, the ☕ symbol takes three and most emoji take four. “Zoë ☕” is 5 characters but 8 bytes, encoding to Wm/DqyDimJU=. Some simple Base64 tools fail with these characters or produce garbled output; this one encodes text as UTF-8 first, so any language and any emoji round-trip correctly.

    Standard and URL-safe Base64

    The characters + and / have special meanings in web addresses, and = is used in query strings. URL-safe Base64 replaces + with – and / with _, and usually leaves out the = padding. It’s used in JSON Web Tokens (JWTs), some API keys and file names. The text ???>>> encodes to Pz8/Pj4+ in standard Base64 and Pz8_Pj4- in URL-safe Base64. The decoder accepts both forms, with or without padding.

    Common uses of Base64

    • Email attachments: MIME encodes attachments in Base64 so they can travel through mail systems designed for text.
    • Data URLs: small images and fonts can be embedded directly in HTML or CSS, such as data:image/png;base64,….
    • HTTP Basic authentication: the username and password are joined with a colon and Base64-encoded in the Authorization header.
    • JSON Web Tokens: the header and payload are URL-safe Base64.
    • APIs and configuration: binary values such as keys, certificates and hashes are often stored or sent as Base64 text.

    Base64 in code and on the command line

    Most programming languages include Base64 functions. In JavaScript, btoa() and atob() handle Base64 but only work directly with single-byte characters, so text containing other characters should be converted with TextEncoder first, which is what this tool does. In Python, the base64 module provides b64encode and urlsafe_b64encode. On Linux and macOS, the base64 command encodes and decodes files from the terminal, and in PowerShell you can use [Convert]::ToBase64String(). When results from two tools don’t match, the cause is usually a different text encoding, a trailing newline included in one input, or the URL-safe variant being used in one place but not the other.

    Other text encodings

    Base64 isn’t the only way to turn bytes into text. Hexadecimal uses 16 characters and doubles the size of the data, but is easy to read and common for hashes and colour codes. Base32 uses only capital letters and the digits 2 to 7, avoiding characters that are easily confused, and appears in two-factor authentication secrets. Base58 removes look-alike characters such as 0, O, I and l, and is used for some cryptocurrency addresses. Base64 is the most compact of these common encodings, which is why it’s the default for most data transfer.

    The Base64 alphabet

    Each Base64 character stands for a 6-bit value from 0 to 63. The values 0 to 25 are the capital letters A to Z, 26 to 51 are the small letters a to z, 52 to 61 are the digits 0 to 9, 62 is + and 63 is /. In URL-safe Base64, 62 becomes – and 63 becomes _. So A is 0, Z is 25, a is 26, z is 51, 0 is 52 and 9 is 61. Knowing the order makes it easy to decode a short string by hand, as in the “Man” example above.

    Line breaks in Base64

    Email (MIME) wraps Base64 into lines of 76 characters, and some older formats such as PEM certificates use 64-character lines. The line breaks aren’t part of the data. This decoder removes spaces and line breaks before decoding, so you can paste wrapped Base64 directly, including the content between the BEGIN and END lines of a PEM file.

    Data URLs and web performance

    Embedding small images or icons as Base64 data URLs saves a separate request to the server, which can help for tiny files. For larger images, the 33% size increase and the fact that the data can’t be cached separately usually make a normal image file faster. As a rule of thumb, inline only very small assets of a few kilobytes and keep everything else as regular files.

    Base64 is not encryption

    Base64 only changes how data is represented; anyone can decode it instantly. It provides no security. Never rely on Base64 to hide passwords, API keys or personal information. For example, an HTTP Basic authentication header can be decoded to reveal the username and password, which is why it must only be used over HTTPS. To protect data, use proper encryption and secure transport.

    Decoding errors explained

    • Invalid characters: only letters, digits, +, /, – , _ and = are allowed. Copying from a web page or document can introduce stray characters.
    • Wrong length: a valid Base64 string, once padding is restored, has a length that’s a multiple of 4. A length that leaves a remainder of 1 means characters are missing.
    • Binary content: if the decoded bytes aren’t valid UTF-8 text, such as an image or a compressed file, the tool shows the first bytes in hexadecimal instead of garbled characters.

    Related calculations

    You may also find the URL encode decode tool useful to encode or decode text for use in web addresses, while the password generator lets you create strong random passwords.

    Frequently asked questions

    A way of representing binary data using 64 text-safe characters (A–Z, a–z, 0–9, + and /), so it can travel through systems that only handle text.

    Choose Decode, paste the Base64 string and select Decode. The tool shows the original text, or the bytes in hexadecimal if the data isn't text.

    No. Anyone can decode Base64 instantly. It's an encoding for compatibility, not a way to protect data.

    The = signs are padding, added when the data length isn't a multiple of 3 bytes, so the output length is a multiple of 4.

    About 33% bigger, because every 3 bytes become 4 characters.

    A variant that uses - and _ instead of + and / and usually omits = padding, so it can be used in URLs and file names.

    Yes. Text is encoded as UTF-8 first, so any language and emoji encode and decode correctly.

    No. Encoding and decoding happen entirely in your browser.

    The text contains characters outside the Base64 alphabet, the padding is in the wrong place, or part of the string is missing.

    Usually because of a different text encoding, an extra newline at the end of the input, or one tool using the URL-safe variant. Check those three things first.

    Use the base64 module: base64.b64encode(text.encode("utf-8")) returns the encoded bytes, and base64.b64decode reverses it.