Base64 Encoder Decoder
Encode text or files to Base64 and decode Base64 strings back to text or files. Supports standard and URL-safe variants. Everything runs in your browser — nothing is uploaded.
Why use our online Base64 Encoder Decoder?
Convert text or binary data to Base64 and back instantly in your browser. Useful for embedding images in CSS, encoding API credentials, or debugging encoded payloads — zero upload needed.
How to use Base64 Encoder Decoder
- 1Choose encode or decode
Select the Encode tab to convert text or a file to Base64, or the Decode tab to convert a Base64 string back to its original form.
- 2Enter your input
Paste text into the input field, or drag and drop a file onto the upload area to encode it as a Base64 data URI.
- 3Select the Base64 variant
Choose between standard Base64 (RFC 4648) or URL-safe Base64 (which replaces + with - and / with _ to avoid URL encoding issues).
- 4Copy or download the output
The result appears instantly. Use the Copy button to copy the Base64 string, or download the decoded file if you decoded a data URI.
What Base64 actually does and why it exists
Base64 encoding converts binary data into a sequence of 64 printable ASCII characters. It works by taking every 3 bytes of input (24 bits) and splitting them into four 6-bit groups. Each 6-bit group maps to one of 64 characters: uppercase letters A–Z, lowercase letters a–z, digits 0–9, and the symbols + and / (with = used for padding when the input length is not divisible by 3).
The reason Base64 exists is historical. Many early protocols — SMTP for email, HTTP headers, XML, JSON — were designed to carry text only. Binary data like images, certificates, or executable files could not be reliably transmitted because some byte values (especially those below 32) were interpreted as control characters by the protocol layer. Base64 solves this by mapping all binary values to printable characters that are safe in any text context.
The 33% size increase (3 bytes in → 4 characters out) is the trade-off for this compatibility guarantee. Modern binary-safe protocols like HTTP/2 do not need Base64 for body data, but Base64 remains ubiquitous for embedding in text fields, data URIs, and credentials.
Standard vs URL-safe Base64 — when it matters
Standard Base64 uses + and / as its 62nd and 63rd characters. This is a problem in URLs: + means a space in application/x-www-form-urlencoded format (used by HTML forms), and / is a path separator. When Base64-encoded data appears in a URL, these characters must be percent-encoded as %2B and %2F — making the URL longer and harder to read.
URL-safe Base64 (also called Base64url, defined in RFC 4648 §5) replaces + with - and / with _, making the output safe to include directly in URLs and filenames without any escaping. It also typically omits the = padding characters, since URL query parameters don't need them.
Real-world uses of URL-safe Base64 include: JWT tokens (all three parts are Base64url-encoded), OAuth state parameters, email confirmation tokens in URLs, and file names derived from content hashes. Standard Base64 is used for: MIME email attachments, data URIs (data:image/png;base64,...), X.509 certificates, and HTTP Basic Authentication headers (which use the standard + and / and transmit over HTTPS).
Base64 in practice — data URIs and API credentials
The most visible everyday use of Base64 is data URIs: a way to embed image or file data directly in HTML, CSS, or JavaScript without a separate HTTP request. A data URI looks like data:image/png;base64,[...encoded bytes...]. Browsers decode and display it as if it were a URL to an external file.
Data URIs are useful for embedding small icons and assets in inline CSS or HTML emails (which block external URLs). The trade-off: Base64 images are 33% larger than the binary original, cannot be cached separately by the browser, and increase the size of the HTML document. For large images, a separate file with caching headers is always more efficient.
API credentials (like HTTP Basic Authentication) are also Base64-encoded: the username:password pair is encoded and sent in the Authorization: Basic [base64] header. Crucially, Base64 is not encryption — anyone who intercepts the header can decode it in seconds. Basic Auth headers must always be sent over HTTPS, never over plain HTTP.
Base64 in modern web development — JWTs, OAuth tokens, and binary storage
JSON Web Tokens (JWTs) use Base64url encoding for all three of their components: the header, payload, and signature are each encoded as Base64url strings joined by dots. The header and payload are plain JSON objects that any tool (including this one) can decode — they are not encrypted, just encoded. Never store sensitive data in a JWT payload unless the token is encrypted (JWE) rather than merely signed (JWS). The signature section is a cryptographic hash and cannot be decoded into meaningful content without the private key.
OAuth 2.0 client credentials use Base64 to encode the client_id:client_secret pair for the Authorization header in token requests, following the same pattern as HTTP Basic Auth. When debugging OAuth flows, decoding the Authorization header with this tool reveals the credentials being sent.
For binary data storage in text-based systems, Base64 is used to store images, documents, and arbitrary bytes in JSON fields, SQL VARCHAR columns, HTML attributes (data-image="..."), and localStorage. The trade-off is always the 33% size overhead. For browser localStorage (5–10 MB limit per origin), storing a Base64-encoded image uses 33% more of the quota than storing the equivalent binary in an IndexedDB blob. When storage or bandwidth is constrained, prefer storing files in IndexedDB or serving them as URLs rather than encoding them as Base64 strings.
Frequently Asked Questions
What is Base64 encoding used for?
- Base64 is used to safely transmit binary data (like images or files) over text-based protocols such as email, JSON APIs, or data URIs in CSS and HTML.
What is the difference between standard and URL-safe Base64?
- Standard Base64 uses + and / characters, which have special meanings in URLs and must be percent-encoded. URL-safe Base64 replaces these with - and _ so the output can be used directly in URLs and filenames without escaping.
Does Base64 compress data?
- No. Base64 encoding increases the data size by approximately 33%. It is used for encoding safety, not compression.
Is this tool free and does it require sign-up?
- Yes, it is completely free with no sign-up required. All encoding and decoding runs locally in your browser — nothing is sent to a server.
Related Tools
JSON Formatter
Clean, minify, and validate JSON data structures.
HTML Entity
Encode special chars to HTML entities and decode back.
Unix Timestamp
Unix timestamps to human dates, multiple timezones.
Regex Tester
Real-time expression matching and testing.
Password Gen
Highly secure, random entropy generation.