Base64 Encoder / Decoder
Encode text or files to Base64, or decode Base64 back to plain text. Supports URL-safe Base64 and file-to-Base64 conversion.
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters: A–Z, a–z, 0–9, and the symbols + and / (with = as padding). It was designed to safely transmit binary data — such as images, audio files, or encryption keys — through systems that were originally designed to handle only text, such as email (SMTP), HTTP headers, and XML. The name "Base64" comes from the fact that 64 characters are used as the encoding alphabet.
The encoding process works by grouping the input bytes into sets of 3 (24 bits total), then splitting each group into four 6-bit values, each mapped to one of the 64 characters. This means every 3 bytes of binary input becomes exactly 4 Base64 characters, resulting in approximately 33% size overhead compared to the original binary data. If the input length is not divisible by 3, = padding characters are added to make the output length a multiple of 4.
Base64 is not encryption — it is an encoding scheme, meaning anyone can decode it without a key. It is widely used in JWT tokens, email attachments (MIME), embedding images in HTML/CSS as data URLs, storing binary data in JSON, and HTTP Basic Authentication. URL-safe Base64 (Base64url) replaces + with - and / with _ to avoid conflicts with URL-reserved characters, and is used in JWTs and OAuth tokens.
Common Base64 Use Cases
Embed Image in HTML/CSS
Convert image files to Base64 data URLs to embed them directly in HTML img tags or CSS background-image properties — no separate file request.
data:image/png;base64,iVBORw0…
HTTP Basic Auth Header
HTTP Basic Authentication encodes credentials as Base64 in the Authorization header. The format is Base64("username:password").
Authorization: Basic dXNlcjpwYXNz
JWT Token Payload
JSON Web Tokens (JWT) use URL-safe Base64 encoding (Base64url) for the header and payload segments, separated by dots.
eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOi…
How the Base64 Encoder/Decoder Works
Formula, assumptions, and calculation steps for this dev tools tool.
Formula Used
Encodes 3 bytes of input into 4 Base64 characters using the standard 64-character alphabet
Methodology
Groups input bytes into 3-byte blocks and maps each 6-bit segment to a character in the standard Base64 alphabet, or reverses the process to decode.
Calculation Steps
- Provide the input text or select generation options.
- Apply the selected encoding, parsing, hashing, or formatting rule.
- Validate the output where possible.
- Return copy-ready developer output.
Assumptions and Limits
- Generated or transformed output depends exactly on the supplied input.
- Security-sensitive values should be handled carefully.
- Browser tools do not replace production validation.
Frequently Asked Questions
Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). It is used to transmit binary data over channels that only support text, such as email (MIME), JSON APIs, and HTML attributes.
Standard Base64 uses + and / characters, which have special meaning in URLs. URL-safe Base64 (Base64url) replaces + with - and / with _, making the output safe to include in URLs and HTTP headers without percent-encoding. JWT tokens use Base64url encoding.
Base64 encodes every 3 bytes of input as 4 ASCII characters (a 4/3 ratio). This means Base64 output is always approximately 33% larger than the original binary data. Padding characters (=) are added to make the output length a multiple of 4.
No. Base64 is an encoding scheme, not encryption. It is trivially reversible — anyone can decode Base64 without a key. It is used for format compatibility, not security. Never use Base64 to hide sensitive data.
Real-World Applications of Base64 Encoding
Common Base64 Mistakes to Avoid
References
- IETF RFC 4648. The Base16, Base32, and Base64 Data Encodings. tools.ietf.org/html/rfc4648
- IETF RFC 7519. JSON Web Token (JWT). tools.ietf.org/html/rfc7519
- IETF RFC 2045. MIME Part One: Format of Internet Message Bodies. tools.ietf.org/html/rfc2045
- MDN Web Docs. Base64 encoding and decoding. developer.mozilla.org
- IETF RFC 7617. The 'Basic' HTTP Authentication Scheme. tools.ietf.org/html/rfc7617
Related Calculators
Browse all Dev Tools calculators →URL Encoder/Decoder
Encode and decode URLs, query strings, and special characters.
JSON Formatter
Format, validate, minify, and convert JSON to YAML or CSV.
Hash Generator
Generate MD5, SHA-1, SHA-256, and SHA-512 hashes from any text.