JSONHack
Validator · Formatter · Base64
Developer Guide

What is Base64 Encoding?

📅Last updated:

Base64 is a binary-to-text encoding scheme that converts binary data into a string of ASCII characters. It is one of the most widely used encoding techniques in web development, APIs, email systems, and cryptography. Base64 is not encryption — it is purely an encoding method designed to safely transport binary data through text-based systems.

How Base64 Works

Base64 takes binary data and breaks it into groups of 6 bits. Each 6-bit group is mapped to one of 64 characters from the Base64 alphabet: uppercase letters (A–Z), lowercase letters (a–z), digits (0–9), plus (+), and slash (/). The = character is used for padding when the input length is not a multiple of 3 bytes.

Encoding Example

Original text:

Hello, World!

Base64 encoded:

SGVsbG8sIFdvcmxkIQ==

Why the Output Is Longer

Base64 encoding increases data size by approximately 33% because every 3 bytes of input become 4 characters of output. This is a known trade-off for the benefit of safe text-based transmission.

Why Base64 Is Used

Embedding Images in HTML/CSS

Convert images to Base64 data URLs to embed them directly in HTML without separate file requests.

<img src="data:image/png;base64,...">

API File Transfers

Many REST APIs accept file uploads as Base64 strings in JSON payloads, avoiding multipart form encoding complexity.

Storing Binary in JSON

JSON only supports text. Base64 lets you store binary data (images, PDFs, audio) inside a JSON string field.

Email Attachments (MIME)

Email protocols use Base64 to encode attachments so binary files can travel safely through text-based email systems.

Authentication Tokens

HTTP Basic Auth encodes credentials as Base64. JWT tokens use Base64URL encoding for their header and payload sections.

Data URLs

Fonts, SVGs, and small assets can be inlined as Base64 data URLs in CSS to reduce HTTP requests.

Base64 vs Encryption

This is a very common misconception. Base64 is not secure and should never be used as a security measure:

Base64 Variants

Advantages and Disadvantages

✅ Advantages

  • Safe for text-based systems
  • Works across all browsers and platforms
  • Prevents binary data corruption
  • Simple to encode and decode
  • Widely supported in all languages

❌ Disadvantages

  • Increases data size by ~33%
  • Not secure — easily reversible
  • Not suitable for large binary files
  • Adds processing overhead

How to Encode and Decode Base64 Online

JSONHack provides a free, browser-based Base64 encoder and decoder. No data is uploaded — everything runs locally in your browser:

Try the Base64 Encoder/Decoder

Free, instant, and 100% browser-based — no uploads, no accounts needed.

Open Base64 Tool →