Base64 Encode / Decode

Base64 Encode / Decode

Convert text to Base64 format or decode Base64 back to readable text — fast, private, and free.

Plain Text Input
0 chars 0 bytes 1 line(s)
Swap
Base64 Output
Output will appear here...
0 chars 0 bytes ratio
Input Size
0 B
Output Size
0 B
Compression
Process Time
0 ms
How Base64 Encoding Works

Every 3 bytes of input are split into 4 groups of 6 bits, each mapped to a printable character from the Base64 alphabet.

Input Text
"Cat"
ASCII Bytes
67 97 116
Binary
01000011 01100001 01110100
6-bit Groups
010000 110110 000101 110100
Decimal
16 · 54 · 5 · 52
Base64
Q2F0
Base64 Character Set (64 chars) A B C D E F G H I J K L M N O P Q R S T U V W X Y Z   a b c d e f g h i j k l m n o p q r s t u v w x y z   0 1 2 3 4 5 6 7 8 9   + /  (URL-safe: + → - , / → _ )

About Base64

Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters. It is commonly used to embed images in HTML/CSS, transmit data over JSON, and store binary data in text-based formats.

  • Encoding increases size by approximately 33%
  • Every 3 bytes of input becomes 4 characters of output
  • Padding uses the = character when needed
  • URL-safe variant replaces + and / with - and _

Privacy & Security

All encoding and decoding happens 100% in your browser. No data is uploaded to any server — your input never leaves your device. This tool is safe for sensitive content.

  • Works completely offline after first load
  • No tracking, no cookies, no analytics
  • Supports Unicode / UTF-8 characters
  • Handles large inputs (up to several MB)
Copied!

Base64 Encode / Decode Calculator: Complete Guide for 2026

Published on Calculators4All.com — your home for free, browser-based tools.

 

Introduction

The Base64 Encode / Decode Calculator is a free online tool that converts plain text into Base64 format and translates Base64 strings back into readable text. Everything runs inside your browser. Nothing is uploaded, stored, or tracked. Whether you are debugging an API response, inspecting a JSON Web Token, or trying to figure out what that long string of letters in an email header actually says, this tool gives you instant, accurate results.

 

People use Base64 encoding far more often than they realize. It hides behind email attachments, image data URIs, HTTP authentication headers, configuration files, and many authentication tokens. Anytime a system needs to move binary data through a channel that was built only for text, Base64 is usually the answer.

 

This calculator is built for a wide audience. Developers use it to inspect API responses, debug tokens, and test encoding behavior. Email administrators use it to verify attachments. Cybersecurity analysts use it to decode suspicious strings during investigations. Teachers and students use it to learn how binary data is represented. Content creators use it to embed small images directly into HTML or CSS.

 

The benefits are obvious from the first click. You get instant results without installing software. You can switch between encoding and decoding with one click. You can copy output to your clipboard, download it as a file, or swap input and output with a single button. Advanced options like URL-safe mode and padding removal give you control over the result.

 

In real life, this calculator helps with tasks such as decoding the payload of a JWT to inspect user claims, embedding a small logo into a website using a data URI, verifying that an email attachment was encoded correctly, or safely passing binary data through a URL. It also shines when you receive a Base64 string from a colleague or API and just want to know what it says.

 
 

Image suggestion: Hero image showing the calculator interface with sample input “Hello, World!” and output “SGVsbG8sIFdvcmxkIQ==”, with a soft green theme matching the tool.


What is Base64 Encode / Decode?

Base64 is a binary-to-text encoding scheme that takes binary data and represents it using only 64 printable ASCII characters. The name comes directly from the size of the alphabet. By limiting the character set to a known, safe group of symbols, Base64 makes it possible to send data through systems that were designed only for text.

 

The 64-character alphabet includes:

 
  • Uppercase letters A–Z (26 characters)
  • Lowercase letters a–z (26 characters)
  • Digits 0–9 (10 characters)
  • Two extra symbols, usually + and /
 

A 65th character, the equals sign =, is used as padding when the input length is not a multiple of three bytes.

 

The purpose of Base64 is not to encrypt or compress data. It is to make data transportable. Many older systems and protocols were built to handle only text. They treated certain byte values as control characters, which corrupted binary data passing through them. Base64 solved this by translating binary into a form that text-only systems could carry safely.

 

Base64 was formally described in RFC 1421 and later refined in RFC 2045, part of the MIME standard used by email systems. Today, the algorithm lives inside countless applications, from web browsers to enterprise software.

 

The importance of Base64 today is hard to overstate. Modern web development, email infrastructure, authentication systems, and many data interchange formats rely on it. Without it, embedding images in HTML, attaching files to email, or passing credentials in HTTP headers would be far more complicated.

 
 

Image suggestion: Infographic showing the 64-character Base64 alphabet grouped by uppercase, lowercase, digits, and symbols.


How This Calculator Works

This calculator takes an input string and runs it through a series of well-defined steps. The process differs slightly between encoding and decoding, but the underlying logic is the same algorithm in reverse.

 

Inputs

  • A text string entered in the input box, or a file uploaded through the upload icon
  • A mode selection: Encode or Decode
  • An option for URL-safe mode
  • An option to strip padding
  • A charset selection: UTF-8 or ASCII
 

Outputs

  • The converted text in the output panel
  • Character count for both input and output
  • Byte count for both input and output
  • The conversion ratio between input and output
  • The processing time in milliseconds
 

Formula / Algorithm

For encoding, the calculator follows this logic:

 
  1. Convert each character of the input into its byte value (UTF-8 by default).
  2. Group the bytes into blocks of three.
  3. Split each 24-bit block into four 6-bit groups.
  4. Map each 6-bit value to a character from the Base64 alphabet.
  5. Add padding (=) if the last group has fewer than three bytes.
 

For decoding, the steps run in reverse:

 
  1. Strip whitespace from the input.
  2. Validate that every character belongs to the Base64 alphabet.
  3. Convert each Base64 character back to its 6-bit value.
  4. Combine four 6-bit values into one 24-bit block.
  5. Split each 24-bit block back into three 8-bit bytes.
  6. Decode the resulting bytes back into text using the selected charset.
 

Variables and Units

  • 1 byte = 8 bits
  • 1 Base64 character = 6 bits of data
  • 3 input bytes = 4 output characters
 

The size increase from encoding is approximately 33%. A 3-byte input becomes a 4-character output.

 
 

Image suggestion: Workflow diagram showing the encoding pipeline: Text → Bytes → Binary → 6-bit groups → Base64 characters.


Formula Explained

The Base64 algorithm is best understood through its bitwise logic. There is no advanced math here — just careful binary manipulation.

 

The Core Idea

Every three bytes (24 bits) of input are split into four groups of 6 bits. Each 6-bit group can represent a value from 0 to 63, which maps cleanly to the 64-character Base64 alphabet.

 

Variable Explanation

  • b0, b1, b2: the three input bytes
  • triplet: a 24-bit value formed by combining the three bytes
  • g1, g2, g3, g4: the four 6-bit groups extracted from the triplet
 

Construction of the Triplet

text
 
 
triplet = (b0 << 16) | (b1 << 8) | b2
 
 

This means: shift the first byte 16 positions to the left, the second byte 8 positions to the left, and combine them with the third byte using a bitwise OR.

 

Extracting the 6-bit Groups

text
 
 
g1 = (triplet >> 18) & 0x3F
g2 = (triplet >> 12) & 0x3F
g3 = (triplet >> 6) & 0x3F
g4 = triplet & 0x3F
 
 

Each group is then mapped to a character from the alphabet: A–Z, a–z, 0–9, +, /.

 

Example Calculation: Encode “Cat”

Step 1: Find the byte values.

 
Char
Decimal
Binary
C6701000011
a9701100001
t11601110100

Step 2: Combine into one 24-bit string.

 
text
 
 
01000011 01100001 01110100
 
 

Step 3: Split into four 6-bit groups.

 
text
 
 
010000 110110 000101 110100
 
 

Step 4: Convert each to decimal and map to the alphabet.

 
Bits
Decimal
Char
01000016Q
110110542
0001015F
110100520

Step 5: Output the result.

 
text
 
 
“Cat” → Q2F0
 
 

Common Mistakes

  • Forgetting that padding (=) is required when the input length is not a multiple of three.
  • Confusing URL-safe Base64 (- and _) with standard Base64 (+ and /).
  • Assuming Base64 is encryption. It is not. Anyone can decode it.
  • Using the wrong character encoding (such as Latin-1 instead of UTF-8) for non-ASCII text.
 
 

Image suggestion: Formula diagram showing how “Cat” becomes “Q2F0” through binary grouping.


How to Use the Calculator

Using the Base64 Encode / Decode Calculator is simple. Follow these steps:

 
  1. Choose your mode. Click the Encode tab to convert text to Base64. Click the Decode tab if you have a Base64 string and want to read it.
  2. Enter your text. Type or paste your content into the input box on the left. You can also upload a file using the upload icon in the panel header.
  3. Adjust the options. Toggle URL-safe mode if you are working with web URLs. Toggle strip padding if you want to remove the trailing = characters. Choose UTF-8 for general text or ASCII for plain English characters.
  4. View the output. The result appears automatically in the right panel when live mode is on. Otherwise, click the Encode Now or Decode Now button.
  5. Copy or download. Use the copy button to place the result on your clipboard. Use the download button to save it as a text file.
  6. Swap if needed. Click the circular swap button in the middle to exchange input and output. This is useful for verifying round-trip accuracy.
  7. Check the stats. Look at the bottom of each panel and the stats bar to see character counts, byte counts, and the conversion ratio.
 

Field Explanations

  • Encode / Decode tabs: Switch the conversion direction.
  • URL-safe mode: Replaces + with - and / with _ for safer URL usage.
  • Strip padding: Removes the trailing = characters that some systems do not want.
  • Live convert: Updates output in real time as you type.
  • Charset selector: Choose how characters are interpreted at the byte level.
  • Upload button: Loads a small file directly as input.
  • Sample button: Fills the input with example data.
  • Reset button: Clears everything and restores defaults.
 

Tips

  • Use the sample button if you want to see how the calculator works before entering your own data.
  • Keep live mode on for instant feedback while typing.
  • For very large inputs, the calculator remains fast because all work is local.
 
 

Image suggestion: Screenshot placeholder of the calculator with annotations pointing to each major button and field.


Example Calculations

Beginner Example: Encoding “Hello”

Input
ASCII Bytes
Base64 Output
Hello72 101 108 108 111SGVsbG8=

Notice the trailing =. “Hello” is 5 bytes long, which is not a multiple of three. Two bytes (108, 111) are left over after the first triplet, so one = is added.

 

Intermediate Example: Encoding a Sentence

Encode “Hello, World!”.

 
  • Input: 13 characters
  • Output: SGVsbG8sIFdvcmxkIQ==
  • Two = signs are added because 13 mod 3 equals 1.
 

Advanced Example: Encoding Unicode

Encode “🌍 Hello”.

 
  • The globe emoji takes 4 bytes in UTF-8 (F0 9F 8C 8D).
  • The space and “Hello” take 6 bytes.
  • Total: 10 bytes.
  • Output: 8J+MjSBIZWxsbw==
 

This shows why choosing UTF-8 matters — without it, the emoji would not encode correctly.

 

Decoding Example

Decode “SGVsbG8sIFdvcmxkIQ==”.

 
  • Output: Hello, World!
 

URL-safe Comparison

Encode a binary sequence that produces + or / characters in standard Base64. With URL-safe mode on, those characters become - and _.

 
Mode
Example Output (snippet)
Standard...T+q/3Q==
URL-safe...T-q_3Q==
 

Image suggestion: Side-by-side example illustrations showing how the same input produces different outputs in standard vs. URL-safe mode.


Benefits

  1. Free to use. No subscriptions, no sign-ups, no hidden fees.
  2. Privacy first. All processing happens in your browser. No data is sent to a server.
  3. Works offline. After the first load, the calculator runs without an internet connection.
  4. Instant results. Live mode shows output as you type.
  5. Supports Unicode. Full UTF-8 support means emoji and international characters work.
  6. URL-safe option. Useful for web developers and API designers.
  7. Padding control. Toggle padding on or off depending on your use case.
  8. File support. Encode or decode small files directly without installing anything.
  9. Copy and download. Get your result into other tools quickly.
  10. Detailed stats. See character counts, byte counts, and ratios at a glance.
  11. Educational diagram. A built-in visual explains how the algorithm works.
  12. Mobile friendly. Works smoothly on phones and tablets.
  13. No ads inside the tool area. Focus stays on the work.
 

Features

The calculator includes the following features:

 
  • Encode and Decode modes. Switch directions with one click.
  • URL-safe Base64. Replace + and / with - and _.
  • Strip padding option. Remove trailing = characters when they are not needed.
  • Live mode. Convert as you type.
  • Charset selector. Choose UTF-8 or ASCII.
  • File upload. Load a small file as input.
  • Copy to clipboard. One-click copying of the result.
  • Download result. Save the output as a text file.
  • Swap button. Exchange input and output instantly.
  • Clear button. Empty the input box in one click.
  • Sample text. Load example data to test the tool.
  • Stats panels. Track characters, bytes, and lines.
  • How-it-works diagram. Visual explanation of the algorithm.
  • FAQ section. Quick answers to common questions.
 

Applications

Base64 is used across many industries. Here are some of the most common applications.

 

Web Development

Web developers embed small images, fonts, and other assets directly into HTML or CSS using data URIs. These URIs often use Base64 so the asset stays inside the document. This avoids extra HTTP requests and is useful for tiny icons and logos.

 

Email

Email attachments are stored in MIME format, which uses Base64 to encode binary files so they can travel through text-only mail servers. If you have ever received an email attachment that did not open correctly, decoding the Base64 payload is one way to inspect what was actually sent.

 

Authentication

HTTP Basic Authentication sends usernames and passwords encoded in Base64 inside the Authorization header. JSON Web Tokens (JWTs) also use Base64 URL-safe encoding for their header and payload sections. This calculator is a quick way to inspect those tokens.

 

Cybersecurity

Security analysts often find Base64 strings inside suspicious scripts, phishing emails, and malware payloads. Decoding them is a routine step in threat analysis. Our URL Encoder/Decoder is another useful tool for inspecting web traffic.

 

Education

Computer science teachers use Base64 as a hands-on example of binary data representation, bitwise operations, and character encoding. Students can encode their own name and trace each step of the algorithm.

 

Data Interchange

Some APIs return binary data — such as thumbnails or hashes — encoded in Base64 inside JSON responses. This keeps the response in a text format that any parser can read.

 

Configuration Files

Many configuration formats, including Kubernetes secrets, store sensitive values as Base64-encoded strings. This calculator helps administrators verify what value is actually stored.

 

Advantages

  • No installation required. The tool runs in any modern browser.
  • No registration. No account, no email, no tracking.
  • Cross-platform. Works on Windows, macOS, Linux, iOS, and Android.
  • Handles large inputs efficiently. Up to several megabytes process in milliseconds.
  • Deterministic. The same input always produces the same output.
  • Educational. The diagram and stats help users understand what is happening.
  • Reduces human error. No need to write code or use a terminal.
  • Saves time. Developers and students get answers in seconds.
  • Free and ad-light. The focus stays on the work.
  • Round-trip verification. The swap button lets you confirm nothing was lost.
 

Limitations

While the Base64 Encode / Decode Calculator is useful, it has some limits worth knowing.

 
  • Not encryption. Base64 is fully reversible. Do not use it to protect secrets.
  • Increases size. Encoded data is about 33% larger than the original.
  • No integrity check. The tool does not verify that data was not corrupted.
  • File size cap. For browser performance, very large files (over several megabytes) are not recommended.
  • Browser-only. The tool cannot run in environments that block JavaScript.
  • Manual validation. You must still confirm that decoded output is what you expect.
 

For strong data protection, use a real cipher such as AES, not Base64. You can also generate secure hashes with our SHA-256 Hash Generator when you need one-way verification.

 

Tips for Accurate Results

  • Pick the right charset. Use UTF-8 unless you are certain your input is pure ASCII.
  • Match options on both sides. If you encode with URL-safe mode on, decode with the same option.
  • Watch the padding. Some systems expect padding; others reject it.
  • Check for whitespace. Decoders usually ignore whitespace, but extra characters can break some implementations.
  • Validate output. After decoding, glance at the result to confirm it looks reasonable.
  • Test round trips. Encode, then decode, to verify nothing was lost.
  • Use sample text. Run the sample to confirm the calculator is working as expected.
  • Save your settings. If you are doing a batch of similar tasks, keep the same options for consistency.
 

Common Mistakes

  • Treating Base64 as encryption. It is encoding, not security.
  • Forgetting to switch modes. Trying to decode when encode is selected (or the reverse) leads to confusion.
  • Mixing standard and URL-safe variants. Decoding a URL-safe string with the standard alphabet can fail.
  • Ignoring the charset. Decoding Unicode text as ASCII produces wrong characters.
  • Pasting extra whitespace. Some inputs include trailing spaces that change the output.
  • Expecting compression. Base64 makes data larger, not smaller. For actual compression, look into gzip or our Data Storage Converter.
  • Skipping validation. Always confirm decoded output matches your expectation.
  • Using Base64 in URLs without URL-safe mode. The + and / characters can break URL parsing.
 

Frequently Asked Questions

What is Base64 used for?

Base64 is used to represent binary data using only printable ASCII characters. This makes it safe to send binary data through systems designed for text, such as email servers, JSON APIs, and HTTP headers. Common uses include email attachments, data URIs in HTML or CSS, JWT payloads, and HTTP Basic Authentication credentials.

 

Is Base64 encryption?

No. Base64 is encoding, not encryption. It does not use a key, and anyone can decode it. If you need to protect data, use a real encryption algorithm such as AES. Base64 is about transport, not secrecy.

 

Does Base64 compress data?

No. Base64 actually makes data larger by about 33%. Three bytes of input become four characters of output. If you need compression, look at gzip or zlib instead.

 

What is URL-safe Base64?

URL-safe Base64 replaces the characters + and / with - and _. This makes the output safe to use in URLs and file names without needing to escape those characters. JWTs use URL-safe Base64 by default.

 

Why does Base64 end with =?

The = character is padding. Base64 encodes data in groups of three bytes, but the input length is not always a multiple of three. Padding tells the decoder how many bytes the original input contained. One or two = characters can appear at the end.

 

Can I encode images with this tool?

Yes. You can upload a small image file and the tool will produce its Base64 representation, which you can embed in HTML or CSS as a data URI. For very large images, use a dedicated tool to avoid slow performance.

 

Is my data safe in this calculator?

Yes. All processing happens locally in your browser. No data is sent to any server. This makes the tool safe for sensitive content, although you should still avoid pasting truly sensitive material into any web page out of caution.

 

What is the difference between Base64 and hex encoding?

Base64 uses 64 characters and produces output about 33% larger than the input. Hex encoding uses only 16 characters and produces output 100% larger. Base64 is more compact; hex is easier for humans to read byte by byte. Try our Hex to ASCII Converter for hex work.

 

Does Base64 support Unicode?

Yes, when used with a UTF-8 byte representation. This calculator supports UTF-8 by default, so emoji and international characters encode correctly. Older tools that use Latin-1 may produce wrong results for non-ASCII characters.

 

How much larger is Base64 than the original?

Approximately 33%. For every 3 bytes of input, you get 4 characters of output. For example, 30 bytes become 40 characters. This is why Base64 is not a compression method.

 

What is the Base64 character set?

The standard set is A-Z, a-z, 0-9, +, and /, with = as padding. The URL-safe set replaces + with - and / with _. The alphabet was designed to avoid characters that cause problems in text-based systems.

 

Can I use Base64 in URLs?

Yes, but you should use URL-safe mode. Standard Base64 contains + and /, which can break URL parsing. URL-safe mode replaces them with - and _. You may also want to strip padding, depending on the receiving system.

 

How do I encode a JWT?

A JWT has three parts separated by dots: header, payload, and signature. The header and payload are Base64 URL-safe encoded JSON. Paste the middle part into the decoder with URL-safe mode on, and you will see the JSON claims.

 

What does the strip padding option do?

It removes the trailing = characters from the encoded output. Some systems, including JWT, do not use padding. Other systems expect it. Always match the option to what the receiving system requires.

 

Why did my Base64 decode fail?

The most common reasons are non-Base64 characters in the input, mismatched URL-safe mode, incorrect padding, or wrong charset selection. Remove any whitespace or hidden characters and try again. The error message in the output panel will explain what went wrong.

 

What is the difference between Base64 and UTF-8?

They serve different purposes. UTF-8 is a character encoding that represents text as bytes. Base64 is a binary-to-text encoding that represents bytes as printable ASCII. You can encode UTF-8 text into Base64, then decode it back to recover the same text.

 

Can Base64 encode binary files?

Yes. Any binary file can be encoded as Base64. This tool supports small files through the upload button. For very large files, use a command-line tool such as base64 on Linux or macOS.

 

Is Base64 the same as Base32?

No. Base32 uses 32 characters (A–Z and 2–7) and produces larger output than Base64. Base32 is used in systems where case sensitivity is a problem, such as human-typed codes.

 

How fast is this calculator?

Very fast. Most inputs process in under a millisecond because the work happens locally. Performance depends on input size, but even megabytes of text decode in well under a second on a modern computer.

 

Does this tool work offline?

After the first load, yes. The calculator runs entirely in your browser, so once the page is loaded, it can be used without an internet connection. This is useful for working with sensitive data on air-gapped machines.

 

Can I use Base64 for passwords?

Only for transport, never for storage. Storing Base64-encoded passwords is the same as storing them in plain text. Use a real password hash such as bcrypt or ArgonDB. For generating strong passwords, try our Password Generator.

 

What is the history of Base64?

Base64 grew out of earlier encoding schemes like uuencode and was formalized in RFC 2045 as part of the MIME standard in 1996. It has since become one of the most widely used binary-to-text encodings in computing.

 

How does Base64 compare to binary传输?

Base64 lets binary data travel through text-only channels, at the cost of 33% size increase. True binary transmission is more efficient but requires a channel that can handle arbitrary byte values. Base64 is the safe choice when you cannot guarantee binary support.

 

Related Calculators

If you found this Base64 tool useful, you might also like these calculators on our site:

 
  1. URL Encoder/Decoder — for percent-encoding URLs
  2. Text to Binary Converter — see the bits behind your text
  3. Binary to Text Converter — reverse of the above
  4. Hex to ASCII Converter — translate hex strings
  5. ASCII to Hex Converter — encode text as hex
  6. MD5 Hash Generator — generate MD5 checksums
  7. SHA-256 Hash Generator — secure one-way hashing
  8. Password Generator — create strong random passwords
  9. QR Code Generator — turn text into a QR image
  10. Data Storage Converter — bytes to KB, MB, GB
  11. File Size Converter — convert between units
  12. Character Counter — count characters and bytes
  13. Word Counter — count words and reading time
  14. Text Case Converter — change capitalization styles
  15. JSON Formatter — pretty-print JSON data
  16. Percentage Calculator — solve everyday percentages
 

Final Thoughts

The Base64 Encode / Decode Calculator is a small but powerful tool. It runs in your browser, keeps your data private, and gives you results in milliseconds. Whether you are a developer inspecting a JWT, a student learning about binary data, or just someone trying to decode a strange string, this calculator is built to help.

 

Take a moment to try the sample button if you have not used the tool yet. Paste your own text, watch the live output update, and explore the URL-safe and padding options. The built-in diagram shows you exactly what happens to your data at the bit level.

 

For any task that involves moving binary data through a text channel, Base64 remains one of the simplest and most reliable solutions. Pair it with the related tools above to cover the full range of encoding, hashing, and data conversion tasks you might run into. We are always adding more calculators to Calculators4All.com, so check back whenever you need a quick, trustworthy, browser-based tool.

 

Try the Base64 Encode / Decode Calculator above right now — your data never leaves your device, and the result appears the moment you start typing.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top