Base64 Encode & Decode in JavaScript
Encode and decode Base64 instantly using native JavaScript browser APIs.
Base64
0 characters
Browser JavaScript
Learn how to encode and decode Base64 in JavaScript using modern browser APIs.
This guide includes:
- Base64 encoding examples
- Base64 decoding examples
- Browser JavaScript examples
- Practical use cases
- Live Base64 encoder and decoder tool
What is Base64?
Base64 is a text encoding format that converts binary data into ASCII text.
It is commonly used to safely transmit data through systems that only support text.
Base64 is widely used in:
- APIs
- JSON data
- Authentication tokens
- Email systems
- File encoding
- Web development
Encode Base64 in JavaScript
Modern browsers support Base64 encoding using the built-in btoa() function.
Example:
const text = "Hello World";
const encoded = btoa(text);
console.log(encoded);
Result:
SGVsbG8gV29ybGQ=
Decode Base64 in JavaScript
Use the built-in atob() function to decode Base64 strings.
Example:
const encoded = "SGVsbG8gV29ybGQ=";
const decoded = atob(encoded);
console.log(decoded);
When should you use Base64?
Base64 is useful for:
- Encoding files into text
- API payloads
- JWT tokens
- Authentication headers
- Embedding images in HTML or CSS
- Browser storage systems
Is Base64 encryption?
No.
Base64 is an encoding method, not encryption.
Encoded Base64 data can easily be decoded back into its original content.
Browser vs Node.js Base64
Browser
Uses:
btoa()atob()
Node.js
Uses:
Buffer.from(text).toString("base64")
Common Use Cases
Developers commonly use Base64 in JavaScript for:
- APIs
- Web applications
- Image embedding
- File transfer
- Authentication systems
- Tokens and cookies
Live Base64 JavaScript Tool
Use the tool below to encode and decode Base64 instantly in your browser.
Everything runs locally using JavaScript.
FAQ
Is Base64 secure?
No. Base64 is not encryption and should not be used to protect sensitive information.
Can Base64 be decoded?
Yes. Base64 encoding is completely reversible.
Does JavaScript support Base64 natively?
Yes. Browsers support Base64 through btoa() and atob().
Can I encode files with Base64?
Yes. Base64 is commonly used to encode binary files into text format.
Is this Base64 tool free?
Yes, completely free.
