Binary to Hex
Convert binary numbers to hexadecimal quickly with support for padding, two's complement, bit-widths, grouping and BigInt-sized inputs
Updated
What is the Binary to Hex?
Convert binary numbers into hexadecimal fast and reliably. This tool accepts flexible binary input (spaces, underscores, and a 0b prefix), handles large integers using BigInt, supports explicit bit widths, and can interpret values as unsigned or two's complement signed integers. Output options include padded or minimal hex, uppercase or lowercase, and nibble grouping (for readable byte/word grouping). The interface is designed for developers, firmware engineers, and anyone working with low-level data formats who needs accurate, production-grade conversions without external dependencies.
How it works
- Input normalization
- The tool first trims the input and removes common separators such as spaces and underscores, and also accepts a leading
0bor0Bprefix. - It validates that only the characters
0and1remain, otherwise it returns a clear validation error.
- Bit-width handling and padding
- If you provide an explicit bit width, the tool validates the width (integer between 1 and 1024) and ensures the input fits or is left-padded with zeros.
- If you leave bit width empty, the tool uses the minimal width required by the input bits.
- BigInt parsing and masking
- The cleaned binary string is parsed to a BigInt to support large inputs reliably.
- When a bit width is specified, the value is masked to that width (equivalent to taking the lower N bits).
- Two's complement (signed) interpretation
- If signed mode is selected, the tool interprets the masked unsigned value as a two's complement signed integer for the chosen bit width and returns the signed decimal representation.
- Hex formatting options
- The tool converts the masked value to hexadecimal using BigInt-to-string conversion.
- You can choose uppercase or lowercase hex, minimal hex (no padding) or padded to full bytes, and grouping (underscore between nibble groups) for readability.
- Outputs
- Normalized/padded binary, unsigned decimal, optional signed decimal, hex without prefix, and hex with a 0x prefix.
- Suggested byte width is shown (minimum bytes required to contain the bit width).
- Validation and errors
- The tool throws human-readable errors for empty input, invalid characters, non-integer or out-of-range bit widths, and excessively large bit widths to prevent runaway computation.
Examples
Basic binary to hex
Convert a simple binary string to minimal hexadecimal.
Padded, grouped bytes
Convert binary with explicit 16-bit width and group by bytes using underscores.
Signed two's complement
Interpret binary as signed two's complement with a fixed bit width.
Frequently asked questions
What input formats does the converter accept?
What input formats does the converter accept?
You can paste raw binary digits, binary with a leading 0b or 0B, and binary split with spaces or underscores for readability; the tool strips separators and validates only 0 and 1 remain.
How do I make the converter interpret the value as a signed number?
How do I make the converter interpret the value as a signed number?
Enable the Signed (two's complement) option and set the bit width you want; the tool will convert the masked value to a signed decimal using two's complement rules for that width.
What happens if I leave the bit width empty?
What happens if I leave the bit width empty?
If bit width is empty the converter uses the minimal width required by the provided bits (no extra padding). You can choose to show padded output if you want hex aligned to full bytes.
Can I convert very large binary values?
Can I convert very large binary values?
Yes. The tool uses BigInt and supports inputs up to a safe practical limit (1024 bits) to avoid excessive computation; the UI will reject larger widths with a helpful error.
How does hex grouping work?
How does hex grouping work?
Grouping inserts underscores every N nibbles (nibble = 4 bits). Common presets are 2 (byte grouping), 4 (2-byte groups), and 8 (4-byte groups). Grouped hex keeps leading zero padding when padded output is selected.
Why is the hex output sometimes padded and sometimes minimal?
Why is the hex output sometimes padded and sometimes minimal?
Padded hex aligns the output to the chosen bit width (rounded to full bytes) and is useful for memory dumps and protocol fields. Minimal hex strips leading zero bytes for compact display; toggle between the two with Display options.
Does the converter show both unsigned and signed values?
Does the converter show both unsigned and signed values?
Yes. The tool always shows the unsigned decimal and hex; it shows the signed decimal only when Signed mode is selected.
What validation errors will I see?
What validation errors will I see?
You may see errors for empty input, invalid characters (anything other than 0,1 after stripping separators), non-integer or out-of-range bit widths, and bit widths smaller than the input length; each error explains how to fix the input.
Can I copy the outputs or export results?
Can I copy the outputs or export results?
Every output panel includes a Copy button; the tool also provides a Copy Summary action to quickly copy hex and decimal representations ready for paste elsewhere.
Is two's complement interpretation reversible?
Is two's complement interpretation reversible?
Two's complement decoding is reversible when you know the exact bit width used to encode the value; without the correct width, the signed interpretation may be incorrect. Always set the bit width when working with signed values.
Related tools
More utilities you might find handy.
Base64 Encoder / Decoder for Text, Images & Docs
Instantly convert plain text, images, PDFs, and documents to Base64 strings or decode Base64 data arrays back into downloadable file assets.
Camel, Snake, Kebab Case Converter
Effortlessly convert text between camelCase, snake_case, kebab-case, PascalCase, and more for developers and writers.
CSV to JSON Converter
Convert CSV to JSON instantly in your browser – auto-detect delimiters, handle quotes and line breaks, create nested objects, and export clean JSON with zero uploads.