Hex Calculator

Convert between hexadecimal and decimal values.

Hex Calculator

Formula

hex2dec: parseInt(value, 16); dec2hex: Number(value).toString(16)

In hex to decimal mode it parses a hex string as base 16. In decimal to hex mode it formats a non-negative integer as hexadecimal.

This hex calculator converts between hexadecimal and decimal. Default mode is hex to decimal with value FF, which equals 255. Switch modes when you need the reverse direction.

Developers and students use it while reading color codes, memory dumps, and bit masks. For binary string work on the same theme, [INTERNAL LINK NEEDED: binary calculator]. For percent math beside coding homework, use the percentage calculator.

How the formula works

Hex to decimal parses the string in base 16. Decimal to hex formats a non-negative integer in base 16. Digits above 9 use letters A through F.

Worked example

FF hex means 15×16 + 15 = 255 decimal.

InputValue
ModeHex to decimal
ValueFF
Result255

How to use the fields

  • Value is the hex string or decimal number depending on mode.
  • Convert chooses hex to decimal or decimal to hex.

Place values

Each hex digit is a power of 16. Two digit values like FF sit in the 0 to 255 range common in byte sized RGB channels.

Common mistakes

  • Leaving mode on hex to decimal while typing a decimal like 255 without letters
  • Using letters beyond F
  • Expecting signed two’s complement formatting from this simple converter
  • Forgetting that 10 hex is 16 decimal, not ten

Color codes

Web colors often appear as six hex digits. Converting one channel such as FF helps you see the 0 to 255 intensity before you edit CSS by hand.

Classroom practice

Convert FF to 255, then convert 255 back to hex and confirm FF. Round trips catch mode mistakes immediately.

Ask what 10 hex equals in decimal. Students who answer 10 are mixing bases; the correct decimal value is 16.

Debugging habit

When a dump shows 0xFF, write 255 beside it in notes so magnitude is obvious during reviews.

Bytes and words

Two hex digits make one byte in the 00 to FF range. Four hex digits often represent 16 bit values. Knowing those widths helps when a dump pads with leading zeros.

This converter returns the numeric value without forcing a fixed width display.

Case and prefixes

Languages may show 0xFF or hFF style prefixes. Strip prefixes before entry if the field expects bare hex digits.

Uppercase and lowercase letters are equal in value. Pick one style for team docs and stay consistent.

Mental math shortcuts

F hex is 15. A hex is 10. Memorizing A through F speeds reading without the calculator. Still verify critical addresses with the tool.

Powers of two often land on round hex boundaries, which is why memory sizes look tidy in hex dumps.

ASCII and character codes

Some lessons connect byte values to characters. Hex 41 is decimal 65, a common example for uppercase A in ASCII. Convert with the tool, then look up the character table separately.

Not every byte is a printable character. Use conversion for the number first, then interpret meaning in context.

When a protocol doc writes multi byte fields, convert each byte or the whole width as the doc specifies. Mixing those approaches creates off by byte errors.

Endianness reminder

Multi byte hex values may be written with the most significant byte first or last depending on the system. Conversion of a single value like FF is unaffected, but longer strings need an endianness rule from the spec you are reading.

When unsure, convert byte by byte in the order the protocol diagram shows.

Document the endianness beside any converted address so the next reader does not reverse the bytes again.

Nibble view

Each hex digit is a nibble of four bits. FF is two nibbles making eight bits. Thinking in nibbles makes binary translation faster when you need it.

You can convert FF to binary 11111111 by expanding each F as 1111, which reinforces why hex shorthand exists.

Limitations

No bitwise operators, no floating hex formats, and no automatic bit width padding beyond what you type.

Frequently Asked Questions

What does the default example show?

Hex value FF in hex-to-decimal mode equals 255.

Which characters are valid in hex?

Digits 0-9 and letters A-F in either case.

How do I convert decimal to hex?

Switch mode to decimal to hex and enter a non-negative whole number in the value field.

Does it do hex addition?

Not as a separate adder. Convert, compute in decimal if needed, then convert back.

Is FF the same as ff?

Yes. Letter case does not change the value.

What about negative decimals?

This converter path expects non-negative integers for decimal to hex.

Leading zeros?

They do not change the numeric value, though bit width displays in hardware docs may keep them for alignment.

Why learn hex?

Computing, colors, and memory addresses often use base 16 shorthand for binary groups.