Base64 Encoder / Decoder
Encode and decode Base64 strings online. Also supports file to Base64 encoding for data URIs.
How to use Base64 Encoder / Decoder
Enter String
Enter the string you want to encode or decode in the input field. You can also upload a file to convert it to a Base64 data URI.
Choose Action
Select whether you want to encode or decode the string using the provided options. For file uploads, the tool will automatically generate a data URI.
Get Result
Click the 'Encode' or 'Decode' button to process the string. The result will be displayed in the output field, ready for you to use or copy.
Related Tools
URL Encoder / Decoder
Encode and decode URLs and query strings. Escape special characters for safe URL usage.
Hash Generator
Generate MD5, SHA-1, SHA-256, SHA-512 hashes from text or files. Browser-based, private.
JSON Formatter
Format, validate, and minify JSON data online. Syntax highlighting, error detection, and tree view.
Base64 encoder online, encode and decode instantly
Base64 encoder online, encode and decode instantly
You can encode or decode Base64 strings instantly with ToolHQ's Base64 Encoder, free, browser-based, and your data is never sent to any server.
ToolHQ's Base64 Encoder is a free browser-based tool that encodes text or binary data to Base64 format and decodes Base64 strings back to plain text, running entirely in your browser with no data transmitted externally.
Developers hit Base64 problems constantly. An API returns an encoded image. A config file stores credentials as Base64. An email attachment arrives garbled. You need to verify a JWT payload. Getting these tasks done should not require writing a script every time. This guide explains what Base64 is, when you need it, and how to use ToolHQ's encoder in your daily workflow.
Key Takeaways
- Base64 is a text encoding scheme that converts binary data into printable ASCII characters
- It is widely used for embedding images in HTML/CSS, encoding API tokens, and transmitting data through text-only channels
- ToolHQ's tool encodes and decodes in both directions, paste in either format and convert
- All processing happens in your browser, no data leaves your device
- Base64 increases data size by approximately 33%, it is for compatibility, not compression
What is Base64 encoding and why does it exist?
Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters: the uppercase and lowercase letters A–Z, the digits 0–9, and the symbols + and /. The = character is used for padding.
The standard is defined in RFC 4648, published by the IETF. The document covers Base64 and related encodings, their canonical alphabets, and how padding works.
The fundamental problem Base64 solves is this: many protocols and formats were designed for text, not binary data. Email protocols, URLs, JSON fields, and HTTP headers all have special meanings for certain byte values. Raw binary data, the bytes that make up a JPEG image, a PDF, or an executable, routinely includes those "special" bytes. Passing binary directly through a text-only channel corrupts it.
Base64 sidesteps this by mapping every possible sequence of 6 bits to a safe printable character. Three bytes of binary data (24 bits) become four Base64 characters. A 100 KB image becomes a 133 KB Base64 string, safe to paste into a JSON field, embed in a <style> tag, or include in an HTTP header.
MDN's documentation on Base64 notes that browsers expose btoa() (binary to ASCII, i.e., encode) and atob() (ASCII to binary, i.e., decode) as built-in JavaScript functions. These are convenient for small strings, but having a visual tool is faster for ad hoc work, debugging, or encoding files.
Base64 is everywhere even when it is not obvious: JWT tokens are Base64-encoded JSON, data URIs for inline images start with data:image/png;base64,..., and Basic Authentication headers send username:password as Base64. Being able to encode and decode quickly is a routine developer task.
When should you use a Base64 encoder?
The most common use cases split into two groups: encoding (turning something into Base64) and decoding (reading what Base64 contains).
Encoding situations:
- Embedding a small image directly in HTML or CSS as a data URI to avoid an extra HTTP request
- Storing binary data like certificates or keys in a JSON configuration file
- Creating HTTP Basic Auth headers for API testing: encode
username:passwordand paste it into yourAuthorizationheader - Encoding file attachments to send through an API that only accepts JSON
Decoding situations:
- Inspecting a JWT token to read the claims payload (the middle segment of a JWT is Base64-encoded JSON)
- Debugging an API response that returns binary data encoded as Base64
- Reading credentials or keys from a configuration file or environment variable that stores them encoded
A real-world scenario: Tomás is a backend engineer integrating with a third-party payment gateway. The API documentation says error responses include a details field that is a Base64-encoded JSON object with additional diagnostic information. When he triggers a test error, he sees: "details": "eyJlcnJvcl9jb2RlIjoiMTIzNCIsIm1lc3NhZ2UiOiJJbnZhbGlkIGNhcmQgbnVtYmVyIn0=". He opens ToolHQ's Base64 Encoder, pastes that string into the decode field, and gets back {"error_code":"1234","message":"Invalid card number"} in under three seconds. He fixes the test data and moves on.
Encode or decode Base64 in your browser, no data leaves your device →
How to encode and decode Base64 step by step
To encode text to Base64:
Open the tool. Go to ToolHQ's Base64 Encoder in any browser.
Select Encode mode. Click the Encode tab or button to make sure you are in encoding mode.
Paste your input. Type or paste the text you want to encode into the input field. This can be a URL, a JSON string, a password, credentials, or any plain text.
Copy the output. The Base64-encoded string appears immediately in the output field. Click Copy to copy it to your clipboard.
Use it. Paste the encoded string wherever you need it, an HTTP header, a config file, a data URI, or an API request body.
To decode Base64 back to text:
Select Decode mode. Switch to the Decode tab.
Paste your Base64 string. Paste the Base64-encoded text into the input field. The string typically consists of letters, numbers,
+,/, and may end with one or two=padding characters.Copy the decoded output. The plain text result appears immediately. If the Base64 encodes JSON, you will see the raw JSON string.
Format if needed. If the decoded output is JSON, consider running it through ToolHQ's JSON formatter for readable indentation.
Tips for working with Base64 in developer workflows
Recognize Base64 by its appearance. A Base64 string uses only A–Z, a–z, 0–9, +, and /, usually ending with zero, one, or two = padding characters. If you see a long string with this pattern in an API response or config file, it is almost certainly Base64.
JWT tokens are three Base64 sections separated by dots. A JWT looks like xxxxx.yyyyy.zzzzz. Each section is Base64URL-encoded (a variant that uses - and _ instead of + and /). To read the header or payload, decode the first or second section. The third section is the cryptographic signature, decoding it reveals raw bytes, not readable text.
Base64URL is slightly different from standard Base64. Standard Base64 uses + and /. Base64URL (used in JWTs, URL-safe contexts) uses - and _ instead and omits padding =. If you are decoding a JWT payload, replace - with + and _ with / before decoding if your tool does not handle this automatically.
Do not use Base64 for security. Base64 encoding is not encryption. Anyone who has the Base64 string can decode it instantly. If you need to protect sensitive data, use proper encryption rather than just encoding it. For generating secure passwords and tokens, use ToolHQ's password generator or hash generator.
Pair with the URL encoder for API work. Base64 strings sometimes appear in URLs as query parameters. If you need to embed a Base64 string in a URL, first encode it with Base64, then URL-encode the result (replacing + with %2B and = with %3D) using ToolHQ's URL encoder/decoder.
Common mistakes when using Base64
Confusing encoding with encryption. This is the most important mistake to avoid. Encoding is reversible by anyone without any key. Never treat Base64 as a security measure.
Including whitespace or line breaks in the encoded string. Some Base64 encoders (especially those generating MIME-encoded email content) add line breaks every 76 characters. If you paste this into a field expecting a single-line Base64 string, it will fail to decode. Remove all whitespace and line breaks before decoding.
Truncating the string. Base64 strings must be decoded in full. If you accidentally copy only part of a long Base64 value, the decoder will produce garbage or fail entirely. Always select all before copying.
Expecting Base64 to reduce file size. Base64 adds 33% overhead. A 300 KB image encoded as Base64 becomes a 400 KB string. This is acceptable for small images embedded in CSS but impractical for large files.
Decoding binary output as text. If the original data was binary (an image, a PDF, an executable), decoding the Base64 gives you raw binary bytes, not readable text. A plain-text Base64 decoder will show garbled characters. ToolHQ's tool handles this by showing you the result; for binary outputs, you would need to download the decoded file rather than read it as text.
FAQ
What is Base64 used for in real applications?
Common uses include data URI image embedding in CSS and HTML, encoding binary data in JSON APIs, HTTP Basic Authentication headers, and encoding configuration values in environment variables. JWT tokens also use a Base64 variant called Base64URL.
Is Base64 the same as encryption?
No. Base64 is reversible encoding with no key required. Anyone can decode a Base64 string. Do not use it to protect sensitive data, use proper encryption for that.
Why does a Base64 string end with ==?
Base64 encodes 3 bytes at a time into 4 characters. If the input length is not a multiple of 3, padding characters (= or ==) are added to make the output length a multiple of 4.
What is the difference between Base64 and Base64URL?
Standard Base64 uses + and /. Base64URL replaces these with - and _ to make the string safe for use in URLs and filenames without percent-encoding. JWTs use Base64URL.
Can I encode binary files (images, PDFs) with this tool?
ToolHQ's Base64 Encoder works with text input. For encoding binary files to Base64 data URIs, you would need a tool that accepts file uploads and outputs the binary as Base64. For text-based Base64 work, JWTs, API tokens, config values, this tool covers everything.
Is the data I enter kept private?
Yes. All encoding and decoding runs in your browser using JavaScript. Nothing is transmitted to any server. Your input data never leaves your device.
Conclusion
Base64 encoding comes up constantly in web development, API work, and system configuration. Knowing how to encode and decode it quickly, without writing a script or installing a library, saves real time.
ToolHQ's Base64 Encoder handles both directions in your browser, with no data sent anywhere. Paste in your text, get your encoded or decoded result, and copy it. That is the entire workflow.
For related developer tools, explore the developer tools category. The JSON formatter is useful after decoding Base64 API responses, the URL encoder/decoder handles URL-safe encoding for query strings, and the hash generator is the right tool when you need one-way cryptographic hashing rather than reversible encoding.
Encode or decode Base64 free, private, instant, browser-based →