Base64Plus is a modern, Unicode-safe Base64 encoding and decoding library. It supports Node.js, ES Modules, Browsers, and TypeScript with a built-in polyfill for Node.js environments.
- Handles Unicode strings properly: Native
atob/btoafail with multi-byte characters like emojis or non-Latin scripts. - Works in both Node.js & Browsers: Node.js lacks
atob/btoa, but Base64Plus provides a seamless polyfill. - Supports ES Modules & TypeScript: Fully typed for modern JavaScript projects.
- Encodes and decodes Buffers: Unlike
atob, which only works with plain strings. - No dependencies & lightweight: Small package size with no external dependencies.
-
npm install base64plus
Include the UMD version directly in your HTML file:
<script src="https://github.com/nassiry/base64plus/releases/latest/download/base64Plus.umd.js"></script>
<script>
console.log(Base64Plus.encode("Hello, World!"));
</script>Get the latest release from GitHub Releases.
-
const Base64Plus = require("base64plus"); const encoded = Base64Plus.encode("Hello, World!"); console.log(encoded); // Base64 string const decoded = Base64Plus.decode(encoded); console.log(decoded); // Hello, World! const encodedUrl = Base64Plus.encodeUrl("Hello, World!"); console.log(encodedUrl); // Base64 string const decodedUrl = Base64Plus.decodeUrl(encodedUrl); console.log(decodedUrl); // Hello, World!
-
import Base64Plus from "base64plus"; const encoded = Base64Plus.encode("Base64 Encoding"); console.log(encoded); // Base64 string const decoded = Base64Plus.decode(encoded); console.log(decoded); // Base64 Encoding
Base64Plus.encode(input: string): string- Encodes a string to Base64 while supporting full Unicode characters.
Base64Plus.decode(base64String: string): string- Decodes a Base64 string back to a Unicode string.
Base64Plus.encodeUrl(input: string): string- Encodes a string to URL-safe Base64.
Base64Plus.decodeUrl(Base64String: string): string- Decodes a URL-safe Base64 string back to a Unicode string.
Base64Plus.isValid(base64String: string): boolean- Checks if a string is a valid Base64 string.
Deprecated:
Base64Plus.isValidBase64(base64String: string): booleanUseBase64Plus.isValidinstead.
Clone the Repository & install the dependencies.
git clone https://github.com/nassiry/base64plus.git
cd base64plus
npm install-
npm run build
-
npm test
For more details on contributing, see CONTRIBUTING.
See CHANGELOG for release details.
This package is open-source software licensed under the MIT license.