Base64 Encode and Decode Online, Client-Side

Encode text or files to Base64 and decode strings back to bytes in the browser. Includes padding examples, the RFC 4648 alphabet and the URL-safe variant.

All calculation runs in your browser. Nothing you enter is sent to a server.

01 calculator

Results update as you type. Ctrl/Cmd+Enter copies the primary result.

Result

    Show the working

      Base64 Encode and Decode converts arbitrary bytes to an ASCII string using the RFC 4648 alphabet, and reverses that string back to the original bytes. Text mode accepts a character encoding such as UTF-8; file mode reads an upload through the browser's FileReader and can emit a data: URI for embedding. Encoding is not encryption. Anyone who receives the string can decode it.

      All encoding and decoding runs in your browser. Nothing you paste is sent to a server.

      Encode text or a file to Base64

      Concept diagram: Inputs leads to Encode text or a file to Base64 leads to ResultInputsEncode text or a fileto Base64Result
      Encode text or a file to Base64.

      Encoding takes raw bytes and writes a string of A to Z, a to z, 0 to 9, plus, slash and padding =. Paste text or choose a file, select character encoding when the source is text, and read the output.

      File mode suits small images and documents that must travel inside JSON, XML or email without a binary channel.

      The output is safe for transport through systems that corrupt arbitrary binary, such as older mail gateways or copy-paste into XML. It is longer than the input by design. Invalid empty input produces no string; the tool waits for bytes before emitting characters.

      Decode a Base64 string back to data

      Concept diagram: Inputs leads to Decode a Base64 string back to data leads to ResultInputsDecode a Base64 stringback to dataResult
      Decode a Base64 string back to data.

      Decoding reverses the alphabet lookup, rebuilds the original bit stream and returns text or a downloadable file. Padding = characters at the end are significant: they mark how many bytes were in the final incomplete group. Characters outside the alphabet cause a clear error rather than a silent partial decode.

      Whitespace is often ignored so strings copied from PEM certificates or MIME bodies still work. A string that looks like Base64 but uses the URL-safe alphabet needs the URL-safe decode mode, or hyphen and underscore will be rejected as illegal in the standard alphabet.

      Understand how Base64 encoding works

      Process with 3 steps: Enter how Base64 encoding works; Read the main result; Check the breakdown1Enter how Base64encoding works2Read the main result3Check the breakdown
      Understand how Base64 encoding works.

      Base64 processes input in blocks of three bytes (24 bits). Those 24 bits are split into four groups of 6 bits. Each 6-bit value is an index from 0 to 63 into the 64-character alphabet. Three input bytes therefore become four output characters.

      Bytes:  [ byte1 ][ byte2 ][ byte3 ]
      Bits:   aaaaaaaa bbbbbbbb cccccccc
      Groups: aaaaaa aabbbb bbbbcc cccccc
      Chars:  Char1  Char2  Char3  Char4

      When fewer than three bytes remain, the encoder still emits four characters but adds padding so the decoder knows the original length. The bit regrouping is the entire algorithm; there is no checksum and no key.

      Encode the word Dog step by step

      Process with 3 steps: Enter Encode word Dog step by step; Read the main result; Check the breakdown1Enter Encode word Dogstep by step2Read the main result3Check the breakdown
      Encode the word Dog step by step.

      The word Dog is three ASCII bytes, so it fills one Base64 group and encodes with no padding characters. The fixture output is RG9n. Walking the bytes to bits, regrouping into 6-bit indexes, and reading the RFC 4648 alphabet shows why those four characters appear and how any three-byte block follows the same path.

      1. Write the bytes. D = 0x44 = 01000100 o = 0x6F = 01101111 g = 0x67 = 01100111

      2. Concatenate 24 bits. 01000100 01101111 01100111

      3. Split into 6-bit groups. 010001 000110 111101 100111

      4. Convert each group to a decimal index. 17, 6, 61, 39

      5. Look up the alphabet. Index 17 = R, 6 = G, 61 = 9, 39 = n

      Result: RG9n. Decoding RG9n returns the three original bytes and the text Dog under UTF-8 or ASCII.

      Understand padding with the equals sign

      Concept diagram: Inputs leads to padding with equals sign leads to ResultInputspadding with equalssignResult
      Understand padding with the equals sign.

      Padding appears when the byte count is not a multiple of three. One leftover byte produces two alphabet characters and two = signs. Two leftover bytes produce three characters and one =. The fixtures DoRG8= and DogsRG9ncw== show both remainder cases beside the unpadded three-byte word Dog.

      InputBytesEncodedPadding
      Dog3RG9nnone
      Do2RG8=one =
      Dogs4RG9ncw==two =

      Do is two bytes: 01000100 01101111. After 6-bit grouping there are only enough bits for three meaningful characters (RG8), and one padding = fills the fourth slot. Dogs is four bytes: a full three-byte group encoding as RG9n, then a one-byte remainder encoding as cw==. Removing padding by hand without adjusting the bit length breaks decoding; leave the = characters in place when pasting.

      Read the Base64 alphabet

      Concept diagram: Inputs leads to Base64 alphabet leads to ResultInputsBase64 alphabetResult
      Read the Base64 alphabet.

      RFC 4648 defines 64 characters plus the padding mark =. Indexes 0 to 25 are A to Z, 26 to 51 are a to z, 52 to 61 are 0 to 9, index 62 is +, and index 63 is /.

      Index 0 is A, not 0, which trips anyone who expects digits to lead the alphabet.

      Index rangeCharacters
      0 to 25A to Z
      26 to 51a to z
      52 to 610 to 9
      62+
      63/
      padding=

      The calculator's alphabet panel lists the same table the encoder uses, so a suspicious character can be checked against the standard set. The full string is ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/.

      Use the URL-safe Base64 variant

      Concept diagram: Inputs leads to URL-safe Base64 variant leads to ResultInputsURL-safe Base64 variantResult
      Use the URL-safe Base64 variant.

      The URL-safe alphabet (base64url) replaces + with - and / with _. Padding may be omitted in some protocols. JSON Web Tokens use this variant so token segments can sit in URLs and HTTP headers without percent-encoding the plus and slash characters.

      Standard and URL-safe strings are not interchangeable. Decoding a JWT payload with the standard alphabet fails on hyphens. The tool offers an explicit URL-safe mode for both encode and decode. Percent-encoding a URL is a different problem; use the URL Encode and Decode page when the goal is RFC 3986 escaping rather than Base64.

      Account for the size increase

      Concept diagram: Inputs leads to Account for size increase leads to ResultInputsAccount for sizeincreaseResult
      Account for the size increase.

      Every three bytes become four characters, so encoded length is about 4/3 of the input, a 33 percent increase before line breaks. Padding can add one or two extra characters on the final group. Data URIs and email attachments feel this cost quickly: a 300 KB image becomes roughly 400 KB of text.

      encoded_length ≈ 4 × ceil(byte_length / 3)

      Line wrapping at 76 characters, common in MIME, adds newline bytes on top. Prefer binary attachments or compressed formats when size matters; use Base64 when the channel genuinely cannot carry raw bytes.

      Choose a character encoding

      Concept diagram: Inputs leads to a character encoding leads to ResultInputsa character encodingResult
      Choose a character encoding.

      Base64 encodes bytes, not abstract characters. The same letters produce different bytes under UTF-8, UTF-16, Shift JIS or Big5. Decoding then interpreting with the wrong charset yields mojibake even when the Base64 layer was perfect, so the text mode charset must match the producer on encode and the consumer on decode.

      CharsetTypical use
      UTF-8Default for modern text and APIs
      Windows-1252Legacy Western European text
      UTF-16 LE / BESome Windows and Java payloads
      Shift JISOlder Japanese text
      Big5Older Traditional Chinese text

      For the word Dog, ASCII and UTF-8 produce the same three bytes, so RG9n is identical. Non-ASCII text diverges. Pick the charset that matches the producer before encoding, and the same charset after decoding, or the round trip will look like a Base64 bug when the mistake is upstream.

      Frequently asked questions

      Is Base64 encryption?

      No. Base64 is an encoding that anyone can reverse with the public alphabet. It hides nothing. Use a real cryptographic algorithm when confidentiality is required; use Base64 when a channel needs ASCII-safe bytes.

      Why does Base64 output end with equals signs?

      The = characters are padding. They mark that the final input group had one or two bytes instead of three. Do encodes to RG8= and Dogs to RG9ncw==. Keep the padding when decoding unless the protocol documents that it was stripped.

      What does Dog encode to?

      Dog encodes to RG9n with no padding, because three bytes fill one Base64 group exactly. The step-by-step bit regrouping is shown in the worked example on this page.

      What is the difference between standard and URL-safe Base64?

      URL-safe Base64 uses - and _ instead of + and /. JWTs and some file-name embeddings use the URL-safe alphabet. Decoding with the wrong alphabet fails on those substituted characters.

      How much larger is Base64 than the original?

      About one third larger. Three bytes become four characters, so the ratio is 4/3 before padding and line breaks. A 3,000-byte payload becomes 4,000 characters of Base64.

      Can Base64 encode a file, not only text?

      Yes. File mode reads the upload in the browser and encodes its raw bytes. The reverse path decodes to a downloadable blob. Large files increase memory use in the tab; keep uploads modest.

      Why does decoded text look wrong after a correct decode?

      The Base64 layer restored the bytes, but the character encoding used to interpret those bytes does not match the producer. Try UTF-8 first, then the charset the source system actually uses.

      Does this tool upload pasted secrets?

      No. Encoding and decoding run locally. API keys, tokens and certificate fragments pasted into the box are not sent to a server. That promise matches the design rule for all encoding pages on Quick Calculators.

      Is Base64 the same as URL encoding?

      No. Base64 maps binary to a 64-character alphabet for transport. URL encoding (percent-encoding) escapes reserved characters inside URIs per RFC 3986. They solve different problems and are not substitutes for each other.

      What RFC defines the alphabet?

      RFC 4648 defines the standard and URL-safe Base64 alphabets and the padding rules used here. Older documents such as RFC 2045 describe Base64 in the MIME context with similar mechanics.

      Summary

      Base64 Encode and Decode maps bytes to the RFC 4648 alphabet in 6-bit groups and reverses the process locally in the browser. Dog becomes RG9n, Do becomes RG8=, and Dogs becomes RG9ncw==, illustrating padding for one- and two-byte remainders.

      The URL-safe alphabet swaps +// for -/_, output grows by about one third, and character set choice decides which bytes the text mode feeds into the encoder. Nothing pasted is uploaded.