Skip to main content

Base64 Encode Decode Tool

Encode text to Base64 or decode Base64 strings back to plain text instantly. Enter values for instant results with step-by-step formulas.

Skip to calculator
Computer & IT

Base64 Encode Decode Tool

Encode text to Base64 or decode Base64 strings back to plain text instantly. Supports Unicode, URL-safe encoding, and provides detailed size analysis.

Last updated: December 2025

Calculator

Adjust values & calculate
45 characters
Base64 Output
SGVsbG8sIFdvcmxkISBUaGlzIGlzIGEgQmFzZTY0IGVuY29kaW5nIHRlc3Qu
Input Size
45 bytes
Output Size
60 chars
Size Ratio
133.3%
Special Characters
Yes
Unicode Content
No
URL-Safe Base64
SGVsbG8sIFdvcmxkISBUaGlzIGlzIGEgQmFzZTY0IGVuY29kaW5nIHRlc3Qu
Size Overhead: Base64 encoding added 33.3% to the original data size. This is expected as Base64 uses 4 characters to represent every 3 bytes of input.
Your Result
Encoded: 60 characters | Size ratio: 133.3%
Share Your Result
Understand the Math

Formula

Each 3 bytes of input become 4 Base64 characters (6 bits per character)

Base64 uses 64 printable characters (A-Z, a-z, 0-9, +, /) to represent binary data. Every 3 input bytes (24 bits) are split into 4 groups of 6 bits, each mapping to one Base64 character. Padding with = is added when the input length is not a multiple of 3 bytes.

Last reviewed: December 2025

Worked Examples

Example 1: Encoding a Simple Text String

Encode the string 'Hello, World!' to Base64.
Solution:
Input: Hello, World! (13 bytes) Convert to bytes: 72 101 108 108 111 44 32 87 111 114 108 100 33 Group into 3-byte chunks and convert to 4 Base64 chars: [72,101,108] -> SGVs [108,111,44] -> bG8s [32,87,111] -> IFdv [114,108,100] -> cmxk [33,pad,pad] -> IQ== Result: SGVsbG8sIFdvcmxkIQ== Output: 20 characters (54% overhead for short string) URL-safe: SGVsbG8sIFdvcmxkIQ
Result: Encoded: SGVsbG8sIFdvcmxkIQ== | 13 bytes input -> 20 chars output

Example 2: Decoding a Base64 JWT Payload

Decode the Base64 string 'eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0=' to reveal the JWT payload.
Solution:
Input: eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0= (52 chars) Decode Base64 to bytes, then UTF-8: Result: {"sub":"1234567890","name":"John Doe"} This is a JSON object typically found as the payload of a JSON Web Token (JWT), containing the subject ID and user name claims.
Result: Decoded: {"sub":"1234567890","name":"John Doe"} | Valid JSON payload
Expert Insights

Background & Theory

The Base64 Encode Decode Tool applies the following established principles and formulas. Computers represent all information using binary, a base-2 number system consisting solely of the digits 0 and 1, each called a bit. Because long binary strings are unwieldy, programmers routinely use octal (base 8) and hexadecimal (base 16) as compact shorthand. Converting between bases follows a consistent algorithm: divide the source number repeatedly by the target base, collecting remainders in reverse order. Hexadecimal digits A through F represent the values 10 through 15, allowing a single character to encode four binary bits, making it the preferred notation for memory addresses, color codes, and bytecode. Bitwise operations manipulate individual bits within integers. AND produces a 1 only when both input bits are 1, making it useful for masking. OR produces a 1 when either bit is 1 and is used for combining flags. XOR flips bits that differ, enabling simple toggle logic and efficient swap algorithms. NOT inverts every bit (one's complement), while left and right shifts multiply or divide by powers of two in constant time. Data storage units ascend in binary multiples of 1024: 8 bits form one byte, 1024 bytes form one kibibyte (KiB), 1024 KiB form one mebibyte (MiB), and so forth. Hard-drive manufacturers historically use decimal prefixes (1 KB = 1000 bytes), creating the persistent confusion between binary and decimal interpretations of the same label. The IEC standardized the binary prefixes KiB, MiB, GiB, and TiB in 1998 to resolve this ambiguity. Network bandwidth is measured in bits per second (bps), most commonly megabits per second (Mbps) or gigabits per second (Gbps). A 100 Mbps connection transfers 100 million bits every second, equating to roughly 12.5 megabytes per second. IP subnet masks define network boundaries; CIDR notation appends a prefix length (e.g., /24) to an address, indicating how many leading bits are fixed. A /24 subnet contains 256 addresses with 254 usable hosts. Algorithm efficiency is described using Big-O notation, which characterises the worst-case growth of time or space relative to input size. O(1) is constant, O(log n) is logarithmic (binary search), O(n) is linear, and O(nยฒ) is quadratic. Cryptographic hash functions like SHA-256 produce a fixed 256-bit (32-byte) digest regardless of input length. File compression algorithms exploit statistical redundancy to reduce storage footprint, and compression ratio equals the original file size divided by the compressed size.

History

The history behind the Base64 Encode Decode Tool traces back through the following developments. The conceptual foundation of modern computing traces back to Charles Babbage, whose Analytical Engine design of 1837 introduced the idea of a general-purpose mechanical computer with separate storage and processing units, including what he called the Store and the Mill. Ada Lovelace wrote what many consider the first algorithm intended for machine execution while annotating a translation of Luigi Menabrea's account of Babbage's work, also recognising the machine's potential to manipulate symbols beyond mere numbers. George Boole published "The Laws of Thought" in 1854, formalising a two-valued algebra of logic that would later map perfectly to electrical circuits. It remained largely a mathematical curiosity until Claude Shannon's landmark 1937 master's thesis demonstrated that Boolean algebra could describe switching circuits, laying the theoretical groundwork for all digital electronics. Shannon's 1948 paper "A Mathematical Theory of Communication" defined the bit as the fundamental unit of information and established information theory as a rigorous discipline. The same year, the transistor was invented at Bell Labs by Bardeen, Brattain, and Shockley, eventually replacing vacuum tubes and enabling miniaturisation at scale. ENIAC, completed in 1945, was one of the first general-purpose electronic computers, occupying 1800 square feet and consuming 150 kilowatts of power while performing roughly 5000 additions per second. The ASCII standard was ratified in 1963, assigning 7-bit codes to 128 characters and enabling interoperability between computers from different manufacturers. Through the 1970s, the microprocessor consolidated an entire CPU onto a single chip; Intel's 4004 in 1971 marked the beginning of this trend. The Apple II launched in 1977 and the IBM PC in 1981 brought computing to homes and offices, triggering a mass-market software industry. Tim Berners-Lee proposed the World Wide Web in 1989 and launched the first website in 1991 at CERN, transforming the internet from an academic and military network into a global information infrastructure. Mobile computing accelerated through the 2000s with smartphones integrating powerful processors, wireless networking, and GPS into pocket-sized devices, extending computation into every facet of daily life and cementing TCP/IP as the universal communications fabric.

Share this calculator

Explore More

Frequently Asked Questions

Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters: A-Z, a-z, 0-9, plus (+), and forward slash (/), with equals (=) used for padding. It was designed to safely transmit binary data through systems that only support text, such as email protocols (MIME), XML documents, JSON payloads, and URL parameters. Without Base64, binary data like images, files, or encrypted content would get corrupted when transmitted through text-only channels because certain byte values would be interpreted as control characters. Base64 increases the data size by approximately 33 percent but guarantees that the encoded output consists entirely of safe, printable characters that will survive transit through any text-based system.
Base64 encoding works by taking every three bytes (24 bits) of input data and splitting them into four groups of six bits each. Each six-bit group maps to one of 64 characters in the Base64 alphabet. Since 2 to the 6th power equals 64, six bits can represent exactly one Base64 character. When the input length is not a multiple of three bytes, the encoder adds padding characters (equals signs) to make the output length a multiple of four characters. One byte of input becomes two Base64 characters plus two padding characters. Two bytes become three Base64 characters plus one padding character. Three bytes become exactly four Base64 characters with no padding needed. This is why Base64 encoded data is always approximately 33 percent larger than the original binary data.
Standard Base64 uses plus (+) and forward slash (/) as two of its 64 characters, and equals (=) for padding. These characters have special meanings in URLs: plus represents a space, forward slash is a path separator, and equals separates parameter names from values. URL-safe Base64 (also called Base64url per RFC 4648) replaces plus with hyphen (-) and forward slash with underscore (_), and typically omits the padding equals signs entirely. This variant is essential for embedding encoded data in URLs, filenames, and other contexts where standard Base64 characters would cause parsing problems. JSON Web Tokens (JWTs) use URL-safe Base64 for their header, payload, and signature components, making it one of the most commonly encountered variants in modern web development.
No, Base64 encoding is absolutely not encryption and provides zero security. It is a reversible encoding scheme that anyone can decode instantly without any key or secret. Base64 transforms data into a different representation format but does not hide or protect the information in any way. Thinking of Base64 as encryption is a dangerous misconception that has led to real security vulnerabilities in production software. If you need to protect sensitive data, use proper encryption algorithms like AES-256 for symmetric encryption or RSA for asymmetric encryption, combined with secure key management practices. Base64 is often used as the final step after encryption to convert the encrypted binary ciphertext into a text-safe format for transmission, but the security comes entirely from the encryption layer, not from the Base64 encoding.
The 33 percent size increase is an inherent mathematical consequence of how Base64 maps binary data to printable characters. Original binary data uses all 256 possible byte values (8 bits per byte), but Base64 only uses 64 characters (6 bits of information per character). This means every 3 bytes of input (24 bits) become 4 Base64 characters (24 bits of information encoded in 32 bits of text). The ratio is 4/3, which is approximately 1.333, representing a 33.3 percent increase. Additionally, line breaks are sometimes inserted every 76 characters per the MIME standard (RFC 2045), which adds further overhead. Padding characters at the end can add up to 2 extra characters. For large files, this overhead is significant, which is why Base64 encoding is typically used for small payloads rather than large file transfers.
Base64 is ubiquitous in modern web development across many contexts. Data URIs embed small images directly in HTML or CSS using the format data:image/png;base64 followed by the encoded image data, eliminating extra HTTP requests. Email attachments are encoded in Base64 per the MIME standard. JSON Web Tokens use Base64url encoding for their three components (header, payload, signature). API authentication often uses Base64 for HTTP Basic Auth where the username and password are combined and encoded. Client-side JavaScript uses btoa() and atob() functions for encoding and decoding respectively. SVG images can be inlined as Base64 data URIs. Source maps in minified JavaScript files use Base64-encoded mappings. Font files can be embedded in CSS using Base64 data URIs for single-request page loads.
Educational Note: This calculator is provided for educational and informational purposes. Results are based on the formulas and inputs provided. Always verify important calculations independently. NovaCalculator processes calculator inputs client-side; optional analytics follow visitor consent settings. ยฉ 2024โ€“2026 NovaCalculator.

Share this calculator

Formula

Each 3 bytes of input become 4 Base64 characters (6 bits per character)

Base64 uses 64 printable characters (A-Z, a-z, 0-9, +, /) to represent binary data. Every 3 input bytes (24 bits) are split into 4 groups of 6 bits, each mapping to one Base64 character. Padding with = is added when the input length is not a multiple of 3 bytes.

Worked Examples

Example 1: Encoding a Simple Text String

Problem: Encode the string 'Hello, World!' to Base64.

Solution: Input: Hello, World! (13 bytes)\nConvert to bytes: 72 101 108 108 111 44 32 87 111 114 108 100 33\n\nGroup into 3-byte chunks and convert to 4 Base64 chars:\n[72,101,108] -> SGVs [108,111,44] -> bG8s [32,87,111] -> IFdv\n[114,108,100] -> cmxk [33,pad,pad] -> IQ==\n\nResult: SGVsbG8sIFdvcmxkIQ==\nOutput: 20 characters (54% overhead for short string)\nURL-safe: SGVsbG8sIFdvcmxkIQ

Result: Encoded: SGVsbG8sIFdvcmxkIQ== | 13 bytes input -> 20 chars output

Example 2: Decoding a Base64 JWT Payload

Problem: Decode the Base64 string 'eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0=' to reveal the JWT payload.

Solution: Input: eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0= (52 chars)\n\nDecode Base64 to bytes, then UTF-8:\nResult: {\"sub\":\"1234567890\",\"name\":\"John Doe\"}\n\nThis is a JSON object typically found as the payload\nof a JSON Web Token (JWT), containing the subject ID\nand user name claims.

Result: Decoded: {\"sub\":\"1234567890\",\"name\":\"John Doe\"} | Valid JSON payload

Frequently Asked Questions

What is Base64 encoding and why is it used?

Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters: A-Z, a-z, 0-9, plus (+), and forward slash (/), with equals (=) used for padding. It was designed to safely transmit binary data through systems that only support text, such as email protocols (MIME), XML documents, JSON payloads, and URL parameters. Without Base64, binary data like images, files, or encrypted content would get corrupted when transmitted through text-only channels because certain byte values would be interpreted as control characters. Base64 increases the data size by approximately 33 percent but guarantees that the encoded output consists entirely of safe, printable characters that will survive transit through any text-based system.

How does Base64 encoding work technically?

Base64 encoding works by taking every three bytes (24 bits) of input data and splitting them into four groups of six bits each. Each six-bit group maps to one of 64 characters in the Base64 alphabet. Since 2 to the 6th power equals 64, six bits can represent exactly one Base64 character. When the input length is not a multiple of three bytes, the encoder adds padding characters (equals signs) to make the output length a multiple of four characters. One byte of input becomes two Base64 characters plus two padding characters. Two bytes become three Base64 characters plus one padding character. Three bytes become exactly four Base64 characters with no padding needed. This is why Base64 encoded data is always approximately 33 percent larger than the original binary data.

What is the difference between standard Base64 and URL-safe Base64?

Standard Base64 uses plus (+) and forward slash (/) as two of its 64 characters, and equals (=) for padding. These characters have special meanings in URLs: plus represents a space, forward slash is a path separator, and equals separates parameter names from values. URL-safe Base64 (also called Base64url per RFC 4648) replaces plus with hyphen (-) and forward slash with underscore (_), and typically omits the padding equals signs entirely. This variant is essential for embedding encoded data in URLs, filenames, and other contexts where standard Base64 characters would cause parsing problems. JSON Web Tokens (JWTs) use URL-safe Base64 for their header, payload, and signature components, making it one of the most commonly encountered variants in modern web development.

Is Base64 encoding the same as encryption?

No, Base64 encoding is absolutely not encryption and provides zero security. It is a reversible encoding scheme that anyone can decode instantly without any key or secret. Base64 transforms data into a different representation format but does not hide or protect the information in any way. Thinking of Base64 as encryption is a dangerous misconception that has led to real security vulnerabilities in production software. If you need to protect sensitive data, use proper encryption algorithms like AES-256 for symmetric encryption or RSA for asymmetric encryption, combined with secure key management practices. Base64 is often used as the final step after encryption to convert the encrypted binary ciphertext into a text-safe format for transmission, but the security comes entirely from the encryption layer, not from the Base64 encoding.

Why does Base64 increase the data size by 33 percent?

The 33 percent size increase is an inherent mathematical consequence of how Base64 maps binary data to printable characters. Original binary data uses all 256 possible byte values (8 bits per byte), but Base64 only uses 64 characters (6 bits of information per character). This means every 3 bytes of input (24 bits) become 4 Base64 characters (24 bits of information encoded in 32 bits of text). The ratio is 4/3, which is approximately 1.333, representing a 33.3 percent increase. Additionally, line breaks are sometimes inserted every 76 characters per the MIME standard (RFC 2045), which adds further overhead. Padding characters at the end can add up to 2 extra characters. For large files, this overhead is significant, which is why Base64 encoding is typically used for small payloads rather than large file transfers.

Where is Base64 commonly used in web development?

Base64 is ubiquitous in modern web development across many contexts. Data URIs embed small images directly in HTML or CSS using the format data:image/png;base64 followed by the encoded image data, eliminating extra HTTP requests. Email attachments are encoded in Base64 per the MIME standard. JSON Web Tokens use Base64url encoding for their three components (header, payload, signature). API authentication often uses Base64 for HTTP Basic Auth where the username and password are combined and encoded. Client-side JavaScript uses btoa() and atob() functions for encoding and decoding respectively. SVG images can be inlined as Base64 data URIs. Source maps in minified JavaScript files use Base64-encoded mappings. Font files can be embedded in CSS using Base64 data URIs for single-request page loads.

References

Reviewed by Daniel Agrici, Founder & Lead Developer ยท Editorial policy