https://github.com/nassiry/base64plus
Base64Plus is a modern, Unicode-safe Base64 encoding and decoding JavaScript library.
https://github.com/nassiry/base64plus
base64-decoding base64-encoding javascript typescript
Last synced: 9 months ago
JSON representation
Base64Plus is a modern, Unicode-safe Base64 encoding and decoding JavaScript library.
- Host: GitHub
- URL: https://github.com/nassiry/base64plus
- Owner: nassiry
- License: mit
- Created: 2025-02-01T03:54:04.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-03-20T04:36:02.000Z (9 months ago)
- Last Synced: 2025-04-14T20:11:56.085Z (9 months ago)
- Topics: base64-decoding, base64-encoding, javascript, typescript
- Language: TypeScript
- Homepage: https://github.com/nassiry/base64plus
- Size: 556 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Base64Plus

[](https://www.npmjs.com/package/base64plus)

[](https://github.com/nassiry/base64plus/releases)
[](https://github.com/nassiry/base64plus/blob/main/LICENSE)
**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`/`btoa` fail 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.
## Table Of Contents
1. [Installation](#1-installation)
- [Option 1: Install via NPM](#option-1-install-via-npm)
- [Option 2: Use via CDN](#option-2-use-via-cdn)
- [Option 3: Download Manually](#option-3-download-manually)
2. [Usage](#2-usage)
- [Node.js (CommonJS)](#nodejs-commonjs)
- [ES Modules / TypeScript](#es-modules--typescript)
3. [API Reference](#3-api-reference)
- [Encoding and Decoding](#encoding-and-decoding)
- [Validation](#validation)
4. [Development & Contribution](#4-development--contribution)
- [Build the Project](#build-the-project)
- [Run Tests](#run-tests)
5. [Changelog](#changelog)
6. [License](#license)
## 1. Installation
- ### Option 1: Install via NPM
```sh
npm install base64plus
```
- ### Option 2: Use via CDN
Include the `UMD` version directly in your HTML file:
```html
console.log(Base64Plus.encode("Hello, World!"));
```
- ### Option 3: Download Manually
Get the latest release from [GitHub Releases](https://github.com/nassiry/base64plus/releases/latest).
## 2. Usage
- ### Node.js (CommonJS)
```javascript
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!
```
- ### ES Modules / TypeScript
```javascript
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
```
## 3. API Reference
### Encoding and Decoding
- `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.
### Validation
- `Base64Plus.isValid(base64String: string): boolean`
- Checks if a string is a valid **Base64 string**.
> **Deprecated:** `Base64Plus.isValidBase64(base64String: string): boolean`
Use `Base64Plus.isValid` instead.
## 4. Development & Contribution
Clone the Repository & `install` the dependencies.
```sh
git clone https://github.com/nassiry/base64plus.git
cd base64plus
npm install
```
- ### Build the Project
```sh
npm run build
```
- ### Run Tests
```sh
npm test
```
For more details on contributing, see [CONTRIBUTING](CONTRIBUTING.md).
## Changelog
See [CHANGELOG](CHANGELOG.md) for release details.
## License
This package is open-source software licensed under the [MIT license](LICENSE).