Hoppa till huvudinnehåll
FreeOnlineTools Go
Svenska
how-to

Koda och Avkoda Base64-strängar Steg för Steg

By FreeOnlineTools Team · Updated 2026-09-02

Quick Answer

För att koda Base64: klistra in din text i Base64 Encoder och den kodade strängen visas omedelbart. För att avkoda Base64: klistra in Base64-strängen i Base64 Decoder och originaltexten visas. All bearbetning sker lokalt —din data laddas aldrig upp.

Introduction

Base64 är ett binärt-till-text-kodningsschema som konverterar binär data till en ASCII-sträng med 64 utskrivbara tecken (A-Z, a-z, 0-9, +, /). Det används ofta i email-bilagor, Data URLs, JWT-tokens och API-payloads. Base64 är reversibel kodning, inte kryptering —vem som helst kan avkoda utan en nyckel.

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