SITE UNDER CONSTRUCTION. Everything here is provided AS IS, WITHOUT WARRANTIES, to the extent the law allows. It is information, not professional advice. Use at your own risk. Terms and liability limits →

eThorns ES
← DeveloperES

Tool 5.7

Number base converter (binary, hex, decimal)

Convert whole numbers between decimal, hexadecimal, binary and octal, with bit length and grouped digits. Exact at any size. Nothing is uploaded.

Runs on your deviceRuns entirely in your browser: nothing you type or upload leaves your device.

How to use it

  1. Type or paste a whole number in any of the four fields, or press a quick value such as 64-bit max.
  2. The other three fields update as you type. The prefixes `0x`, `0b` and `0o` are accepted, and spaces, commas and underscores are ignored.
  3. Below, read the bit length, the size in bytes, the hex grouped by bytes and the binary grouped by nibbles (4 bits).
  4. Copy any field with the button next to it.

Hex colors, chmod and 64-bit IDs

Computers store everything in binary and people count in decimal. Programmers write the values in between in hexadecimal (base 16) or octal (base 8) because they map neatly onto bits: one hex digit is 4 bits, one octal digit is 3. You meet them in color codes like #FF8800, in Linux permissions like 755, in file signatures and in Windows error codes such as 0x80070005.

The converter handles whole numbers of any length, because it uses BigInt, the JavaScript type for integers of arbitrary size. Ordinary JavaScript numbers are exact only up to 9007199254740991 (2^53 − 1); past that they round without warning.

Example: the largest 64-bit number

Press 64-bit max, or type 18446744073709551615 in the decimal field. That is 2^64 − 1, the largest value an unsigned 64-bit integer can hold. The hex field shows FFFFFFFFFFFFFFFF, octal shows 1777777777777777777777 and binary shows 64 ones. The table says 64 bits and 8 bytes, and the grouped hex reads FF FF FF FF FF FF FF FF.

An ordinary JavaScript number would turn the same value into 18446744073709552000, which is off by 385. Spreadsheets do something similar past 15 digits. That silent rounding is how database IDs and 64-bit counters get corrupted on their way through a script or an Excel file.

Fractions, negatives and two's complement

Only whole numbers are converted. 3.14 gives an error, and so does a number written with Colombian thousands separators, 1.000.000: remove the dots first. Commas, spaces and underscores are fine, so 1,000,000 and 1_000_000 both work. The flip side: a decimal comma is ignored too, so 1,5 is read as 15.

Negative numbers keep their minus sign: -42 becomes -2A in hex. The tool doesn't produce two's complement, the form in which a computer stores a negative number in a fixed number of bits. For the 32-bit version, add 2^32 (4294967296) first: -42 becomes 4294967254, which is FFFFFFD6 in hex.

FAQ

What is the largest number it can convert?

There's no 32- or 64-bit ceiling: `BigInt` handles numbers with thousands of digits, such as a 128-bit value (the 128-bit max button) or a 256-bit key written in hex. Paste a UUID into the hex field without its dashes and you see it as a single 128-bit number.

What do prefixes like 0x mean?

`0x` marks a hexadecimal number in languages like JavaScript, Python and C; `0b` marks binary and `0o` octal in JavaScript and Python. You can type the number with or without them.

Where is octal still used?

Mostly in Linux and UNIX file permissions. In `chmod 755`, the 7 is read (4) + write (2) + execute (1) for the owner, and each 5 is read + execute, for the group and for everyone else. In binary, `755` is `111101101`: one bit per permission.

How many bits and bytes does a number need?

The bit length is the position of the highest 1 in binary, and the byte size rounds it up to whole bytes. `255` needs 8 bits (1 byte); `256` needs 9 bits, so 2 bytes. That is the size of the number itself, not of a data type: a 64-bit variable that holds 5 still takes 8 bytes.

How do I convert a hex color to decimal RGB?

Convert each pair on its own in the hex field: in `FF8800`, `FF` is 255 red, `88` is 136 green and `00` is 0 blue. Converting the whole `FF8800` gives a single number, 16746496, which is how some programs store a color.

  • 5.1JSON formatterFormat or minify JSON and find syntax errors by line and column.
  • 5.2CSV to JSON converterConvert CSV to JSON or JSON to CSV with comma, semicolon or tab separators.
  • 5.3YAML to JSON converterConvert YAML to JSON and back in your browser.
  • 5.4Base64Encode or decode Base64 in your browser: UTF-8 text, URL-safe Base64, files to Base64 or data URLs, and Base64 back to a downloadable file.
  • 5.5Color contrast checkerCheck the contrast ratio of a text color on its background against WCAG 2.2 AA and AAA, for normal text, large text and UI components.
  • 5.6Cron explainerRead a 5-field cron expression as a plain sentence and see its next 5 run times in your time zone.
  • 5.8HTML entity encoderEncode text as HTML entities (named, decimal or hex) or decode entities back to text: <, >, &, quotes, Spanish accents, Latin-1 symbols.
  • 5.9URL encodePercent-encode or decode URLs and query values, and break any URL into protocol, host, path, query parameters and fragment.
  • 5.10SHA-256 hashGet SHA-1, SHA-256, SHA-384 and SHA-512 hashes of text or files and verify a download against its published checksum.
  • 5.11UUID generatorGenerate random UUID v4 or time-ordered UUID v7 (RFC 9562) in your browser, 1 to 1000 at a time, in uppercase or without dashes.
  • 5.12Unix timestampConvert Unix timestamps in seconds or milliseconds to ISO 8601, UTC and your local time, or a date back to epoch.
  • 5.13JWT decoderDecode a JSON Web Token in your browser: see the header and payload as formatted JSON and whether it has expired.
  • 5.14Regex testerTest regular expressions live: highlighted matches, capture and named groups, flags and clear errors.

╌╌ END ╌╌