Skip to content
PickZeal
    Text and code tools

    Base64 Encode and Decode

    Encode text to Base64 or decode Base64 to text, with UTF-8, emoji and URL-safe Base64URL support plus a Basic auth header builder. Free, private.

    • Runs in your browser
    • Nothing is uploaded
    • Free, no sign-up
    Direction

    Basic auth header builder

    Base64 encode a client ID and secret, or a username and password, for an Authorization header.

    Base64 turns any data into plain letters, digits and a few symbols, so it can travel through email, JSON, HTML and HTTP headers without being damaged. This Base64 encoder and decoder works on text in any language: it converts your text to UTF-8 bytes first, so accented letters and emoji encode correctly, and it handles both standard Base64 and URL-safe Base64URL.

    How to encode and decode Base64 online

    1. Choose Encode to turn text into Base64, or Decode to turn Base64 back into text.
    2. Type or paste into the left box. The result appears as you type.
    3. When encoding, pick Standard or URL-safe, and tick the 76-character option if the result goes into an email or PEM file.
    4. Click Copy result, or Swap direction to check the round trip.

    Is Base64 encryption or encoding?

    Base64 is encoding. It is defined in RFC 4648 as a way to represent bytes, not to protect them: there is no key, and anyone can decode it. So is Base64 secure? No. A password or API key in Base64 is as readable as plain text to anyone who sees it. Use real encryption such as AES or TLS to keep data secret, and a password hash such as bcrypt or Argon2 for stored passwords. Base64 is still the right choice when you need binary data to pass through a text-only channel.

    How to decode Base64 by hand

    Each Base64 character stands for a number from 0 to 63, which is 6 bits. To decode by hand, look up each character, write its 6 bits, join them and read the bits back in groups of 8. Here is SGk= decoded step by step:

    CharacterValue6 bits
    S18010010
    G6000110
    k36100100
    =padding-

    Joined, the bits are 010010 000110 100100. Read as bytes, that is 01001000 (hex 48, the letter H) and 01101001 (hex 69, the letter i), with two leftover zero bits dropped. The = tells you the last group held only two bytes. So SGk= decodes to "Hi". Encoding by hand is the same steps in reverse. The values come from this table:

    CharactersValues
    A to Z0 to 25
    a to z26 to 51
    0 to 952 to 61
    + (Base64URL: -)62
    / (Base64URL: _)63
    =Padding, no value

    Base64 vs Base64URL: URL-safe Base64 decoding

    Standard Base64 uses + and /, which break inside web addresses, and =, which marks query parameters. Base64URL swaps those characters so the result can go straight into a URL, a file name or a JSON Web Token. To decode Base64URL, just paste it: the decoder accepts both alphabets and adds any missing padding itself.

    FeatureStandard Base64Base64URL
    Characters 62 and 63+ and /- and _
    Padding= or == at the endUsually left out
    Safe in URLs and file namesNo, needs escapingYes
    Used inEmail (MIME), data URIs, Basic authJWT, URL parameters, file names

    Base64 encode a client ID and secret for Basic auth

    Many APIs ask you to send your OAuth client ID and client secret as a Basic auth header when you request a token. The format, defined in RFC 7617, is the ID and secret joined by a colon, then Base64-encoded:

    Authorization: Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ=

    That example is client_id:client_secret encoded. Fill in the Basic auth header builder above to make your own. A common mistake is encoding the ID and secret separately, or adding a space or line break around the colon, which makes the server reject the request.

    Base64 decode UTF-8 text and emoji

    The browser's built-in btoa() function only accepts Latin-1 characters, which is why encoding an emoji in JavaScript can fail with an "InvalidCharacterError". This tool avoids that by converting text to UTF-8 bytes before encoding, and reading decoded bytes back as UTF-8. Characters outside plain English take more than one byte, so their Base64 is longer:

    TextUTF-8 bytesBase64
    A41QQ==
    éC3 A9w6k=
    €E2 82 AC4oKs
    😀F0 9F 98 808J+YgA==

    To see the bytes behind any text, use the Text to Hex Converter.

    Base64 vs hex: which is smaller?

    Both write bytes as text. Hex uses 2 characters per byte, so the output is twice the size of the input. Base64 uses 4 characters per 3 bytes, so it is only about 33% larger, which is why it is the usual choice for email attachments, images in data URIs and keys in config files. Hex is easier to read byte by byte, which is why it is used for checksums and debugging. An MD5 checksum, for example, is always written as 32 hex characters. You can make one with the Text to MD5 Hash Generator.

    What Base64 is used for

    • Email attachments. MIME encodes files as Base64 in lines of up to 76 characters.
    • Data URIs. Small images and fonts embedded in HTML or CSS as data:image/png;base64,....
    • HTTP Basic auth. Usernames and passwords, or client IDs and secrets, in the Authorization header.
    • JSON Web Tokens. The header and payload of a JWT are Base64URL-encoded JSON.
    • Config and secrets files. Certificates (PEM files) and Kubernetes secrets store binary values as Base64.

    Your data stays private

    Everything runs in your browser, so the text, IDs and secrets you paste are never uploaded, stored or logged. See all free in-browser tools.

    Frequently asked questions

    How do I decode Base64 to text?

    Choose "Decode", paste the Base64 string and the text appears at once. Line breaks and spaces inside the string are ignored, missing = padding is fine, and both standard Base64 and Base64URL are recognised. You can also paste a full data URI that starts with data: and the prefix is removed for you.

    How do I encode text to Base64?

    Leave the tool on "Encode" and type or paste your text. The text is first turned into UTF-8 bytes, then every 3 bytes become 4 Base64 characters. For example, "Hi" becomes SGk= and "Man" becomes TWFu. Click Copy result to use it.

    Is Base64 encryption or encoding?

    Base64 is encoding, not encryption. It has no key and no secret, so anyone can decode it in a second. It exists to carry binary data through systems that only accept plain text, such as email and JSON. Never use Base64 alone to hide a password or API key.

    Is Base64 reversible?

    Yes, always. Base64 maps every 6 bits to one of 64 characters, so decoding gives back exactly the original bytes. That is the main difference from a hash such as MD5, which cannot be turned back into the original text.

    How do I Base64 encode a client ID and secret?

    Join them with a colon, as client_id:client_secret, and Base64-encode the result. The OAuth token request then sends the header Authorization: Basic followed by that Base64 string. The Basic auth header builder under the converter does this for you, with UTF-8 support.

    What is the difference between Base64 and Base64URL?

    Base64URL uses - and _ instead of + and /, and usually leaves out the = padding. That makes the result safe inside URLs, file names and JSON Web Tokens (JWT), where + / and = have special meanings. Choose "URL-safe" to encode Base64URL. Decoding accepts both forms automatically.

    Why does my Base64 string end with = or ==?

    Base64 works in groups of 3 bytes. When the last group has only 1 or 2 bytes, = signs pad the output to a multiple of 4 characters: == means one byte was left over, = means two. Padding never appears in the middle of a valid string.

    Why does decoding Base64 give an error or garbled text?

    Usually the string was cut off, contains a character that is not Base64, or holds a file rather than text. This tool explains which problem it found. If the Base64 contains a PDF, image or ZIP file, it tells you the file type instead of showing unreadable characters.

    Is Base64 the same as MD5?

    No. Base64 is reversible encoding, and its output grows with the input, about 33% larger than the original. MD5 is a one-way hash that always produces 32 hex characters, whatever the input length, and cannot be decoded.

    Is my text uploaded anywhere?

    No. Encoding and decoding happen in your browser on your own device. Your text, client IDs and secrets are never sent to PickZeal or anyone else.

    More text and code tools

    View all tools