Binary to Hexadecimal Calculator

Binary ↔ Hexadecimal Converter

Binary to Hexadecimal Calculator: A simple tool to convert numbers between binary (base-2) and hexadecimal (base-16). Enter a value and see the conversion instantly.

Result Copied!

Why Use Binary and Hexadecimal?

Base Systems Explained

Binary (Base-2): This is the native language of all digital computers. It uses only two digits, 0 and 1, to represent “off” and “on” states in a circuit.

Hexadecimal (Base-16): This system uses 16 digits: 0-9 and A-F (where A=10, B=11, C=12, D=13, E=14, F=15). Humans use hex because it’s a fantastic **shorthand for binary**.

A long binary string like 1011000101011110 is unreadable. But in hex, it’s just B15E. They both represent the exact same number!

How The Conversion Works

The 4-to-1 Grouping Method

The magic link is that one hexadecimal digit represents exactly four binary digits (bits). The largest 4-bit number is 1111, which equals 15 (or F in hex).

Binary to Hexadecimal

To convert from binary to hex, you group the binary string into sets of 4, starting from the right. If the last group isn’t full, add leading zeros. Then, convert each group.

Example: 101100010101

  1. Group: 1011 | 0001 | 0101
  2. Convert: 1011 = 11 = B
  3. Convert: 0001 = 1 = 1
  4. Convert: 0101 = 5 = 5

Result: B15

Hexadecimal to Binary

This is even easier. Just convert each hex digit into its 4-bit binary equivalent.

Example: B15

  • B (11) = 1011
  • 1 (1) = 0001
  • 5 (5) = 0101

Result: 101100010101

Quick Lookup Table

HexBinaryDecimalHexBinaryDecimal
000000810008
100011910019
200102A101010
300113B101111
401004C110012
501015D110113
601106E111014
701117F111115

Binary to Hexadecimal Converter: Convert Base 2 and Base 16 Numbers

Binary to Hexadecimal Calculator Web App.
Binary to Hexadecimal Calculator Web App.

A binary to hexadecimal converter changes a numerical representation from base 2 to base 16, or from base 16 back to base 2, without changing the underlying numerical value. Binary uses only 0 and 1, while hexadecimal uses sixteen symbols: 0–9 and A–F.

The relationship between these two systems is especially useful in computing because one hexadecimal digit corresponds exactly to four binary bits. This makes hexadecimal a compact way to write long binary values while preserving the information represented by the individual bits. NIST provides the same four-bit relationship in its technical glossary and gives byte-level examples of hexadecimal notation.

This converter allows you to select the source base and destination base, enter a value, and obtain the equivalent representation. It supports both directions: binary → hexadecimal and hexadecimal → binary. The calculator also displays the decimal value as a reference and uses arbitrary-precision integer arithmetic through JavaScript’s BigInt for the actual conversion process.

What Is Binary?

Binary is a positional number system with base 2. It contains only two digits:

0 and 1

Each position in a binary number represents a power of 2. Beginning at the rightmost position, the place values are:

Binary positionPowerDecimal value
1st from right201
2nd212
3rd224
4th238
5th2416
6th2532

A binary number such as 101101 therefore means:

1 × 25 + 0 × 24 + 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20

= 32 + 0 + 8 + 4 + 0 + 1 = 45

So:

1011012 = 4510

A bit is one binary digit. NIST defines a bit as a binary digit with a value of 0 or 1.

What Is Hexadecimal?

Hexadecimal, often abbreviated as hex, is a positional number system with base 16. Since ordinary decimal digits provide only ten symbols, hexadecimal extends the digit set with six letters:

Hexadecimal symbolDecimal value
00
11
22
33
44
55
66
77
88
99
A10
B11
C12
D13
E14
F15

Thus, hexadecimal A represents decimal 10, B represents 11, and F represents 15. This is not a different set of numerical values. It is simply another positional notation for the same numbers.

The next hexadecimal place represents 161, the next represents 162, and so on. For example:

2F16 = 2 × 161 + 15 × 160

= 32 + 15 = 4710

Why Binary and Hexadecimal Are Closely Related

The mathematical connection between binary and hexadecimal is exact because:

16 = 24

That means each hexadecimal digit contains the same amount of positional information as four binary digits.

For example:

F16 = 1510 = 11112

and:

C16 = 1210 = 11002

NIST explicitly describes hexadecimal byte notation in terms of four-bit groups, giving examples such as 0xC6 = 11000110.

This relationship is why conversion between the two bases can be performed directly without calculating a decimal intermediate value by hand.

How the Binary ↔ Hexadecimal Converter Works

The calculator follows a simple base-conversion process.

  1. Validate the input. Binary input must contain only 0 and 1. Hexadecimal input may contain 0–9 and A–F, in either uppercase or lowercase.
  2. Interpret the input as an integer. The implementation uses BigInt with an explicit binary or hexadecimal prefix.
  3. Convert to the requested target base. Binary output is generated with base 2 and hexadecimal output with base 16.
  4. Display the result. The tool shows the original value and its equivalent representation in the selected target base.

The calculator also updates a decimal helper while the user types a valid value. That decimal figure is a reference representation of the same integer and does not change the binary or hexadecimal value itself.

Binary to Hexadecimal Conversion

Binary-to-hex conversion is usually the fastest base conversion to perform manually because it requires only grouping.

Step 1: Start at the right-hand side of the binary number.

Step 2: Divide the binary digits into groups of four.

Step 3: If the leftmost group contains fewer than four digits, add leading zeros.

Step 4: Replace each four-bit group with its corresponding hexadecimal digit.

For example:

1011000101012

Group into four bits:

1011 | 0001 | 0101

Convert each group:

Binary groupDecimal valueHex digit
101111B
000111
010155

Therefore:

1011000101012 = B1516

No decimal calculation is necessary once the four-bit lookup is understood.

Why Four Binary Bits Equal One Hexadecimal Digit

A group of four binary bits can represent:

24 = 16

different patterns.

Those 16 patterns correspond exactly to the 16 hexadecimal symbols from 0 through F.

BinaryDecimalHex
000000
000111
001022
001133
010044
010155
011066
011177
100088
100199
101010A
101111B
110012C
110113D
111014E
111115F

The table is the fundamental lookup map behind manual binary-to-hexadecimal conversion.

Hexadecimal to Binary Conversion

Hexadecimal-to-binary conversion works in the opposite direction. Replace every hexadecimal digit with its four-bit equivalent.

For example:

B1516

becomes:

B → 1011

1 → 0001

5 → 0101

Therefore:

B1516 = 1011000101012

This direct mapping works because the binary and hexadecimal place values are aligned in groups of four.

Converting Through Decimal

It is also possible to convert between binary and hexadecimal by using decimal as an intermediate representation:

Binary → Decimal → Hexadecimal

or:

Hexadecimal → Decimal → Binary

This approach is mathematically valid, but for ordinary integers it is often less efficient than the direct four-bit method.

For example:

10102 = 1010 = A16

However, the direct method immediately recognizes:

10102 → A16

without requiring the decimal step.

Understanding Hexadecimal Place Values

Hexadecimal is a positional system just like decimal and binary. Each position represents a power of 16.

PositionPower of 16Decimal value
Rightmost1601
Next16116
Next162256
Next1634,096
Next16465,536

For example:

3A716 = 3 × 162 + 10 × 161 + 7 × 160

= 3 × 256 + 10 × 16 + 7

= 768 + 160 + 7 = 935

Therefore:

3A716 = 93510

Why Hexadecimal Is Used in Computing

Long binary strings are accurate but visually cumbersome. Hexadecimal provides a shorter representation while preserving a direct relationship with individual groups of bits.

Consider:

1011000101011110

Grouping the bits gives:

1011 | 0001 | 0101 | 1110

which becomes:

B15E

Both strings represent exactly the same numerical value, but the hexadecimal form uses only four characters instead of sixteen binary digits.

This compact notation is useful when inspecting low-level data, memory values, protocol fields, machine representations, bit patterns, and hexadecimal dumps. NIST standards routinely use hexadecimal notation to describe bit strings and bytes, while IETF standards also specify binary and hexadecimal representations in technical formats.

Hexadecimal and Bytes

Eight bits form a byte, and two hexadecimal digits can represent exactly one byte because:

2 hexadecimal digits × 4 bits per hexadecimal digit = 8 bits

For example:

C616 = 110001102

The first hexadecimal digit, C, represents:

1100

The second hexadecimal digit, 6, represents:

0110

Combining the two groups gives:

1100 0110

NIST gives this exact relationship in its definition of hexadecimal byte notation.

Binary, Hexadecimal, and Decimal Compared

PropertyBinaryDecimalHexadecimal
Base21016
Digits0–10–90–9 and A–F
Four binary bits correspond toOne groupNot directly alignedOne digit
Primary advantageDirect bit representationFamiliar to most peopleCompact representation of binary
Common computing useBit-level representationHuman-facing numerical valuesCompact machine-oriented notation

These systems do not represent different quantities merely because the written symbols differ. They are different notational systems for representing numerical values.

Leading Zeros in Binary and Hexadecimal

Leading zeros do not change the numerical value of an ordinary unsigned integer.

For example:

000010102 = 10102

and:

0A16 = A16

Both forms represent 10.

However, leading zeros can become significant when communicating a fixed-width representation. For example, eight bits are conventionally written as eight positions, so the value 10 may appear as:

00001010

rather than simply:

1010

Similarly, a byte is often represented by exactly two hexadecimal digits.

Input Rules for This Converter

The current implementation imposes clear character restrictions.

Source formatAccepted charactersExamples
Binary0 and 1101101, 0001
Hexadecimal0–9 and A–F, case-insensitiveB15E, a7f

The source code validates binary with ^[01]+$ and hexadecimal with ^[0-9A-Fa-f]+$.

Therefore, values containing spaces, punctuation, decimal points, signs, or hexadecimal prefixes such as 0x are not accepted by the current input validator. This is an important distinction because technical programming notation often uses prefixes such as 0x for hexadecimal or 0b for binary, while this particular interface expects the digits themselves.

Does This Converter Support Negative Numbers?

The current tool is designed for unsigned, non-negative integer representations. Its validation rules permit only binary digits or hexadecimal digits and do not accept a minus sign.

This matters because negative values in computing require a representation convention, such as two’s complement with a specified bit width. A string such as 11111111 can represent 255 as an unsigned 8-bit integer or −1 as an 8-bit two’s-complement integer. The bit pattern alone is insufficient unless the interpretation has been specified.

Because this converter does not ask for signedness or bit width, its results should be understood as ordinary non-negative integer conversions rather than signed-integer interpretation.

Does the Converter Preserve Leading Zeros?

For numerical conversion, the implementation converts the parsed integer back to its target base with BigInt.prototype.toString(). As a result, the output is a canonical numerical representation rather than a fixed-width representation containing all original padding zeros.

For example, an input such as:

000010102

can convert to:

A16

rather than necessarily preserving the two-digit byte form 0A.

This is mathematically correct because both forms represent the same integer, but it is important when a user needs formatting that communicates a fixed number of bits or bytes.

Why This Calculator Uses BigInt

The converter’s implementation uses JavaScript’s BigInt rather than ordinary floating-point Number values for the core integer conversion.

This is a significant implementation choice because hexadecimal and binary strings can become very long. An arbitrary-precision integer type can represent integers beyond the safe-integer limitations that apply to JavaScript’s ordinary Number type.

Using BigInt also allows the converter to convert directly between binary and hexadecimal without first reducing the value to a floating-point decimal approximation.

The interface nevertheless displays a decimal helper value as well. That decimal value is generated from the same BigInt representation, ensuring that the displayed integer is not dependent on ordinary floating-point rounding for the conversion itself.

Example: Binary to Hexadecimal

Convert:

1101011011112

Group the bits:

1101 | 0110 | 1111

Look up each group:

BinaryDecimalHex
110113D
011066
111115F

Therefore:

1101011011112 = D6F16

As an additional check:

13 × 162 + 6 × 16 + 15 = 3328 + 96 + 15 = 3439

and:

1101011011112 = 343910

Example: Hexadecimal to Binary

Convert:

7C216

Replace every hex digit individually:

7 → 0111

C → 1100

2 → 0010

Therefore:

7C216 = 0111110000102

If leading zeros are unnecessary, the same integer can also be written as:

111110000102

The fixed four-bit grouping is usually preferable when the purpose is to inspect the exact relationship between each hexadecimal digit and its corresponding bits.

Example: Converting a Byte

Suppose a byte has the hexadecimal value:

AF

Convert the first digit:

A = 1010

Convert the second digit:

F = 1111

Therefore:

AF16 = 101011112

The reverse is equally direct:

1010 1111 → A F

So:

101011112 = AF16

This two-digit hexadecimal representation is particularly convenient for byte-oriented data because every pair of hex digits corresponds to exactly eight bits. NIST documents the same byte-to-hex relationship in its cryptographic terminology.

Common Uses of Binary and Hexadecimal Conversion

Programming: Developers use binary and hexadecimal when examining integer representations, bit masks, flags, low-level data structures, and machine-oriented values.

Networking: Protocol specifications and diagnostic tools frequently represent binary data in hexadecimal because it is more compact than a raw bit string.

Debugging: Hexadecimal can make memory dumps and binary payloads easier to read while retaining direct access to groups of four bits.

Cryptography: Cryptographic standards frequently display byte strings and bit-oriented values in hexadecimal notation.

Digital electronics: Binary expresses individual digital states, while hexadecimal can summarize longer bit patterns in a more compact form.

Computer architecture: Addresses, registers, instruction fields, and machine data are commonly displayed using hexadecimal notation.

Education: Conversion exercises help students understand positional notation, powers of two, bit grouping, bytes, and numerical representations.

Binary vs. Hexadecimal for Human Readability

RepresentationExampleNumber of characters for 16 bitsReadability for bit inspection
Binary101100010101111016Excellent for individual bits
HexadecimalB15E4Excellent for compact bit-group representation

Neither representation is inherently more correct. The best notation depends on what needs to be communicated. Binary is ideal when individual bits matter. Hexadecimal is often more convenient when the same information needs to be displayed compactly.

Common Conversion Mistakes

  • Grouping from the wrong side: Binary-to-hexadecimal grouping should begin at the rightmost end.
  • Forgetting leading zeros: An incomplete leftmost four-bit group must be padded with zeros when performing direct grouping.
  • Confusing hexadecimal letters with decimal values: A hexadecimal A means 10, not the letter’s alphabetic position.
  • Mixing bases: 10 has different values in binary, decimal, and hexadecimal.
  • Dropping meaningful fixed-width information: Leading zeros do not change the integer but may matter when representing a byte or word.
  • Assuming a bit string has an inherent signed meaning: Signed interpretation requires a defined representation and width.
  • Entering prefixes not accepted by the tool: This calculator expects the raw binary or hexadecimal digits rather than 0b or 0x prefixes.

Binary and Hexadecimal Prefixes

In programming and technical documentation, prefixes are often used to signal a number’s base. For example:

0b1010 can indicate a binary literal.

0xA can indicate a hexadecimal literal.

IETF specifications use notations such as 0b for binary and 0x for hexadecimal in relevant technical contexts.

However, the current converter deliberately does not accept those prefixes as part of its user-entered value. The validator expects only the digits belonging to the selected base.

What the Swap Button Does

The Swap Units control exchanges the selected source and destination bases. For example, if the interface is set to convert binary to hexadecimal, selecting Swap changes the direction to hexadecimal to binary.

The value itself is not automatically recalculated until a new conversion is performed. This keeps the control focused on changing conversion direction rather than silently changing the currently displayed result.

Why the Converter Requires Different Source and Target Bases

The calculator rejects a configuration in which the selected source and target units are identical. Converting binary to binary or hexadecimal to hexadecimal would not provide a meaningful base conversion, so the implementation requests two different units.

What This Converter Does Not Do

The tool is a number-representation converter, not a general binary-data decoder.

It does not automatically determine whether a hexadecimal value represents:

  • An unsigned integer
  • A signed integer
  • A character encoding
  • A memory address
  • A color value
  • A cryptographic key or digest
  • A serialized data structure
  • A processor instruction

The same hexadecimal digits can have different meanings depending on their application and encoding. Conversion changes notation; it does not interpret the semantic meaning of the resulting data.

Numerical Representation vs. Data Interpretation

This distinction is essential in technical work.

Suppose the hexadecimal value is:

4116

Numerically, it is:

6510

In ASCII, the byte value 65 is associated with the character A. But the converter itself does not perform ASCII decoding. It simply establishes the numerical equivalence:

4116 = 010000012 = 6510

Interpreting that number as a character is a separate task.

Accuracy and Large Values

The converter uses BigInt for the conversion path, which is particularly appropriate for large integer strings.

This allows the tool to preserve integer precision without relying on JavaScript’s floating-point Number type for the primary conversion operation.

The implementation still protects against conversion failures with an error message rather than returning a potentially misleading result.

Frequently Asked Questions

What is a binary to hexadecimal converter?

It is a tool that changes a number written in base 2 into an equivalent representation in base 16, or performs the reverse conversion without changing the underlying integer.

How many binary bits are represented by one hexadecimal digit?

One hexadecimal digit represents exactly four binary bits because 16 = 24. NIST documents this relationship explicitly.

How do I convert binary to hexadecimal manually?

Group the binary digits into groups of four from right to left, pad the leftmost group with zeros if needed, and replace each group with its corresponding hexadecimal digit.

How do I convert hexadecimal to binary?

Replace each hexadecimal digit with its four-bit binary equivalent.

What does A mean in hexadecimal?

A represents decimal 10.

What does F mean in hexadecimal?

F represents decimal 15.

Why is hexadecimal useful in computing?

It provides a compact representation of binary data. Four binary bits can be summarized with one hexadecimal digit, reducing the number of written characters by a factor of four for long bit strings. NIST and IETF technical specifications use hexadecimal extensively for bit-oriented and byte-oriented data.

Does this calculator support uppercase and lowercase hexadecimal?

Yes. The hexadecimal validator accepts both uppercase and lowercase letters A through F. The generated hexadecimal result is converted to uppercase.

Does the calculator accept 0x prefixes?

No. The current interface expects only the hexadecimal digits themselves. An input such as FF is valid, while 0xFF is not accepted by the validator.

Does it support binary prefixes such as 0b?

No. Enter the binary digits directly, such as 101011, rather than 0b101011.

Does the converter preserve leading zeros?

Not necessarily. The target value is generated from the integer representation, so the output is a canonical numerical representation rather than a fixed-width bit string.

Can this converter interpret signed two’s-complement numbers?

No. The tool does not request a signedness convention or a fixed bit width. It should therefore be used for ordinary non-negative integer conversion rather than signed interpretation.

Can hexadecimal be used to represent bytes?

Yes. Two hexadecimal digits correspond to eight binary bits, making two-digit hexadecimal a convenient byte representation. NIST provides examples of this exact relationship.

Does binary-to-hexadecimal conversion change the number?

No. A correct conversion changes only the notation. For example, 11112, 1510, and F16 all represent the same integer.

Quick Binary-to-Hexadecimal Reference

BinaryHexDecimal
000000
000111
001022
001133
010044
010155
011066
011177
100088
100199
1010A10
1011B11
1100C12
1101D13
1110E14
1111F15

Key Takeaways

  • Binary is base 2 and uses only 0 and 1.
  • Hexadecimal is base 16 and uses 0–9 plus A–F.
  • One hexadecimal digit corresponds to four binary bits.
  • Binary-to-hexadecimal conversion is usually performed by grouping binary digits into fours.
  • Hexadecimal-to-binary conversion is performed by replacing each hex digit with its four-bit equivalent.
  • Two hexadecimal digits correspond to one byte because each hexadecimal digit represents four bits.
  • The calculator accepts raw binary or hexadecimal digits and does not accept 0b or 0x prefixes.
  • The converter uses BigInt for integer conversion, making it suitable for very large integer representations within the practical limits of the environment.
  • Conversion changes the notation, not the underlying numerical value.
  • Interpreting a bit pattern as signed data, text, a color, an address, or another data type requires additional context that this converter does not provide.

Authoritative Technical References

National Institute of Standards and Technology (NIST), Computer Security Resource Center Glossary — “bit.” NIST defines a bit as a binary digit with a value of 0 or 1.

NIST CSRC Glossary — “0xab.” NIST explains hexadecimal notation for bytes and explicitly describes each hexadecimal character as representing four bits, with the example 0xc6 = 11000110.

NIST CSRC Glossary — “0x0X.” NIST provides an 8-bit binary representation example for hexadecimal values, reinforcing the relationship between hexadecimal notation and binary bit strings.

IETF RFC 8610, Concise Data Definition Language. This standards-track RFC discusses binary, hexadecimal, and decimal notation and provides equivalent representations of the same numerical values.

IETF RFC 8949, Concise Binary Object Representation. This RFC uses both 0x hexadecimal and 0b binary notation when describing technical data representations.

Found this calculator useful? Share it.
Scroll to Top