Base64 Encoder/Decoder

What Is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It converts binary data into a set of 64 printable characters: A–Z, a–z, 0–9, plus (+), and slash (/), with equals (=) used for padding.

Base64 is commonly used when binary data needs to be transmitted over media that are designed to handle text. This includes email attachments, embedding images in HTML/CSS, JSON Web Tokens (JWT), and data URLs.

The encoding increases the data size by approximately 33%, but it ensures that the data remains intact without modification during transport through systems that may not handle binary cleanly.

How to Use This Base64 Tool

  1. Encode: Enter any text in the input field. The tool automatically converts it to Base64 format.
  2. Decode: Paste a Base64 string to convert it back to plain text.
  3. Copy: Click the copy button to copy the result to your clipboard.
  4. Clear: Use the clear button to reset both fields and start over.

Base64 Encoding Examples

Hello World

Text: Hello World

Base64: SGVsbG8gV29ybGQ=

ToolYard

Text: ToolYard

Base64: VG9vbFlhcmQ=

Numbers

Text: 12345

Base64: MTIzNDU=

Notice how the equals sign (=) appears at the end of some encoded strings. This is padding added when the input length is not a multiple of 3 bytes.

Common Use Cases

Use CaseExampleWhy Base64?
Email AttachmentsMIME encoding for images/filesTransmits binary data through text-only email
Data URLsdata:image/png;base64,iVBOR...Embeds small images in HTML/CSS without HTTP requests
JSON Web TokenseyJhbGciOiJIUzI1NiIs...Encodes header/payload in URL-safe format
API RequestsAuthorization: Basic dXNlcjpwYXNzHTTP Basic authentication header
Configuration FilesAPI keys, certificates in YAML/JSONStores binary data in text config files

Base64 Character Set Reference

IndexCharacterBinaryIndexCharacter
0A00000032g
1B00000133h
2C00001034i
25Z011001575
26a011010586
51z110011597
520110100608
61911110162+
63/111111Pad=

Base64 vs Base64Url

Standard Base64 uses + and / characters, which can cause issues in URLs because they have special meanings (+ becomes a space, / is a path separator).

Base64Url (URL-safe Base64) replaces + with - and / with _, and often omits padding. This makes it safe to use in URLs and filenames without additional encoding.

Comparison:

  • Standard: SGVsbG8gV29ybGQ= (contains +, /, =)
  • Base64Url: SGVsbG8gV29ybGQ (uses -, _, no padding)

When to Use Base64

  • Email attachments: MIME (Multipurpose Internet Mail Extensions) uses Base64 to encode binary files for email transmission.
  • Data URLs: Embedding small images directly in HTML or CSS as data:image/png;base64,... to reduce HTTP requests.
  • APIs and JSON: Encoding binary data in JSON payloads that only support text.
  • JWT tokens: JSON Web Tokens use Base64Url encoding for their header and payload sections.
  • URL parameters: Safely encoding binary data for transmission in URLs (use Base64Url variant).
  • Configuration files: Storing certificates, API keys, or binary settings in text-based config files.

Tips for Working with Base64

Size increase: Expect Base64 encoding to increase data size by about 33%. A 1MB file becomes roughly 1.33MB when encoded. Factor this in when embedding large files.

Not encryption: Base64 is encoding, not encryption. Anyone can decode it instantly. Never use Base64 to protect sensitive data — use proper encryption instead.

Line breaks: Some systems add line breaks every 76 characters (RFC 2045). If decoding fails, try removing all whitespace first.

UTF-8: Base64 operates on bytes. When encoding text, it uses UTF-8 by default. Ensure both encoder and decoder use the same character encoding.

Frequently Asked Questions

What is Base64 encoding used for?

Base64 is used to encode binary data as text for transmission over protocols that only support text (like email), for embedding images in HTML/CSS, and for encoding data in JSON Web Tokens (JWT).

Does Base64 encryption make data secure?

No. Base64 is encoding, not encryption. It is easily reversible and provides no security. Use encryption for sensitive data.

Why does Base64 output have equals signs?

The equals signs (=) are padding characters. Base64 requires input to be a multiple of 3 bytes, so padding is added when the input isn't divisible by 3.

Related Tools