
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
basex-converter
Advanced tools
Decode/encode hex,binary,regular values in any base and Base Converter
Due to the limitation of JavaScript's integer representation, which is limited to 53 bits, handling large numbers for
encryption tasks can be challenging. Existing libraries run into problems when dealing with such values;
To fix this limitation, This library provides encoding of large numbers. This library provides the
following features:
By overcoming JavaScript's integer limitations, this library allows developers to efficiently work with large numbers in encoding and base conversion tasks.
[!CAUTION]
Be careful, spaces(" ") in the whole value and zeros(0) at the beginning of the value being ignored
Default alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
Inverted alphabet: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Default base: 62
See below for a list of commonly recognized alphabets, and their respective base.
| Base | Import Name | Alphabet |
|---|---|---|
| 2 | ALPHABET_BASE2 | 01 |
| 8 | ALPHABET_BASE8 | 01234567 |
| 11 | ALPHABET_BASE11 | 0123456789a |
| 16 | ALPHABET_BASE16 | 0123456789abcdef |
| 32 | ALPHABET_BASE32 | 0123456789ABCDEFGHJKMNPQRSTVWXYZ |
| 36 | ALPHABET_BASE36 | 0123456789abcdefghijklmnopqrstuvwxyz |
| 58 | ALPHABET_BASE58 | 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz |
| 62 | ALPHABET_BASE62_Default | 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |
| 64 | ALPHABET_BASE64 | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ |
| 67 | ALPHABET_BASE67 | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~ |
npm install basex-converter
Alternatively using Yarn:
yarn add basex-converter
import base62 from 'basex-converter';
// or for making instance with custom alphabet
import { Base62, ALPHABET_BASE62_Default, ALPHABET_BASE62_INVERTED, BASE_DEFAULT } from 'basex-converter';
const base62 = require('basex-converter').default;
const { Base62, ALPHABET_BASE62_Default, ALPHABET_BASE62_INVERTED, BASE_DEFAULT } = require('basex-converter');
console.log(base62.decode('base62'));
// '34441886726'
console.log(base62.encode('34441886726'));
// 'base62'
console.log(base62.encode_bytes(new Uint8Array([0x01, 0x01])));
// '49'
console.log(base62.decode_bytes('49'));
// Uint8Array(2) [ 1, 1 ]
console.log(base62.encode_hex('604a38563'));
// 'SDG16R'
console.log(base62.decode_hex('SDG16R'));
// '604a38563'
// encode and decode mongodb objectid
console.log(base62.encode_hex('63d91de18f092ab964484b9e'));
// 'eBhQNIyMqR6WH3XS'
console.log(base62.decode_hex('eBhQNIyMqR6WH3XS'));
// '63d91de18f092ab964484b9e'
console.log(base62.convert_base('ff', 16, 10));
// '255'
console.log(base62.convert_base('wiv', 36, 10));
// '42151'
console.log(base62.convert_base('123456789123456789123456789123456789123456789', 10, 16));
// '58936e53d139afefabb2683f150b684045f15'
This library provides the ability to change the alphabet and base for encoding and decoding. However, changing the base
is not recommended unless you are sure that the chosen base works without malfunctioning.
But the alphabet can be changed without functional problems. it just sensitive to "space" character, and we can not use
it.
import { Base62, ALPHABET_BASE58 } from 'basex-converter';
// make instance
const base62 = new Base62();
// make another base
const base62 = new Base62(ALPHABET_BASE58, 58);
// or you can set alphabet
const base62 = new Base62('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');
// or base
const base62 = new Base62('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 62);
console.log(base62.decode('base62', '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'));
// '34441886726'
console.log(base62.encode('34441886726', '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'));
// 'base62'
import base62, { ALPHABET_BASE58, ALPHABET_BASE62_INVERTED } from 'basex-converter';
// use costom alphabet
base62.setAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');
// or use existing ones
base62.setAlphabet(ALPHABET_BASE62_INVERTED);
base62.setBaseAlphabet(ALPHABET_BASE58, 58);
FAQs
Decode/encode hex,binary,regular values in any base and Base Converter
The npm package basex-converter receives a total of 2 weekly downloads. As such, basex-converter popularity was classified as not popular.
We found that basex-converter 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.