Base64 Encoder / Decoder
Encode any text string to Base64, or decode a Base64 string back to plain text. Commonly used for embedding images in HTML and CSS, encoding API credentials, and storing binary data in JSON or XML. Runs entirely in your browser.
Developer Tools Cluster
What This Tool Does
Encodes text or binary data to Base64 and decodes Base64 strings back to plain text, entirely in your browser. Supports standard Base64, URL-safe Base64, and handles Unicode input correctly.
Who This Is For
- Developers embedding images in HTML or CSS as data URIs to reduce HTTP requests
- Engineers encoding credentials for HTTP Basic Authentication headers (username:password)
- Anyone working with APIs that require Base64-encoded payloads or return encoded responses
- Security professionals encoding or decoding tokens and binary payloads during testing
Example: Input: A binary image file, or a text string like user:password → Output: The Base64-encoded string, e.g. dXNlcjpwYXNzd29yZA==, ready to use in headers or data URIs
How to Encode or Decode Base64
- Encode: paste your plain text into the input field and click Encode. The Base64 string appears in the output.
- Decode: paste a Base64 string into the input and click Decode. The plain text (or binary content) appears in the output.
- Click Copy to copy the result instantly.
The tool handles standard Base64 and URL-safe Base64. For CSV data, convert CSV to JSON before encoding, or validate JSON before Base64-encoding an API payload. (which uses - and _ instead of + and /). Both are available as output options.
What Is Base64 Encoding?
Base64 is an encoding scheme that converts binary data into a string of 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It is not encryption — it does not hide the data. Anyone with a Base64 string can decode it instantly.
The name comes from the 64 characters used in the encoding. Every 3 bytes of input data become 4 Base64 characters, so the encoded output is approximately 33% larger than the original.
| Property | Base64 | URL-Safe Base64 |
|---|---|---|
| Characters used | A–Z, a–z, 0–9, +, / | A–Z, a–z, 0–9, -, _ |
| Padding | = (at end) | = omitted or replaced |
| URL safe | No (+, / need escaping) | Yes |
| Used in | Email (MIME), data URLs | JWTs, OAuth tokens, URL parameters |
Where Is Base64 Used?
- JWT tokens — JSON Web Tokens use URL-safe Base64 to encode the header and payload. The three parts separated by
.are each Base64url encoded. - Data URLs — embed images or fonts directly in HTML or CSS:
url("data:image/png;base64,iVBORw..."). - Email attachments — the MIME standard uses Base64 to encode binary attachments as printable text for safe transmission through email servers.
- HTTP Basic Authentication — credentials are sent as Base64-encoded
username:passwordin theAuthorization: Basic ...header. - API payloads — binary data (images, files) embedded in JSON must be Base64 encoded, since JSON only supports text.
- Cryptographic keys — public and private keys are typically distributed as PEM files which contain Base64-encoded key data between header/footer lines.
Base64 in Code
| Language | Encode | Decode |
|---|---|---|
| JavaScript (browser) | btoa(str) | atob(str) |
| JavaScript (Node) | Buffer.from(str).toString("base64") | Buffer.from(b64, "base64").toString() |
| Python | base64.b64encode(b"data") | base64.b64decode(encoded) |
| PHP | base64_encode($str) | base64_decode($str) |
| Bash | echo -n "text" | base64 | echo "encoded" | base64 -d |
Note: btoa() and atob() in JavaScript only handle ASCII strings. For Unicode text or binary files, use Buffer in Node.js or the TextEncoder API in browsers.
Encoding Workflow Tools
Base64 encoding is used throughout web development and authentication:
- Decode JWT tokens — JWTs are Base64url-encoded JSON
- URL-encode strings — a complementary encoding for query parameters
- Generate a hash before encoding for data integrity
- Format the decoded JSON after decoding a Base64-encoded JSON payload
Related Tools
- Decoded a Base64-encoded CSV payload? Export the data to a spreadsheet with JSON to CSV. → export decoded data to CSV
- Documenting Base64 image embedding? Show the technique with rendered HTML via Markdown to HTML. → embed Base64 images in HTML documentation
- Need to verify a string is valid Base64? Test the pattern
^[A-Za-z0-9+/]*={0,2}$in the Regex Tester. → validate Base64 format with a regex - Automating Base64 encoding in a pipeline? Verify your cron schedule with the Cron Parser. → schedule Base64 encoding tasks
Related Guides & Tutorials
Base64 Encoding Explained: When and Why Developers Use It
From embedding images in CSS to encoding JWT payloads — a clear explanation of Base64 with practical examples.
GuideJSON vs XML vs CSV: Which Data Format Should You Use?
A practical breakdown of when to reach for JSON, XML, or CSV — with real-world API and data pipeline examples.
Frequently Asked Questions
= characters are padding. Base64 encodes 3 bytes into 4 characters. When the input length is not a multiple of 3, padding is added to complete the final group. One = means one byte of padding; == means two bytes.+ and /, which have special meanings in URLs. URL-safe Base64 replaces these with - and _ and typically omits padding. It is used in JWTs, OAuth access tokens, and any context where the encoded string appears in a URL.data:image/png;base64,{encoded}. This eliminates an HTTP request but increases file size by ~33%. Best for small icons only.