About Base64 Encoder
Base64 encoding is one of those tools that surfaces in unexpected places throughout web development — data URIs in CSS and HTML, Basic Auth credentials in HTTP headers, JWT structure, email attachments (MIME), binary data in JSON payloads, and environment variable encoding. It is not encryption — it is simply a way to represent binary or text data using only the 64 printable ASCII characters that are safe to pass through text-only systems without corruption. This free online Base64 encoder and decoder lets you encode any UTF-8 text or ASCII string to Base64 instantly, or decode any Base64 string back to readable text. It handles both standard Base64 and URL-safe Base64 (which replaces + with - and / with _ to make the string safe for use in URLs and filenames). Everything runs locally in your browser using the built-in btoa() and atob() functions — no data is uploaded or transmitted. Whether you are constructing an HTTP Basic Auth header, embedding a small image as a data URI, or debugging a JWT, this tool gives you the encoded or decoded value in seconds.
How to Use Base64 Encoder
- Select Encode or Decode: Choose whether you want to encode text to Base64, or decode a Base64 string back to plain text.
- Paste or Type Your Input: Enter the text you want to encode, or paste the Base64 string you want to decode into the input field.
- Copy the Result: The output appears instantly. Click Copy to send it to your clipboard, ready to use in your code, header, or config file.
Key Features
- Text to Base64 Encoding: Encode any UTF-8 text string to standard Base64. Handles special characters, Unicode text, and multi-line strings correctly using the browser's native btoa() implementation.
- Base64 to Text Decoding: Decode any standard Base64 string back to its original UTF-8 text representation. Useful for inspecting encoded values in API responses, JWT payloads, or configuration files.
- URL-Safe Base64 Variant: Toggle between standard Base64 (using + and /) and URL-safe Base64 (using - and _). URL-safe encoding is required for JWTs, URL parameters, and filenames where the standard characters would cause parsing problems.
- One-Click Copy: Copy the encoded or decoded output to your clipboard instantly. No manual text selection needed — works reliably even for large encoded strings.
- Runs Entirely in Your Browser: Encoding and decoding use JavaScript's built-in btoa() and atob() functions. No data is transmitted to any server — safe for encoding passwords, API keys, or private configuration values.
- Instant Live Conversion: The output updates in real time as you type or paste. No submit button needed — see the encoded or decoded value immediately as you modify the input.
Benefits
- Build HTTP Basic Auth Headers: HTTP Basic Authentication encodes credentials as Base64('username:password'). Encode your credentials here to build a correct Authorization: Basic <encoded> header for API testing or cURL commands.
- Create Data URIs for Inline Images: Embed small images directly in CSS or HTML as data:image/png;base64,<encoded> to eliminate an extra HTTP request. Encode a small icon here, then paste the data URI directly into your stylesheet.
- Debug JWT Sections: JWT header and payload sections are Base64url-encoded. Paste individual JWT sections here (the parts between the dots) to decode and inspect them without using a full JWT decoder.
- Encode Environment Variables: Some deployment platforms, CI/CD systems (like GitHub Actions secrets), and Kubernetes ConfigMaps store binary or multi-line values as Base64. Encode your value here before storing it.
Supported Formats & Capabilities
- UTF-8 text strings (input for encoding)
- ASCII / Base64 strings (input for decoding)
- Standard Base64 (RFC 4648)
- URL-safe Base64 (RFC 4648 §5)
Common Problems & Solutions
- I'm getting an 'Invalid Base64' error when decoding.
- Valid Base64 strings only contain A-Z, a-z, 0-9, +, /, and = padding characters. URL-safe Base64 uses - and _ instead of + and /. Ensure there are no whitespace characters, line breaks, or invalid characters in the string you're decoding.
- The decoded output shows garbled characters.
- The original data may have been binary (like an image or PDF) rather than a text string. Base64 can encode any binary data, not just text — if the original was binary, decoding to text will produce garbled output. Use a binary file decoder for non-text Base64 content.
- My Base64 string has no padding (no = signs at the end) and it fails.
- Standard Base64 requires padding to make the string length a multiple of 4. Some implementations omit padding. If decoding fails, try adding = or == to the end of the string until it becomes a valid multiple of 4 characters long.
- I need to encode a binary file (image, PDF), not text.
- This tool encodes text strings using btoa(). Binary file encoding requires a different approach — use the FileReader API in a script or use the Image Compressor/Converter tools on this site for image data URIs.
Pro Tips & Best Practices
- For HTTP Basic Auth, format your credentials as 'username:password' (colon between, no spaces) before encoding. The resulting Base64 string is what goes after 'Basic ' in the Authorization header.
- JWT tokens consist of three Base64url-encoded sections separated by dots. You can paste any individual section (without the dots) into this tool to quickly inspect the raw JSON without using a full JWT decoder.
- URL-safe Base64 is used in JWTs, OAuth tokens, and some API systems. If a standard Base64 string with + or / fails in a URL context, use the URL-safe variant toggle to get the - and _ variant.
- Base64 encoding increases data size by approximately 33% (every 3 bytes of input becomes 4 characters of output). For large data, consider whether compression before encoding is appropriate.
Privacy & Data Security
Base64 encoding and decoding run entirely in your web browser using JavaScript's built-in btoa() (encode) and atob() (decode) functions. No data is transmitted to any server at any point. When you type or paste input into the tool, the conversion runs in the browser's JavaScript engine on your device and the result is computed locally. Base64 is encoding, not encryption — anyone who sees the encoded string can decode it instantly. Do not use Base64 to protect sensitive data; use proper encryption for that purpose. The tool itself is private — your input and output stay on your device.
Frequently Asked Questions
- What is Base64 encoding used for?
- Base64 encodes binary data as printable ASCII text, making it safe to include in text-based formats like JSON, XML, HTML, and email headers. Common uses include embedding images as data URIs in CSS, encoding credentials in HTTP Basic Auth headers, and encoding binary data in email MIME attachments.
- Is Base64 the same as encryption?
- No. Base64 is encoding, not encryption. Anyone can trivially decode a Base64 string — it is just a different representation of the same data. Do not use it to protect sensitive information; use proper encryption for that.
- Is my data private when I use this Base64 tool?
- Yes. Encoding and decoding runs entirely in your browser using native JavaScript functions. No data is sent to any server.
- What is the difference between standard Base64 and URL-safe Base64?
- Standard Base64 uses + and / characters, which have special meaning in URLs. URL-safe Base64 replaces + with - and / with _, making it safe for use in URLs, query parameters, and filenames. Both encode the same data — they just use different character sets.
- Why does Base64 sometimes end with = or == signs?
- The = signs are padding characters added to make the encoded string length a multiple of 4. They have no data value — they are just alignment markers. Some systems strip padding; others require it.
- Can I encode an image file to Base64 with this tool?
- This tool encodes text strings. For encoding binary files (images, PDFs) to Base64, you would need a tool that reads the raw binary data. The browser's FileReader API can do this in JavaScript.
- How much larger does Base64 make the encoded data?
- Base64 encoding increases data size by approximately 33%. Every 3 bytes of binary data becomes 4 characters of Base64 text. This overhead is the trade-off for being able to transmit binary data through text-only channels.
Related Developer Utilities
JSON Formatter
Format, minify, validate, and filter JSON with JSONPath. Features an interactive tree view and YAML export.
UUID & Identifier Studio
Generate UUID v4, UUID v7, ULID, NanoID, CUID2 values in bulk with real-time inspector and code export formats.
JSON ↔ CSV
Convert JSON arrays to CSV or parse CSV back to JSON in one click.
JWT Decoder
Decode, verify, edit, and sign JSON Web Tokens (JWT) online with 100% private, local browser processing.