Number Base Converter

Share:
Developer Tools

Number Base Converter

Convert between binary, octal, decimal and hexadecimal — instantly.

By Checked against sources by Last reviewed BINARY DECIMAL DEVELOPER HEX OCTAL
Your browser is too old for this tool’s interactive features. Please update to Safari 13.1, Chrome or Edge 80, Firefox 74 or newer.

Number Base Converter Tool

Bit length:
Sample values:
🔵 Binary Base 2
🟠 Octal Base 8
🟢 Decimal Base 10
🔴 Hex Base 16

255 needs 8 bits unsigned, 9 as a signed (two's complement) value. Fits: smallest unsigned type uint8; smallest signed type int16.

Negative value. Every base is showing sign-magnitude — a minus sign followed by the magnitude, so −13 is −1101 in binary, −15 in octal and −D in hex. Turn on Signed (two's complement) above to see the bit pattern a CPU would actually store at the selected bit length.

Advertisement
After results · AD-W1 Responsive · Post-tool — peak engagement

How to Use the Number Base Converter

Type in any field

Enter a binary, octal, decimal or hex value into any of the four input fields — all other fields update instantly as you type. Binary accepts 0s and 1s; hex auto-capitalises to A–F.

Toggle digit grouping

Enable Group digits to format binary output in groups of 4 with spaces (e.g. 0101 1010) and hex in groups of 2, making long values much easier to read.

Select bit length

Choose 8, 16, 32 or 64-bit to pad every base to that width, as a register or protocol field holds it. A width you select is enforced: a value too large for it is rejected with the exact range, in whichever field you typed it, instead of silently overflowing into more bits than you asked for. With Signed on, a binary, octal or hex entry is read as a pattern of that width, so FF at 8 bits is −1. Auto shows the minimum digits. The line under the fields says how many bits the value needs and the smallest standard integer type that holds it.

Use the Copy button

Click the Copy button beside any field to send that value to your clipboard — ready to paste directly into your code, terminal, or documentation.

Advertisement
After how-to · AD-W2 Responsive

Number Systems in Computing — Why Computers Don't Think in Tens

Why Computers Think in Binary

At its most fundamental level, every computer is a collection of billions of tiny switches called transistors. Each transistor has exactly two states: on or off, conducting or not conducting, representing 1 or 0. This is why binary — the base-2 number system — is the native language of all digital electronics. Unlike humans who evolved with ten fingers and naturally count in base 10, electronic circuits are built around the simplest possible distinction: current flows, or it doesn't.

Eight bits grouped together form a byte, capable of holding 256 distinct values (0 to 255). This is why file sizes, memory capacities, and network speeds are measured in bytes, kilobytes, megabytes, and so on. Modern CPUs are 64-bit, meaning their registers hold 64 binary digits — 2⁶⁴, about 18 quintillion, distinct values.

The width of those groups is not a detail — it is a hard boundary you can compute. An n-bit unsigned field holds 0 to 2ⁿ − 1; the same field read as signed two's complement holds −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1. For 8 bits that is 0–255 unsigned, or −128 to +127 signed. Select a bit length above and this converter will refuse a value that does not fit, rather than quietly printing more bits than you asked for.

Hexadecimal: The Programmer's Shorthand

Reading raw binary quickly becomes impractical. A 32-bit memory address in binary is 32 characters long — unwieldy to read, type, or verify. Hexadecimal (base 16) solves this elegantly: because 16 is exactly 2 to the power of 4, one hex digit maps perfectly onto four binary digits (a nibble). A 32-bit address shrinks from 32 binary digits to just 8 hex digits.

Programmers encounter hex constantly. RGB colour codes in CSS and design tools use hex: the RECATOOLS accent colour #E8622A encodes red=232 (0xE8), green=98 (0x62), blue=42 (0x2A). MAC addresses on your Wi-Fi adapter look like AA:BB:CC:DD:EE:FF — six pairs of hex bytes identifying your network interface. URL-encoded characters use hex: the space character becomes %20 because 0x20 is 32 in decimal, which is the ASCII code for space. When debugging at the byte level — reading memory dumps, packet captures, or binary file headers — hex is the universal language of low-level programming.

How Base Conversion Works Step by Step

Converting decimal to binary uses repeated division: divide the number by 2, record the remainder (0 or 1), divide the quotient by 2 again, and continue until the quotient is zero. Reading the remainders from bottom to top gives the binary representation. For example, 13 ÷ 2 = 6 R1, 6 ÷ 2 = 3 R0, 3 ÷ 2 = 1 R1, 1 ÷ 2 = 0 R1 → binary 1101.

Converting binary to decimal uses positional notation: each bit position carries a power of 2, with the rightmost bit representing 2⁰ = 1. So 11111111 = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. Hex to binary is even simpler: each hex digit maps directly to a four-bit group (a nibble). F = 1111, A = 1010, so FA = 1111 1010 — no arithmetic required, just a lookup table.

Octal (base 8) was widely used in early Unix systems and remains relevant today: Unix file permissions are expressed in octal. The familiar chmod 755 means owner has rwx (4+2+1=7), group has r-x (4+0+1=5), others have r-x (5) — expressed in binary as 111 101 101. Each octal digit maps to exactly three binary digits, making octal a natural fit for permission triplets. IPv4 addresses like 192.168.1.1 are human-readable decimal representations of 32-bit binary numbers, where each of the four octets (0–255) corresponds to one byte of the address.

Negative numbers in binary use two's complement — the standard representation in virtually all modern CPUs. To negate a number: flip all bits, then add 1. For an 8-bit signed integer, the range is −128 to +127. The Year 2038 problem is the same arithmetic at 32 bits: the largest signed 32-bit value is 2³¹ − 1 = 2,147,483,647, and a counter of seconds that starts at 1970-01-01T00:00:00Z reaches that value at 2038-01-19T03:14:07Z. Work it out yourself — 2,147,483,647 seconds is about 68.05 years — and the famous date stops being folklore and becomes a division you can check.

Frequently Asked Questions

  • Type your decimal number into the Decimal (green) field and the binary result appears instantly. Manually, divide the number by 2 repeatedly and read the remainders from bottom to top: 13 ÷ 2 = 6 R1, 6 ÷ 2 = 3 R0, 3 ÷ 2 = 1 R1, 1 ÷ 2 = 0 R1 → binary 1101. Enable Group digits to format the result in groups of 4 for easy reading.
  • Hexadecimal (base 16) uses digits 0–9 and letters A–F (for values 10–15). Programmers prefer it because one hex digit maps exactly to 4 binary digits (a nibble), making large binary values far more compact. A 32-bit address that requires 32 binary digits needs only 8 hex digits. Hex appears everywhere in programming: memory addresses, RGB colours (#E8622A), MAC addresses, and URL encoding (%20 for space).
  • A byte is exactly 8 bits. This means one byte can hold 2⁸ = 256 different values (0 to 255). All digital storage — from SSD capacity to RAM size to network bandwidth — is measured in bytes or multiples thereof (kilobytes, megabytes, gigabytes). Select the 8-bit button in this converter to see binary output padded to exactly one byte.
  • Two's complement is the standard method for representing negative integers in binary. To negate a number: flip all its bits (one's complement), then add 1. For example, +5 in 8-bit binary is 00000101. Flip all bits: 11111010. Add 1: 11111011 = −5. This system lets CPUs subtract using the same addition circuits, and ensures only one representation of zero. Enter a negative number in this converter and, with Signed off, every base shows sign-magnitude (−5 → −101); switch it on and binary, octal and hex all show the stored two's complement pattern instead (11111011, 373, FB at 8 bits). It works backwards as well: at a fixed width with Signed on, type 11111011 in the binary field and the decimal field shows −5.
  • Unix permissions have three groups (owner, group, others), each with three bits (read, write, execute) — totalling 9 bits. Since one octal digit represents exactly 3 binary digits, three octal digits perfectly encode all nine permission bits. chmod 755 means 7=111 (rwx), 5=101 (r-x), 5=101 (r-x) — the owner can read, write and execute; group and others can read and execute only.
  • A hex colour like #E8622A is three two-digit hex values: E8 = red, 62 = green, 2A = blue. Enter each pair into the Hex field of this converter to get the decimal values: E8 = 232, 62 = 98, 2A = 42. So #E8622A = RGB(232, 98, 42) — the RECATOOLS coral orange. For a full colour conversion including HSL and CMYK, try the RECATOOLS Color Converter.
  • A 32-bit unsigned integer can hold values from 0 to 4,294,967,295 (2³² − 1). A 32-bit signed integer (using two's complement) ranges from −2,147,483,648 to +2,147,483,647. Select 32-bit in this converter and enter 4294967295 to see it in all four bases. The signed limit is the Year 2038 problem on any system that still keeps Unix time in a signed 32-bit integer.
  • Unix time counts seconds since 1 January 1970 (the Unix epoch), and many systems historically stored it in a signed 32-bit integer. The maximum value of a 32-bit signed integer is 2³¹ − 1 = 2,147,483,647 — that many seconds is roughly 68.05 years, which lands on 03:14:07 UTC on 19 January 2038. After that moment, the counter overflows to a large negative number, potentially causing systems that haven't migrated to 64-bit timestamps to malfunction. This is directly analogous to the Y2K issue but in binary arithmetic.
  • This converter uses JavaScript's native BigInt type, which supports arbitrarily large integers with no precision loss — unlike standard floating-point numbers, which lose accuracy above 2⁵³. You can safely enter values well beyond 32-bit or 64-bit limits and receive exact conversions across all four bases. All conversions happen locally in your browser; no data is sent to any server.
  • Valid hexadecimal characters are the digits 0–9 and the letters A through F (or a–f in lowercase). This gives 16 possible values per digit position: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A (=10), B (=11), C (=12), D (=13), E (=14), F (=15). This converter auto-converts lowercase input to uppercase. The letters G–Z and any special characters are not valid hex and will trigger an error message showing which character is invalid.

Related News

You may be interested in these recent stories from our newsroom.

View all news →

Method & sources

How it computes

Binary, octal, decimal and hex kept in step with BigInt, so any size converts exactly. Fixed 8/16/32/64-bit widths pad every base and are enforced: n bits hold 0 to 2ⁿ − 1 unsigned or −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1 signed. With Signed on, negatives show as two's complement and a typed pattern reads back (FF at 8 bits = −1), checked against BigInt.asIntN/asUintN.

What this tool implements

  • Two's complement is defined as ECMA-262 defines BigInt.asIntN and asUintN (§21.2.2.1-2): the pattern is the value modulo 2^n, and a pattern whose top bit is set reads as pattern − 2^n. The test suite compares the converter with those engine primitives on 11,200 seeded cases across 8, 16, 32 and 64 bits (display, read-back and decimal entry, signed and unsigned).
  • Reading a pattern back: at a fixed width with Signed on, a binary, octal or hex entry without a minus sign is read as an n-bit pattern, so the page accepts the value it displays. Until 2026-11-05 it displayed −1 as FF at 8 bits and rejected FF as out of range when typed.
  • Auto width for a negative value is the smallest power of two from 8 bits up that holds it, with no upper cap. Until 2026-11-05 the search stopped at 64 bits, so −2^70 was truncated to 64 bits and shown as 0.
  • Fixed widths pad binary to n digits, hex to n/4 and octal to ⌈n/3⌉; digit grouping pads to whole nibbles (binary) or bytes (hex) from the right.
  • Input accepts spaces, underscores and a 0b / 0o / 0x prefix matching the field; a prefix for another base is an error, and in the hex field "0b…" is read as hex digits. A size line states the bits the value needs unsigned and signed and the smallest uint8-uint64 / int8-int64 type that holds it.
  • Worked values pinned in the tests: −5 at 8 bits = 11111011 / 373 / FB; #E8622A = 232, 98, 42; 2^31 − 1 seconds after the Unix epoch = 2038-01-19T03:14:07Z, about 68.05 years of 365.2425 days.

Sources

  • Ecma International. ECMA-262, ECMAScript Language Specification — §21.2.2.1 BigInt.asIntN, §21.2.2.2 BigInt.asUintN, §21.2.3.3 BigInt.prototype.toString ( [ radix ] ): https://tc39.es/ecma262/

What can make this go out of date

  • None at runtime. Every conversion runs in the browser; nothing typed is sent anywhere, stored, or put in the URL.
Advertisement
Pre-footer · AD-W3 728 × 90