https://github.com/ctison/base-converter
Convert a number from any base to any base
https://github.com/ctison/base-converter
base base16 cli
Last synced: 3 months ago
JSON representation
Convert a number from any base to any base
- Host: GitHub
- URL: https://github.com/ctison/base-converter
- Owner: ctison
- Created: 2020-03-25T18:16:13.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2026-01-26T06:10:22.000Z (4 months ago)
- Last Synced: 2026-01-26T20:47:09.000Z (4 months ago)
- Topics: base, base16, cli
- Language: Rust
- Homepage:
- Size: 160 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Base converter
Convert a number from any base to any other base from your terminal!
## Install
Pre-built binaries are available in [Releases](https://github.com/ctison/base-converter/releases).
NPM package (wasm) available at https://www.npmjs.com/package/@ctison/base-converter.
Rust doc available at https://docs.rs/base-converter/latest/base_converter/.
## CLI Usage
```sh
$ base-converter
```
```sh
# Convert 51966 from base 10 to base 16
$ base-converter 51966 0123456789 0123456789ABCDEF
CAFE
```
```sh
# Convert 42 from base 10 to base 2
$ base-converter 42 0123456789 🦀🚀
🚀🦀🚀🦀🚀🦀
```
## NPM usage
```sh
$ npm add @ctison/base-converter
```
```ts
/**
* Checks if a base is valid by throwing an error if not.
* @param {string} base
*/
export function checkBase(base: string): void
/**
* Convert a number from any base to an decimal number.
* @param {string} nbr
* @param {string} fromBase
* @returns {number}
*/
export function baseToDecimal(nbr: string, fromBase: string): number
/**
* Convert an decimal number to any base.
* @param {number} nbr
* @param {string} toBase
* @returns {string}
*/
export function decimalToBase(nbr: number, toBase: string): string
/**
* Convert a number from any base to any base.
* @param {string} nbr
* @param {string} fromBase
* @param {string} toBase
* @returns {string}
*/
export function baseToBase(
nbr: string,
fromBase: string,
toBase: string
): string
```