$devtoolkit.sh/examples/encoding/base64-common

Common Base64 Encoding Examples

Base64 encoding is used in dozens of everyday web contexts including HTTP Basic Auth headers, JWT tokens, data URIs, and cookie values. This collection shows the Base64 encoded form of common input types so you can recognize and decode them when they appear in logs or headers. The encoder processes UTF-8 text correctly, including characters outside the ASCII range. Remember that standard Base64 uses = padding characters that must be stripped when the value is used in a URL query string.

Example
# HTTP Basic Auth header value
user:password → dXNlcjpwYXNzd29yZA==

# JSON object
{"key":"value"} → eyJrZXkiOiJ2YWx1ZSJ9

# Simple string
Hello, World! → SGVsbG8sIFdvcmxkIQ==

# API key format
Bearer sk-example → QmVhcmVyIHNrLWV4YW1wbGU=

# Email address
[email protected] → dXNlckBleGFtcGxlLmNvbQ==
[ open in Base64 Encode → ]

FAQ

Why does Base64 output always end with = or ==?
Base64 works in groups of 3 bytes, encoding them as 4 characters. When the input length is not divisible by 3, = padding characters are added to make the output length divisible by 4.
How do I use Base64 in an HTTP Authorization header?
For Basic Auth, concatenate username and password with a colon, Base64 encode the result, and set the header as: Authorization: Basic dXNlcjpwYXNzd29yZA==. The server decodes and splits on the colon.
Can Base64 encode binary files?
Yes. Base64 is designed for binary data. Encoding a binary file (image, PDF) to Base64 allows it to be embedded in JSON, HTML data URIs, or transmitted through text-based protocols like SMTP.

Related Examples

/examples/encoding/base64-commonv1.0.0