@sopkit/base64
v1.0.0
Published
Premium, lightweight Base64 utility for browser and Node.js with URL-safe encoding/decoding.
Downloads
26
Maintainers
Readme
@sopkit/base64
Premium, lightweight Base64 encoder and decoder for both Browser and Node.js environments. Part of the SopKit utility ecosystem.
Online Interactive Tool
You can use the browser-based interactive version of this tool at SopKit Base64 Encoder/Decoder.
Features
- Full Unicode/UTF-8 support (unlike standard
btoa/atobwhich fail on emojis and special chars) - URL-safe encoding/decoding (
+➜-,/➜_, strips=) - Zero dependencies
- Fully typed API with strict TypeScript
- ESM and CommonJS support
Installation
npm install @sopkit/base64Quick Start
ESM
import { encode, decode, urlEncode, urlDecode, isValid } from "@sopkit/base64";
const text = "Hello World 🚀";
// Standard base64
const encoded = encode(text); // "SGVsbG8gV29ybGQg8J+Zog=="
const decoded = decode(encoded); // "Hello World 🚀"
// URL-safe base64
const urlSafeEncoded = urlEncode(text); // "SGVsbG8gV29ybGQg8J-Zog"
const urlSafeDecoded = urlDecode(urlSafeEncoded); // "Hello World 🚀"
// Validation
isValid("SGVsbG8gV29ybGQg8J+Zog=="); // true
isValid("invalid base64!"); // falseCommonJS
const { encode, decode } = require("@sopkit/base64");
const encoded = encode("Hello World");
const decoded = decode(encoded);License
MIT © SopKit
