
Research
SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.
@sindresorhus/base62
Advanced tools
Encode & decode strings, bytes, and integers to Base62
Base62 is ideal for URL shortening, creating readable codes, and compact data representation, because it compresses large values into shorter, alphanumeric strings, maximizing space efficiency and readability.
npm install @sindresorhus/base62
import base62 from '@sindresorhus/base62';
const encodedString = base62.encodeString('Hello world!');
console.log(encodedString);
//=> '8nlogx6nlNdJhVT24v'
console.log(base62.decodeString(encodedString));
//=> 'Hello world!'
console.log(base62.encodeString('🦄'));
//=> '95s3vg'
console.log(base62.encodeInteger(1337));
//=> 'LZ'
[!NOTE] The output may differ from other Base62 encoders due to variations in alphabet order and byte encoding.
It uses the most common alphabet for Base62: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
encodeString(string: string): stringEncodes a string to a Base62 string.
[!CAUTION] The result format is not yet guaranteed to be stable across package versions. Avoid using it for persistent storage.
decodeString(encodedString: string): stringDecodes a Base62 encoded string created with encodeString() back to the original string.
encodeBytes(bytes: Uint8Array): stringEncodes bytes to a Base62 string.
[!CAUTION] The result format is not yet guaranteed to be stable across package versions. Avoid using it for persistent storage.
decodeBytes(encodedString: string): Uint8ArrayDecodes a Base62 string created with encodeBytes() back to bytes.
encodeInteger(integer: number): stringEncodes a non-negative integer to a Base62 string.
decodeInteger(encodedString: string): numberDecodes a Base62 string to an integer.
encodeBigInt(integer: bigint): stringEncodes a non-negative bigint to a Base62 string.
decodeBigInt(encodedString: string): bigintDecodes a Base62 string to a bigint.
FAQs
Encode & decode strings, bytes, and integers to Base62
We found that @sindresorhus/base62 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.