Skip to main content
FreeOnlineTools Go
English
how-to

How to Encode and Decode Base64 Strings Step by Step

By FreeOnlineTools Team · Updated 2026-09-02

Quick Answer

To encode Base64: paste your text into the Base64 Encoder, and the encoded string appears instantly. To decode Base64: paste the Base64 string into the Base64 Decoder, and the original text appears. All processing happens locally in your browser — your data is never uploaded.

Introduction

Base64 is a binary-to-text encoding scheme that converts binary data into an ASCII string using 64 printable characters (A-Z, a-z, 0-9, +, /). It is widely used in email attachments, Data URLs, JWT tokens, and API payloads. Base64 is reversible encoding, not encryption — anyone can decode it without a key. This guide shows you how to encode and decode Base64 in your browser using a free online tool.

Step by Step

  1. Open the Base64 tool

    Go to the Base64 Encode & Decode tool page. The tool has two modes: Encode and Decode, selectable via tabs or a toggle.

  2. Enter your input text

    In Encode mode, paste or type the text you want to encode into the input textarea. Any text works — plain strings, JSON, URLs, or even emoji (the tool handles UTF-8 correctly).

  3. Read the Base64 output

    The tool encodes your input instantly using the browser's built-in btoa() function with UTF-8 handling. The Base64 output appears in the result field automatically — no button to click.

  4. Copy the encoded string

    Click the Copy button next to the output field to copy the Base64 string to your clipboard. You can now paste it into your API call, HTML Data URL, or config file.

  5. Decode Base64 back to text

    Switch to Decode mode and paste a Base64 string into the input field. The tool decodes it using atob() with UTF-8 support and shows the original text instantly. If the input is not valid Base64, an error message appears.

Examples

Encode a simple greeting

Input: Hello, World!

Output: SGVsbG8sIFdvcmxkIQ==

Encode JSON data

Input: {"user":"alice","id":42}

Output: eyJ1c2VyIjoiYWxpY2UiLCJpZCI6NDJ9

Decode a Base64 token

Input: SGVsbG8gV29ybGQ=

Output: Hello World

Encode Unicode text with emoji

Input: Hello 🌍

Output: SGVsbG8g8J+MjQ==

Common Problems

  • Non-ASCII characters produce wrong output —use a tool with UTF-8 support like ours; naive btoa() throws on emoji.
  • Base64 output is ~33% larger than the input —every 3 bytes becomes 4 Base64 characters.
  • Padding characters (= or ==) at the end are required —removing them breaks decoding.
  • Base64 is not encryption —anyone can decode it. Never store passwords or secrets as Base64.

Tips

  • Use Base64 for Data URLs to embed small images directly in HTML or CSS without a separate HTTP request.
  • For URL-safe Base64 (used in JWT), replace + with - and / with _, then strip padding.
  • Always validate decoded output before using it in your application —a corrupted Base64 string may decode to garbage.
  • Use our Base64 Encoder and Decoder tools for instant, private processing —no data leaves your browser.

Related Tools

Related Guides

References