Binary to Hex Converter
Convert raw binary streams (base-2) into hexadecimal representation (base-16) and vice versa.
Two compact views of the same values
Binary writes values with 0 and 1; hexadecimal uses sixteen digits, 0 through 9 and A through F. One hex digit corresponds to four bits, so hex is the compact notation commonly used for bytes, packet dumps, file signatures, register values, and color channels. This binary to hex converter works in both directions and formats output as space-separated byte-like groups.
The component applies a specific grouping policy: binary input is compacted and consumed eight bits at a time, while hexadecimal input is compacted and consumed two digits at a time. Understanding that policy prevents ambiguous results.
Binary to hexadecimal in practice
Select Binary to Hexadecimal and enter:
01001000 01100101 01101100 01101100 01101111
Whitespace is removed, the resulting bitstream is divided into eight-bit chunks, and each chunk becomes uppercase hexadecimal padded to at least two digits:
48 65 6C 6C 6F
Input spaces do not define the byte boundaries. 0100 10000110 0101 is first concatenated, then regrouped from the beginning. Newlines and tabs are also removed. This is convenient for formatted bit dumps but means the first bit must truly be the beginning of a byte.
If the final chunk has fewer than eight bits, it is still converted as a value and padded to two hex digits. For instance, a final 1 becomes 01; it is effectively interpreted as binary one, not as the high bit 80. Pad incomplete data explicitly according to its specification rather than assuming direction.
The reverse route
In Hexadecimal to Binary mode, spaces are removed and pairs are parsed as base 16. Each result is padded to eight binary digits:
DE AD BE EF
becomes:
11011110 10101101 10111110 11101111
An odd final hex digit is accepted as one value. A trailing F becomes 00001111, not 11110000. Add a leading or trailing zero based on the source format before conversion. Hex is case-insensitive during parsing, while output is uppercase in binary-to-hex mode.
Why byte alignment matters
Mathematically, binary-to-hex conversion can group four bits per hex digit. This tool deliberately groups eight bits and emits two-digit fields to resemble bytes. That is ideal for byte sequences but less direct for an arbitrary bit field. A 12-bit register, for example, is processed as one eight-bit chunk and one four-bit chunk, then displayed as two groups rather than a single three-digit word.
For protocol flags, determine whether fields are byte-aligned. If not, manually pad the complete value or use an integer base converter that preserves the intended word width. Leading zeros carry width information even though they do not change numeric value.
Reading a magic number
A common debugging workflow begins with a documented file signature in binary. Paste the bits, ensure the total length is divisible by eight, and compare the hex output with a reference such as 89 50 4E 47 for part of a PNG signature. If one byte differs, inspect the corresponding eight bits rather than comparing a long binary string visually.
For a packet capture, keep network byte order intact. Convert one defined field at a time, annotate offsets outside the input area, and compare with the protocol specification. The tool does not reverse byte order or bits. Little-endian integer interpretation is a separate step: bytes 34 12 may represent integer 0x1234 in little-endian storage, but this converter correctly preserves them as 34 12.
Input validation is permissive
Only whitespace is stripped. Other invalid characters remain in each chunk and are passed to parseInt. JavaScript parsing can accept a valid prefix and ignore later invalid characters. Binary chunk 0101x111 may be interpreted from its leading valid bits rather than rejected as a whole. Likewise, 0x prefixes in hex mode disrupt two-character grouping and can yield misleading output.
Use bare digits only: 0 and 1 for binary, and 0-9A-F for hex. Remove 0b, 0x, commas, underscores, addresses, ASCII gutters, and comments. Unlike whitespace, those decorations are not safely normalized. The component shows no explicit validation error; invalid chunks can be skipped or partially read.
From register documentation to code
Suppose an embedded datasheet defines a control byte as 10100110. Convert it to A6, then express that literal in source code according to the language, such as 0xA6. To verify individual flags later, convert A6 back and confirm 10100110. Keep the documented width alongside the value because source literals do not always preserve display padding.
For multi-byte registers, decide endianness only when combining bytes into an integer. This converter operates on the representation of each byte. It does not calculate signed values, two’s complement, bit masks, checksums, XOR, or numeric shifts.
Distinguish hex text from encoded data
The characters 48 69 can be interpreted as bytes representing ASCII Hi, but binary-to-hex conversion itself does not decode text. It only changes the numeral system. Similarly, a SHA-256 digest displayed as hex is not encrypted text that can be reversed; converting it to binary merely exposes the same digest bits.
Hex is also not Base64. Base64 groups six bits and uses a different alphabet and padding scheme. Do not paste Base64 into hex mode. Use a byte decoder appropriate to the original representation.
Limits and precision
Each chunk is small, so normal byte conversion avoids JavaScript large-integer precision issues. However, this implementation is not a raw-file reader and does not preserve metadata. It accepts pasted text and returns textual groups. Large dumps can stress the browser and are easier to process reproducibly with xxd, hexdump, a debugger, or a language library.
There is no configurable group width, output prefix, line length, nibble mode, or endianness setting. Output uses spaces, uppercase hex, and byte padding. Copying places exactly that displayed text on the clipboard.
Counting offsets in a dump
For a short sequence, number bytes from zero after conversion. Eight binary digits correspond to one displayed hex pair, so the fifth pair starts at byte offset four. This makes it easier to compare a protocol field table with captured data. Keep addresses outside the converter input because address digits can be mistaken for payload.
If a specification numbers bits within each byte, confirm whether bit 0 means the least significant rightmost bit or the first transmitted bit. The converter preserves written order but does not label bit significance. Transmission order, display order, and numeric significance can differ in serial protocols. Document the convention before interpreting flags.
Switching direction resets the working input
Changing the mode clears the input field rather than feeding the current output into the reverse operation. Copy or record a value before switching if you want to perform a round-trip check. For a valid byte-aligned sample, converting binary to hex, changing modes, and pasting the copied hex should reproduce eight-bit groups with the same order. An incomplete final chunk will not necessarily round-trip to the original width because output padding adds leading zeroes. That difference is useful evidence that the source lacked an explicit byte boundary, not evidence that hexadecimal changed the underlying complete bytes.
Resolving odd results
If expected bytes shift, count bits and ensure the stream begins at the correct boundary. If whitespace changes grouping unexpectedly, remember whitespace is removed before fixed eight-bit slicing. If the final value appears too small, the last chunk was incomplete and interpreted as low-order bits. If 0xFF fails, remove the prefix and enter FF.
If punctuation-containing input still generates output, do not trust it; permissive parseInt may have consumed a prefix. Sanitize the source to bare digits and retry. If bytes appear reversed relative to an integer in documentation, investigate endianness rather than manually reversing without context.
Direct answers
Does one hex digit always equal four binary bits?
Yes mathematically. This interface groups output as bytes: two hex digits correspond to eight padded binary bits.
Can I include spaces and newlines?
Yes. All whitespace is removed before grouping. Other separators should be removed manually.
What happens to an odd number of hex digits?
The final single digit becomes one eight-bit-padded value. Add the missing nibble yourself when position matters.
Does the converter change endianness?
No. It preserves chunk order and does not reinterpret a byte sequence as a multi-byte integer.
Can this reverse a hash?
No. It can represent digest bits in another base, but it cannot recover the hash input.
Is this suitable for an entire binary file?
It is intended for pasted textual bits or hex. Use byte-oriented file tools for large or arbitrary binary data.