Binary Converter
Convert text, decimal numbers, and hex values to binary โ and back. See exactly what each bit represents, with clean 8-bit grouping and instant results.
What is binary, and why does it exist?
Binary is base-2 arithmetic: every value is expressed using only the digits 0 and 1. Computers use it because the underlying hardware โ transistors โ operates in two states: off (0) and on (1). There's no practical way to reliably distinguish ten voltage levels in a circuit, but two is straightforward and noise-resistant.
Everything a computer does โ arithmetic, text rendering, networking, audio playback โ ultimately reduces to patterns of 0s and 1s moving through circuits. Higher-level abstractions like decimal numbers, text encodings, and color codes are all representations that get converted to binary before the hardware touches them.
You rarely need to think in binary for day-to-day development, but certain tasks make it unavoidable: reading network packet headers, debugging bitwise flags in configuration registers, analyzing memory dumps, or understanding why floating-point arithmetic produces unexpected results.
How each conversion type works
Text โ Binary
Each character is first mapped to a number via an encoding standard โ ASCII for basic Latin text, UTF-8 for anything beyond that. That number is then converted to base-2 and padded to 8 bits. The results are concatenated in order.
Decimal โ Binary
Divide the decimal number by 2 repeatedly, recording the remainder at each step. Read the remainders from bottom to top. This is the standard long-form method โ the tool does this automatically, but understanding it helps when reading binary output.
Hexadecimal โ Binary
This is the most mechanical of the three conversions. Each hex digit maps to exactly 4 binary digits (a nibble), with no overlap or carry. You can do it character by character.
Who uses binary conversion, and for what
Binary conversion comes up in more contexts than most developers expect. Here are the recurring situations where it's genuinely needed.
Network and subnet analysis
IP addresses and subnet masks are fundamentally binary. A /24 subnet mask is 11111111.11111111.11111111.00000000. Understanding which bits are "network" vs "host" bits requires reading them in binary โ CIDR notation is just a shorthand for bit counts.
Bitwise flags in configuration
Many APIs and system calls pack multiple boolean options into a single integer using bitwise flags. Converting the integer to binary immediately shows which flags are set. Linux file permissions (chmod 755 = 111 101 101) are a familiar example.
Embedded systems and firmware
Microcontroller registers are documented as binary bit fields. A UART control register might use bits 4โ6 for baud rate selection and bit 0 to enable the transmitter. Reading the register value in binary tells you exactly which features are active.
CS coursework and interview prep
Number system conversion โ binary, octal, decimal, hex โ is covered in most CS curricula and appears in technical interviews. Being able to do small conversions by hand, and verify them instantly with a tool, builds the intuition needed for bitwise algorithm problems.
WebAssembly and binary protocols
WebAssembly modules are binary files. High-performance web applications use ArrayBuffer and DataView to work with raw binary data for things like audio processing, image manipulation, and WebSockets. Understanding the binary layout of your data is a prerequisite.
Cryptography and hashing
Hash functions, block ciphers, and key derivation algorithms operate at the bit level using XOR, AND, OR, and bit-shift operations. Tracing through a cryptographic algorithm step-by-step requires seeing the binary values at each stage.
Concepts worth understanding
Bits, nibbles, and bytes
A bit is a single 0 or 1. Four bits make a nibble (one hex digit). Eight bits make a byte, which is the standard unit of addressable memory. This tool groups output into bytes โ 8-bit blocks โ because that's how memory is organized and how most protocol documentation presents binary data.
Two's complement for negative numbers
Signed integers use two's complement encoding. To find the binary representation of โ42: start with 42 (00101010), flip every bit (11010101), then add 1 (11010110). The most significant bit being 1 signals a negative number. This scheme means addition hardware works the same for positive and negative numbers โ no special case needed.
Boolean operations on binary
Bitwise operators (AND, OR, XOR, NOT, shifts) are the primitive operations that make binary practically useful in code. Common patterns: using AND with a mask to check or clear specific bits, using OR to set bits, and using XOR to toggle them.
IEEE 754 floating-point
Decimal fractions like 0.1 can't be represented exactly in binary โ the value repeats infinitely in base-2, like 1/3 repeats in base-10. IEEE 754 specifies how computers store a close approximation using three fields: a sign bit (positive or negative), an exponent (the magnitude), and a mantissa (the significant digits). This is why 0.1 + 0.2 !== 0.3 in JavaScript โ it's a rounding artifact of binary floating-point, not a bug.
Practical tips
Frequently asked questions
How is text converted to binary?+
Each character is mapped to a number using ASCII or UTF-8 encoding, then that number is expressed in base-2 and padded to 8 bits. The letter A is ASCII 65, which is 01000001 in binary. The letter B is 66 = 01000010. For a string like "Hi", you get two 8-bit groups concatenated: 01001000 01101001.
Why is the output grouped in sets of 8?+
Eight bits form one byte โ the standard unit of memory addressing. Nearly all hardware and protocol documentation presents binary data in bytes. Grouping this way makes it far easier to map binary output back to specific characters, values, or fields.
How are negative numbers represented?+
Most systems use two's complement. Take the positive binary value, flip all bits, then add 1. The result has a 1 in the most significant bit, which signals that it's negative. This lets the same addition circuit handle both positive and negative numbers without any special cases.
Why use hex instead of binary for large values?+
Binary is verbose. A 32-bit integer is 32 characters; in hex it's 8. Since every 4 binary digits map exactly to one hex digit, the conversion is lossless and mechanical. Memory addresses, byte arrays, and color codes are all conventionally displayed in hex for exactly this reason.
Is binary still relevant for web development?+
More than most people realize. The Web Crypto API, WebAssembly, Canvas image data, WebSockets with binary frames, and file reading via FileReader all work with binary data directly. If you've ever used ArrayBuffer, DataView, or Uint8Array, you've been working with binary.