{"versions":{"0.1.0":{"name":"@sindresorhus/base62","version":"0.1.0","description":"Encode & decode strings, bytes, and integers to Base62","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/base62.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava"},"keywords":["base62","base","base64","base-62","encode","decode","shorten","compress","compact","alphanumeric","serialization","url","safe","text","string","number","integer","bigint","bytes","uint8array","algorithm","transformation","encoder","decoder","encoding","decoding","url-friendly","url-safe"],"devDependencies":{"ava":"^6.1.2","xo":"^0.58.0"},"_id":"@sindresorhus/base62@0.1.0","gitHead":"a5826efc96f7c79eb63a5d97893d6af03967496d","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/base62/issues"},"homepage":"https://github.com/sindresorhus/base62#readme","_nodeVersion":"20.12.2","_npmVersion":"10.6.0","dist":{"integrity":"sha512-BNjiImatCV+CUdvzSbFWzZIZqOddg6qn0Ag6/8Ty5G09oOtvxidZ5tkPQW2XHpzGVkB3eHfdYGwrWNy2nUFOwQ==","shasum":"2ef36425f0210998adf504e495f6c1e85c7d2718","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@sindresorhus/base62/-/base62-0.1.0.tgz","fileCount":7,"unpackedSize":10037,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC9BfcRDYCj1UXAHW8SgWRQEGbG3hNgzIZcPFSkBlyCwQIhALTvpQkDpexLku9c2u8MyqpvEyz5dk9U78xWGFoVp0+E"}],"size":3386},"_npmUser":{"name":"anonymous","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/base62_0.1.0_1714912663364_0.17261420348543544"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-05-05T12:37:43.527Z","publish_time":1714912663527,"_source_registry_name":"default","contributors":[]},"1.0.0":{"name":"@sindresorhus/base62","version":"1.0.0","description":"Encode & decode strings, bytes, and integers to Base62","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/base62.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava"},"keywords":["base62","base","base64","base-62","encode","decode","shorten","compress","compact","alphanumeric","serialization","url","safe","text","string","number","integer","bigint","bytes","uint8array","algorithm","transformation","encoder","decoder","encoding","decoding","url-friendly","url-safe"],"devDependencies":{"ava":"^6.1.2","xo":"^0.58.0"},"_id":"@sindresorhus/base62@1.0.0","gitHead":"74e8b2f252737a83a9b88dc77afb6ae77bdaa676","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/base62/issues"},"homepage":"https://github.com/sindresorhus/base62#readme","_nodeVersion":"20.19.5","_npmVersion":"10.9.2","dist":{"integrity":"sha512-TeheYy0ILzBEI/CO55CP6zJCSdSWeRtGnHy8U8dWSUH4I68iqTsy7HkMktR4xakThc9jotkPQUXT4ITdbV7cHA==","shasum":"c47c42410e5212e4fa4657670e118ddfba39acd6","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@sindresorhus/base62/-/base62-1.0.0.tgz","fileCount":7,"unpackedSize":15175,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCU/4N+kL/CskYNAd9hc6dEb5W0oPO8jvbwk6EIjj/m6QIhAJcx3G62uoaP85Yj1OCht54pmzmlZ/06qgB4rlJYRZZP"}],"size":4351},"_npmUser":{"name":"anonymous","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/base62_1.0.0_1758049357664_0.6247925194330457"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-09-16T19:02:37.860Z","publish_time":1758049357860,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"1.0.0"},"name":"@sindresorhus/base62","time":{"created":"2024-05-05T12:38:28.812Z","modified":"2025-09-16T19:02:46.284Z","0.1.0":"2024-05-05T12:37:43.527Z","1.0.0":"2025-09-16T19:02:37.860Z"},"readme":"# base62\n\n> Encode & decode strings, bytes, and integers to [Base62](https://en.wikipedia.org/wiki/Base62)\n\nBase62 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.\n\n## Install\n\n```sh\nnpm install @sindresorhus/base62\n```\n\n## Usage\n\n```js\nimport base62 from '@sindresorhus/base62';\n\nconst encodedString = base62.encodeString('Hello world!');\nconsole.log(encodedString);\n//=> '28B5ymDkgSU62aA0v'\n\nconsole.log(base62.decodeString(encodedString));\n//=> 'Hello world!'\n\nconsole.log(base62.encodeString('🦄'));\n//=> '95s3vg'\n\nconsole.log(base62.encodeInteger(1337));\n//=> 'LZ'\n```\n\n> [!NOTE]\n> The output may differ from other Base62 encoders due to variations in alphabet order and byte encoding.\n\n## API\n\nIt uses the most common alphabet for Base62: `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`\n\n### `encodeString(string: string): string`\n\nEncodes a string to a Base62 string.\n\n> [!CAUTION]\n> The result format is not yet guaranteed to be stable across package versions. Avoid using it for persistent storage.\n\n### `decodeString(encodedString: string): string`\n\nDecodes a Base62 encoded string created with `encodeString()` back to the original string.\n\n### `encodeBytes(bytes: Uint8Array): string`\n\nEncodes bytes to a Base62 string.\n\n> [!CAUTION]\n> The result format is not yet guaranteed to be stable across package versions. Avoid using it for persistent storage.\n\n### `decodeBytes(encodedString: string): Uint8Array`\n\nDecodes a Base62 string created with `encodeBytes()` back to bytes.\n\n### `encodeInteger(integer: number): string`\n\nEncodes a non-negative integer to a Base62 string.\n\n### `decodeInteger(encodedString: string): number`\n\nDecodes a Base62 string to an integer.\n\n### `encodeBigInt(integer: bigint): string`\n\nEncodes a non-negative bigint to a Base62 string.\n\n### `decodeBigInt(encodedString: string): bigint`\n\nDecodes a Base62 string to a bigint.\n\n### Custom alphabets\n\nYou can use a custom alphabet by using the `Base62` class:\n\n```js\nimport {Base62} from '@sindresorhus/base62';\n\n// Create instance with custom alphabet\nconst customBase62 = new Base62({\n\talphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'\n});\n\nconsole.log(customBase62.encodeInteger(1337));\n//=> 'Vj' (different from default 'LZ')\n\n// Or use special characters\nconst symbolBase62 = new Base62({\n\talphabet: '!@#$%^&*()_+-=[]{}|;:,.<>?/~`0123456789ABCDEFGHIJKLMNOPQRSTUVW'\n});\nconsole.log(symbolBase62.encodeInteger(42));\n//=> 'D'\n```\n\n> [!NOTE]\n> The alphabet must be exactly 62 unique characters.\n\n### `Base62`\n\n#### `constructor(options?)`\n\nCreate a new Base62 encoder/decoder instance.\n\n##### options\n\nType: `object`\n\n###### alphabet\n\nType: `string`\\\nDefault: `'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'`\n\nCustom alphabet containing exactly 62 unique characters.\n\nThe `Base62` class has the same methods as the exported functions: `encodeString()`, `decodeString()`, `encodeBytes()`, `decodeBytes()`, `encodeInteger()`, `decodeInteger()`, `encodeBigInt()`, and `decodeBigInt()`.","users":{}}