//Tools  ·  /tools/base-convert/about

← Back to the tool

About number base conversion.

A practical explainer for anyone who has ever stared at 0xDEADBEEF and wondered which decimal that is, what a 256-bit hash looks like in binary, or why chmod 755 is an octal number.

1. What this tool does

The Number Base Converter turns a single integer into four equivalent representations — binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) — and updates all of them every time you change one. The workflow is paste, read, copy. Paste a hex value out of a debugger; the decimal lands in the next field. Type a 32-character binary string; the hex form is one click away. The four fields are always in sync because they are four different printings of the same underlying integer, not four independent inputs being reconciled.

The tool runs entirely inside your browser tab. There is no upload, no server round-trip, no account, and no history kept across reloads. For anything that fits in a 64-bit machine integer the conversion is instant; for larger values — 256-bit hashes, RSA moduli, blockchain identifiers — a JavaScript BigInt path takes over so every digit round-trips exactly, with no silent rounding into floating-point error.

2. Why we represent numbers in different bases

Every positional numeral system uses the same rule. A number is a sum of weighted digits: the right-most digit counts ones, the next counts b, the next , and so on. Change the base b and you change the place values and the digit alphabet, but the rule and the underlying quantity stay identical. The decimal number 255, the hex number FF, and the binary number 11111111 all denote the same eight ones followed by a zero of two-hundred-fifty-sixes. This is the framing Knuth uses in TAOCP volume 2, chapter 4: positional notation is a uniform algorithm and the base is a parameter to it.[1]

We do not write everything in decimal because decimal is awful for computer hardware. Bits are physical: a wire is either high or low, a transistor either conducts or does not. Hardware groups bits into bytes and words because those groupings align with memory addresses and ALU widths. When we want a human- readable view of those bit patterns, we want a base whose digits line up cleanly with the underlying bits. Powers of two do. Three bits make one octal digit; four bits make one hex digit; ten bits do not make anything in particular. That is the whole story of why hex dumps are readable and decimal memory dumps are not.

3. A brief, accurate history

The positional decimal system the modern world uses came out of Indian mathematics between the fifth and seventh centuries — the same tradition that gave us zero as a number rather than a placeholder gap. It travelled west through the Persian and Arabic mathematical schools, was assembled in al-Khwārizmī’s ninth-century arithmetic and Fibonacci’s Liber Abaci (1202), and eventually displaced Roman numerals across Europe by the late Middle Ages. Every modern base — 2, 8, 16, 60 (clocks), 12 (eggs) — uses the same positional rule, just with a different b plugged in.

Binary, as a notation, was formalised by Gottfried Wilhelm Leibniz in Explication de l’Arithmétique Binaire (1703). Leibniz was after a theology of two, not a computer; he was delighted to recognise the system in the hexagrams of the I Ching. Binary as a computingnotation arrived with Claude Shannon’s 1937 MIT master’s thesis, A Symbolic Analysis of Relay and Switching Circuits, which showed that Boolean algebra describes the behaviour of electrical relays. Once you can compute Boolean expressions in hardware, base-2 numerals are the obvious notation for the quantities those relays carry.

Hexadecimal was promoted into the mainstream by IBM in the early 1960s. The System/360 architecture, announced in 1964, standardised the eight-bit byte and used hex throughout its dumps, microcode listings, and reference manuals. Bob Bemer is usually credited with arguing for the 0–9 A–F digit choice and the name “hexadecimal” (over alternatives like “sexadecimal”, which IBM thought was a marketing risk). Octal had its moment a generation earlier: the Digital Equipment PDP-1 (1959), PDP-8 (1965), and PDP-11 (1970) all used 12-, 16-, and 18-bit words that partitioned cleanly into three-bit octal digits. Octal mostly retired with those machines, but it survived in one load-bearing place: Unix file permissions, where chmod 755 is three octal digits each encoding a three-bit rwx triple.

4. The technical principles

Positional notation. A non-negative integer n written in base b ≥ 2 is a finite sequence of digits d_k … d_1 d_0 where each digit d_i is in the range 0 ≤ d_i < b and n = Σ d_i · b^i. Converting between bases is the algorithm of repeatedly dividing by the target base and reading the remainders — the algorithm taught in primary school for “long division” — which is what BigInt.prototype.toString(b) and Number.prototype.toString(b) do under the hood per ECMA-262 §21.[2]

Why 2, 8, 16 are computer-friendly. Because 8 = 2³ and 16 = 2⁴, every octal digit is exactly three binary digits and every hex digit is exactly four. Regrouping between these bases is mechanical: chop the binary string into groups, look each group up in a 4- or 16-entry table, done. No arithmetic. This is the same reason that xxd, hexdump, and every debugger you have ever used render memory in hex — the bytes line up.

JavaScript Number vs BigInt. JavaScript’s Number type is IEEE 754 binary64 floating point. Integers are exact only up to Number.MAX_SAFE_INTEGER, which is 2^53 − 1 ≈ 9.007 × 10¹⁵. Above that, integer values round to the nearest representable double, silently. The classic demonstration is parseInt("9007199254740993", 10), which evaluates to 9007199254740992 — off by one. ECMAScript 2020 (TC39, 2020) added BigInt for arbitrary-precision integers; this tool always parses through the BigInt path, so a 256-bit hex hash round-trips bit for bit with no precision loss.[2]

Why parseInt always needs the base. The single-argument form parseInt(s) infers the radix from the string prefix: 0x means 16, no prefix means 10, and on some older engines a leading 0 meant 8 (so parseInt("010") was 8, not 10). The two-argument form parseInt(s, 10) is unambiguous and the only form this tool ever uses.

5. Common use cases

Firmware and embedded developers paste sensor registers between hex (the datasheet) and binary (the bit fields) all day. Networking engineers swing between hex (MAC addresses, IPv6 segments) and decimal (port numbers, MTU sizes). Security researchers and CTF players bounce hash digests and protocol identifiers between hex and binary to find structure. Web developers convert CSS colour values like #E07B3A into (224, 123, 58) decimal triples. Systems admins reach for octal to read and write Unix permission masks. Computer-science students use a base converter as scaffolding while their intuition for binary and hex is still under construction.

6. Anti-patterns

Reading a signed binary value here. This tool renders negatives as a leading - plus the magnitude in each base. It does not render two’s-complement bit patterns — there is no notion of a fixed width here. If you need to see -1 as 0xFFFFFFFF in 32 bits, that is a separate tool with a bit-width selector.

Inspecting a floating-point bit pattern. IEEE 754 floats decompose into sign, exponent, and mantissa fields — a different mental model from integer base conversion. Conflating the two is a bug factory; this tool refuses to do it on purpose.

Trusting parseInt("010"). In modern engines it returns 10. In legacy engines it returned 8. Always pass the radix. This tool always does.

7. How to choose a base

Decimal is the right base when humans are the audience: print statements, error messages, financial amounts. Hex is the right base when bytes are the audience: memory dumps, hashes, colour codes, MAC and IPv6 addresses, JWT signatures. Binary is the right base when bits are the audience: bitfield layouts, network protocol headers, hardware registers, teaching boolean operations. Octal earns its keep in two places only: Unix file permissions and legacy 12-/18-/36-bit machine listings. If you are reaching for octal anywhere else, pause and check whether hex would do the job more cleanly.

References

  1. Knuth, D. E. (1997). The Art of Computer Programming, Vol. 2: Seminumerical Algorithms (3rd ed.), §4.1 “Positional Number Systems.” Addison-Wesley. www-cs-faculty.stanford.edu/~knuth/taocp.html — canonical reference for positional notation and the radix- conversion algorithms underlying this tool.
  2. Ecma International (2024). ECMAScript® 2024 Language Specification (ECMA-262), §21.1.2.13 parseInt, §21.1.3.6 Number.prototype.toString, §21.2 BigInt. tc39.es/ecma262 — primary specification of the exact parseInt(s, base), Number.prototype.toString(base), and BigInt semantics the tool is built on.

Related tools

  • Hash Generator — SHA-256 / SHA-1 / MD5 produce a hex digest that users often immediately paste into a base converter to inspect decimal / binary representation or compare bit counts. Tightest workflow pair in the catalog.
  • Base64 / URL / HTML Encoder–Decoder — sibling representation tool. Base64 isbase 64 with a printable alphabet; users reaching for “convert this thing into a different representation” land in one of these two pages.
  • JWT Decoder — JWT payloads are Base64URL chunks with byte counts that matter for crypto reasoning. The bits / digits mono row on this tool answers questions the JWT tool surfaces.
  • Color Converter — HEX #E07B3A ↔ RGB (224, 123, 58) ↔ HSL is a specialization of the same positional-notation idea this tool covers. Users who think in CSS color values are already comfortable with hex-to-decimal mental math.