Base64 Encoding Explained: What It Is and How It Works
Base64 turns binary into 64 safe ASCII characters, at a 33% size cost. How the encoding works, what padding is for, and how Base64URL differs.
ProfitTool Team
Security & Dev
Why Base64 Exists
Many protocols and formats — HTTP headers, JSON, HTML attributes, email bodies — are designed to carry text, not arbitrary binary data. If you try to embed binary data (like an image or a cryptographic key) directly in a text field, the binary bytes may contain control characters or bytes that break the surrounding format.
Base64 solves this by converting binary data into a set of 64 printable ASCII characters, making the data safe to embed anywhere that accepts text.
How It Works
Base64 takes 3 bytes (24 bits) of input and encodes them as 4 characters from a 64-character alphabet:
A-Z (26) + a-z (26) + 0-9 (10) + + and / (2) = 64 charactersIf the input is not a multiple of 3 bytes, = padding characters are appended to make the output length a multiple of 4.
Example:
Input: "Man" → M (77) a (97) n (110)
Binary: 01001101 01100001 01101110
Groups: 010011 010110 000101 101110
Base64: T W F u → "TWFu"A 3-byte input becomes 4 characters. Every 3 bytes → 4 characters. The encoded size is always ⌈n/3⌉ × 4 bytes.
Base64URL (RFC 4648 §5)
Standard Base64 uses + and /, which are special characters in URLs and file paths. Base64URL replaces them:
+→-/→_- Padding
=is usually omitted
Base64URL is used in JWTs, OAuth tokens, URL-safe tokens, and web API parameters.
Base64 Is Not Encryption
Base64 is an encoding, not encryption. It does not provide any confidentiality. Anyone can decode Base64 instantly without any key. Never use Base64 alone to protect sensitive data.
Use our Base64 Encoder / Decoder to encode and decode both standard Base64 and Base64URL, entirely in your browser.
ProfitTool Team
Security & DevWritten and maintained by the ProfitTool team. Where an article references a ProfitTool utility, the behaviour described is the behaviour of the tool on this site — you can open it and check the output yourself.
More from the Knowledge Hub
How to Decode a JWT Token (Without a Library)
You can decode a JWT token in any language using nothing but base64url decoding and JSON parsing. Here is how to do it in JavaScript, Python and the browser.
Developer ToolsDemystifying Cron Schedules: How to Generate and Debug Linux Crontabs with AI
A complete engineer's reference to cron expressions. Learn crontab syntax, special strings (@daily, @reboot), timezones, and how to generate schedule expressions with AI.
Developer ToolsFrom Natural Language to Complex PostgreSQL Joins: The Developer's AI SQL Playbook
How to write, debug, and optimize complex SQL queries using AI. Learn window functions, CTEs, index hints, and natural language to SQL translation.