Number Base Converter — Binary, Octal, Decimal, Hex | LazyTools

Number Base Converter

Convert instantly between Binary, Octal, Decimal and Hexadecimal — with step-by-step workings, 2s complement signed integers, IEEE 754 float preview, colour-coded nibbles, copy-as-code literals and batch mode. The most complete free base converter for developers and students.

Step-by-step workings 2s complement Batch conversion Copy as code literal

Number Base Converter Tool

Bit width
⭐ User Ratings

Rate this tool

4.9
Based on 28,341 ratings
5
24,940
4
2,267
3
850
2
142
1
142
Was this base converter helpful?
✅ Thank you for rating this tool!
✦ Features

The most complete free number base converter for developers and students

Every other free base converter is a bare-bones four-field input. This one adds step-by-step workings, 2s complement, IEEE 754 float preview, colour-coded nibble groups, copy-as-code literals and batch mode — features that are scattered across paid tools or simply absent online.

Instant 4-way conversion
Type in any field — Binary, Octal, Decimal or Hexadecimal — and all three other fields update instantly on every keystroke. Spaces and underscores in binary input are accepted and stripped automatically. Uppercase and lowercase hex are both valid.
Step-by-step workings for every conversion
For every conversion, the tool shows the complete mathematical working — positional notation expansion for binary-to-decimal, repeated division for decimal-to-hex, and group-substitution for binary-to-hex. The explanation updates live as you type, making it an ideal study companion.
Signed integers — 2s complement (8, 16, 32-bit)
Toggle the 2s complement panel to see the signed interpretation of the current value in 8-bit, 16-bit and 32-bit representations. The tool shows the 1s complement, the 2s complement, and the decimal signed value for each bit-width. Essential for low-level programming and computer architecture coursework.
Colour-coded nibble groups
The binary output is split into nibbles (4-bit groups) each shown in a distinct colour, making it easy to visually map binary to hexadecimal (each hex digit = one nibble). A bit-width selector pads the binary output to 4, 8, 16, 32 or 64 bits with leading zeros.
Copy as code literal — 6 languages
Click any code literal chip to copy the value in the correct format for your language: Python (0b1010, 0o17, 0xFF), C/C++ (0b1010, 017, 0xFF), JavaScript (0b1010, 0o17, 0xFF), Assembly (0AFh), Java (binary string), and plain integer. Each click copies instantly with visual confirmation.
IEEE 754 single precision float preview
Enable the IEEE 754 float toggle to see the floating-point interpretation of a 32-bit binary pattern. The tool shows the sign bit, 8-bit biased exponent, and 23-bit mantissa in colour, then computes the decimal float value using the formula (−1)^sign × 2^(exponent−127) × (1 + mantissa). Handles subnormals, infinity and NaN.
Batch conversion mode
Switch to the Batch tab and paste a list of values — one per line. Select the source base and the target base, click Convert All, and every value is converted simultaneously. The output appears line-by-line in the right panel. Copy all results with one click. Ideal for converting large lists of values in embedded systems, networking or data analysis work.
Bit-width selector
Select 4-bit, 8-bit, 16-bit, 32-bit or 64-bit mode. The binary output is padded with leading zeros to fill the selected width, matching what you would see in a register view, hex editor or assembly debugger. The 2s complement panel shows signed ranges appropriate to the selected width.
Input validation with clear error messages
Invalid characters trigger an inline error message per field — for example "Only digits 0 and 1 are valid in binary" or "Use digits 0–9 and A–F for hexadecimal". The error appears beneath the invalid field and clears the other outputs to avoid showing results based on invalid input.
📖 How to use

How to use the Number Base Converter

Type your number in any field
Click on the Binary, Octal, Decimal or Hexadecimal input and start typing. You can use spaces or underscores in binary for readability (e.g. 1010 1111) — they are stripped automatically. Hex accepts both uppercase (AF) and lowercase (af).
See all bases update instantly
All three other output fields fill in immediately as you type. The colour-coded nibble display shows your binary value split into 4-bit groups. The code literals panel shows the equivalent in Python, C, JavaScript and more formats.
Read the step-by-step explanation
Scroll down to see the full conversion workings — how the number you entered is expanded positionally, what each calculation step is, and how the final result is reached. This is shown for the conversion from the field you typed in to all other bases.
Enable 2s complement or IEEE 754
Tick the 2s complement checkbox in the controls bar to see the signed representation of the value in 8-bit, 16-bit and 32-bit. Tick IEEE 754 float to interpret a 32-bit binary pattern as a floating-point number with sign, exponent and mantissa breakdown.
Copy a value or code literal
Click the Copy button on any output field to copy the plain number. Click any code literal chip — for example the Python chip — to copy the value in Python's native binary literal format (0b10101111). The chip turns green briefly to confirm the copy.
Batch convert a list of numbers
Switch to the Batch tab. Paste a list of values one per line into the left text area. Select the source and target bases from the dropdowns, then click Convert All. Results appear instantly in the right panel — click Copy output to copy all results at once.
🏆 Why LazyTools

How this base converter compares

Feature LazyTools ✦ RapidTables Browserling binaryhexconverter.com
Binary ↔ Octal ↔ Decimal ↔ Hex✔ All 4✔ All 4✔ Most✔ All 4
Step-by-step workings shown✔ Full steps✔ Partial✘ No✘ No
Colour-coded nibble groups✔ Yes✘ No✘ No✘ No
2s complement signed integers✔ 8/16/32-bit✔ Separate page✘ No✘ No
IEEE 754 float preview✔ 32-bit✘ No✘ No✘ No
Copy as code literal (Python, C, JS…)✔ 6 formats✘ No✘ No✘ No
Batch conversion mode✔ Yes✘ No✔ Some✘ No
Bit-width selector (4/8/16/32/64)✔ Yes✘ No✘ No✘ No
Input validation with error messages✔ InlineSilentSilentSilent
No ads or pop-ups blocking the tool✔ CleanHeavy adsAdsHeavy ads
📊 Quick reference

Binary, Octal, Decimal and Hex reference — 0 to 255

DecimalBinaryOctalHexCharacter (ASCII)
📖 Complete guide

Number Systems Explained — Binary, Octal, Decimal and Hexadecimal for Developers and Students

Every digital computer ultimately works in binary — sequences of 0s and 1s representing the off and on states of billions of transistors. But working directly with long binary strings is impractical for human programmers, which is why octal and hexadecimal number systems were developed as shorthand representations of binary data. Understanding how to convert between binary, octal, decimal and hexadecimal is a foundational skill in computer science, embedded systems development, network engineering, digital electronics and computer architecture.

The decimal number system (base 10)

Decimal is the number system humans use in everyday life. It uses ten symbols (0–9) and is a positional system where each digit's value is determined by its position multiplied by a power of 10. The number 347 means 3 × 10² + 4 × 10¹ + 7 × 10⁰ = 300 + 40 + 7. Decimal is the native language of human arithmetic but is not directly used by digital hardware, which fundamentally operates on binary signals.

The binary number system (base 2)

Binary uses only two symbols — 0 and 1 — and each position represents a power of 2. For example, 1011 in binary means 1 × 2³ + 0 × 2² + 1 × 2¹ + 1 × 2⁰ = 8 + 0 + 2 + 1 = 11 in decimal. This base-2 system is the language of digital logic because electronic circuits are most reliably built to distinguish between two states (high and low voltage). Every piece of data in a computer — text, images, programs, network packets — is ultimately stored and processed as binary. An 8-bit group of binary digits is called a byte, and bytes are the fundamental unit of digital data storage.

The hexadecimal number system (base 16)

Hexadecimal uses 16 symbols: the digits 0–9 plus the letters A–F representing values 10–15. Each hex digit maps exactly to a 4-bit binary nibble, making it extremely convenient for reading binary data. The conversion between hex and binary requires no arithmetic — you simply substitute each hex digit with its 4-bit binary equivalent. For example, the hex value AF converts to binary 1010 1111 (A = 1010, F = 1111). Hexadecimal is used pervasively in computing for memory addresses (0x7FFF0000), colour codes in CSS (#FF5733), network MAC addresses (00:1A:2B:3C:4D:5E), byte-level data in hex editors, and assembly language programming.

The octal number system (base 8)

Octal uses digits 0–7, and each octal digit maps to exactly 3 binary bits. Octal was more commonly used in early computing — systems like the PDP-8 and various early Unix systems used it extensively. Today its most visible use is in Unix file permissions: the permission chmod 755 sets permissions as octal 7 (rwx = 111), 5 (r-x = 101), 5 (r-x = 101). Octal is less commonly encountered than hexadecimal in modern programming but remains relevant in Unix system administration and some embedded system contexts.

How to convert binary to decimal — step by step

Write the binary number with position indices starting at 0 on the right. Multiply each binary digit by 2 raised to the power of its position index, then sum all the results. For binary 10110101: 1×2⁷ + 0×2⁶ + 1×2⁵ + 1×2⁴ + 0×2³ + 1×2² + 0×2¹ + 1×2⁰ = 128 + 0 + 32 + 16 + 0 + 4 + 0 + 1 = 181. The LazyTools converter shows this complete positional expansion for every binary input.

What is 2s complement and why does it matter?

2s complement is the standard method computers use to represent negative integers. Without a signed representation scheme, a binary pattern like 11111111 in 8-bit would be ambiguous — it could mean either 255 (unsigned) or −1 (signed 2s complement). In 2s complement, the most significant bit (MSB) acts as a sign bit: 0 means positive, 1 means negative. To negate a number in 2s complement, invert all bits (creating the 1s complement) then add 1. The 2s complement of 00000101 (+5) is 11111010 + 1 = 11111011, which represents −5 in signed 8-bit. This scheme is used because it allows subtraction to be implemented using the same adder circuit as addition — a major hardware simplification. The 8-bit signed range is −128 to +127; the 16-bit range is −32,768 to +32,767; the 32-bit range is −2,147,483,648 to +2,147,483,647.

IEEE 754 floating point — how computers represent decimals

Integers are straightforward in binary, but representing numbers with decimal fractions requires a different scheme. The IEEE 754 standard defines how floating-point numbers are stored using three components: a sign bit (0 = positive, 1 = negative), a biased exponent field (8 bits in 32-bit single precision, bias of 127), and a mantissa or significand (23 bits in 32-bit). The formula for decoding is: value = (−1)^sign × 2^(exponent − 127) × (1 + mantissa). Special cases include zero (all bits zero), infinity (exponent all 1s, mantissa zero) and NaN — Not a Number (exponent all 1s, mantissa non-zero). Understanding IEEE 754 is critical for anyone working in scientific computing, graphics programming, embedded systems or numerical analysis.

Common conversions for developers

Developers frequently need base conversions in several specific contexts. CSS colour codes use 6 hex digits representing three bytes for red, green and blue channels — #FF5733 is red=255 (0xFF), green=87 (0x57), blue=51 (0x33). Network IP addresses in binary are important for understanding subnetting — the IP 192.168.1.1 in binary is 11000000.10101000.00000001.00000001. Memory addresses in debuggers and assembly are nearly always shown in hexadecimal. Bitmask operations in C and embedded programming use binary or hex representations of flag values. Character encoding in ASCII maps directly to decimal values 0–127, each corresponding to a unique binary pattern.

Number base prefixes in programming languages

Every major programming language has a standard notation for expressing integer literals in different bases directly in source code. In Python 3, binary literals use the 0b prefix (e.g., 0b10101111), octal uses 0o (e.g., 0o257), and hex uses 0x (e.g., 0xAF) — all three evaluate to decimal 175. In C and C++, hex uses 0x, octal uses a leading zero (0257), and binary literals were added in C++14 with 0b. JavaScript supports 0b, 0o and 0x in modern ES6. Assembly language typically uses a trailing h suffix for hex (e.g., 0AFh). Understanding these prefixes is important when reading code across languages and copying values between tools and source files. This converter's copy-as-code literals panel generates the correct syntax for Python, C, JavaScript and Assembly automatically.

Bit manipulation and bitmask operations

One of the most practical applications of binary and hexadecimal in programming is bitwise operations and bitmask patterns. A bitmask is a value where specific bits are set to 1 to indicate which flags or options are active. For example, in Unix file permissions, binary 10101101 (hex 0xAD) has bits set corresponding to read, write and execute permissions for owner, group and others. Bitwise AND tests whether a specific bit is set, bitwise OR sets a bit, bitwise XOR toggles a bit, and bitwise NOT inverts all bits. Working with bitmasks almost always requires converting between binary (to see which bits are set) and hex (for compact notation in code). The colour-coded nibble display in this converter groups bits into visually distinct 4-bit sections specifically to make bitwise analysis easier — each coloured nibble maps directly to a single hex digit, letting you instantly read which bits are active in any byte-level value.

Frequently asked questions

Multiply each binary digit by 2 raised to the power of its position (counting from 0 on the right), then sum the results. For binary 1011: 1×8 + 0×4 + 1×2 + 1×1 = 11. The tool shows these steps automatically for every conversion.
Divide the decimal number by 16 repeatedly. Record each remainder (using A–F for 10–15). Read the remainders from bottom to top for the hexadecimal result. Example: 255 ÷ 16 = 15 remainder 15 (F); 15 ÷ 16 = 0 remainder 15 (F). Result: FF. So decimal 255 = hex FF = binary 11111111.
To find the 2s complement of a number: (1) write the number in binary, (2) invert all bits (0→1, 1→0) to get the 1s complement, (3) add 1 to the result. For example, to represent −5 in 8-bit: 5 = 00000101 → invert → 11111010 → add 1 → 11111011. Reading this as a signed 8-bit integer gives −5. In 2s complement, the MSB (leftmost bit) is the sign bit — 1 means negative.
Hexadecimal is much more compact than binary — a single hex digit represents exactly 4 binary bits (a nibble), so an 8-bit byte needs only 2 hex digits instead of 8 binary digits. For example, the byte 11001111 is just CF in hex. This makes hex strings much easier to read, remember and type while retaining a direct, no-arithmetic mapping to the underlying binary data. A 32-bit address like 0x7FFF0000 is far more readable than its 32-digit binary equivalent.
The 0x prefix is the standard notation in C, C++, Java, JavaScript, Python and many other languages for hexadecimal literals. For example, 0xFF means hexadecimal FF, which is 255 in decimal. Similarly, 0b is the prefix for binary literals (0b11111111 = 255) and 0o (or just a leading 0 in older C) is the prefix for octal literals. Python and modern JavaScript use 0b and 0o; classic C uses a leading zero for octal (0377 = 255). The copy-as-code literals feature in this tool provides the correct prefix for each language automatically.
🔗 Related tools

More free developer and converter tools