FormulaCraft

DEC2HEX

DEC2HEX converts a decimal number into a hexadecimal string. You can optionally specify the number of characters to use, padding with leading zeros. Use it when interfacing with systems that require hex addresses, color codes, or binary protocols.

Excel
=DEC2HEX(255,4)
Google Sheets
=DEC2HEX(255,4)

Verified example

Computed by a real spreadsheet engine on the sample data below.

DecimalHex
10=DEC2HEX(10)
255=DEC2HEX(255,4)
4096=DEC2HEX(4096)
65535=DEC2HEX(65535)

=DEC2HEX(255,4)00FF

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

How it works

  1. 1Enter the decimal number you want to convert as the first argument (e.g., 255).
  2. 2Optionally provide a second argument for the minimum number of hex digits, padding with zeros (e.g., 4 yields '00FF').
  3. 3The result is text — use it directly in concatenation or system interfaces expecting hex strings.

Need a version for your data?

Try: “Convert the decimal number 255 to hexadecimal with 4 digits

Related

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: