What is base64-url?
The base64-url npm package provides utilities for encoding and decoding data in base64 format, specifically tailored for URL-safe operations. It ensures that the encoded data is safe to use in URLs by replacing characters that are not URL-safe.
What are base64-url's main functionalities?
Encode to Base64 URL
This feature allows you to encode a string into a URL-safe base64 format. The encoded string can be safely used in URLs without any issues.
const base64url = require('base64-url');
const encoded = base64url.encode('Hello World!');
console.log(encoded); // Outputs: 'SGVsbG8gV29ybGQh'
Decode from Base64 URL
This feature allows you to decode a URL-safe base64 encoded string back to its original form.
const base64url = require('base64-url');
const decoded = base64url.decode('SGVsbG8gV29ybGQh');
console.log(decoded); // Outputs: 'Hello World!'
Escape Base64
This feature escapes a base64 encoded string to make it URL-safe by replacing characters like '+' and '/' with '-' and '_'.
const base64url = require('base64-url');
const escaped = base64url.escape('SGVsbG8gV29ybGQh');
console.log(escaped); // Outputs: 'SGVsbG8gV29ybGQh'
Unescape Base64
This feature unescapes a URL-safe base64 encoded string back to its original base64 format.
const base64url = require('base64-url');
const unescaped = base64url.unescape('SGVsbG8gV29ybGQh');
console.log(unescaped); // Outputs: 'SGVsbG8gV29ybGQh'
Other packages similar to base64-url
base64url
The base64url package provides similar functionality for encoding and decoding base64 URL-safe strings. It is a popular alternative and offers a similar API for handling base64 URL-safe operations.
js-base64
The js-base64 package is a robust library for encoding and decoding base64 strings. While it is not specifically tailored for URL-safe operations, it provides comprehensive base64 encoding and decoding functionalities.
base64-js
The base64-js package is another library for encoding and decoding base64 strings. It focuses on providing a fast and efficient way to handle base64 operations, but it does not specifically address URL-safe encoding.
base64-url
Base64 encode, decode, escape and unescape for URL applications.






API
const base64url = require('base64-url')
examples
base64url.encode('Node.js is awesome.')
base64url.decode('Tm9kZS5qcyBpcyBhd2Vzb21lLg')
base64url.escape('This+is/goingto+escape==')
base64url.unescape('This-is_goingto-escape')
base64url.encode(string to encode, encoding)
base64url.decode(string to decode, encoding)
ISC License (ISC)
Alternatives