Tool Point

    Decimal to Hex Converter

    Convert decimal numbers (base-10) to hexadecimal numbers (base-16)

    Decimal to Hexadecimal Converter

    Enter a decimal number to convert it to hexadecimal

    Hexadecimal Digit Values

    0 = 0
    1 = 1
    2 = 2
    3 = 3
    4 = 4
    5 = 5
    6 = 6
    7 = 7
    8 = 8
    9 = 9
    A = 10
    B = 11
    C = 12
    D = 13
    E = 14
    F = 15

    Category Essentials

    Number tools often serve connected search intents like conversion, formatting, and basic math references. These featured pages help users move between the main number tasks more naturally.

    Daily Inspiration

    The pen is mightier than the sword. - Edward Bulwer-Lytton

    Decimal to Hex Converter - Base 10 to Base 16

    Convert decimal numbers to hexadecimal instantly

    Transform decimal (base 10) numbers to hexadecimal (base 16) format with our free online converter. Perfect for programmers, students, and anyone working with computer systems, memory addresses, or color codes. Get accurate results instantly with optional step-by-step explanations showing the division-by-16 method.

    Convert Decimal to Hex (Tool)

    Use our instant decimal to hex converter to transform any decimal number into its hexadecimal equivalent.

    How to Use

    • Accepts positive integers (e.g., 255, 4095, 65535)
    • Whole numbers only (no decimals or fractions)
    1. Click "Convert" to process
    • Instant conversion to hexadecimal
    • Results appear immediately
    1. View your hexadecimal result
    • Output displayed in standard hex format
    • Copy the result for use in your projects

    Example Conversions

    Decimal (Base 10)Hexadecimal (Base 16)
    10A
    15F
    1610
    255FF
    256100
    4095FFF
    65535FFFF

    What Is Hexadecimal?

    Hexadecimal (often abbreviated as "hex") is a base-16 numbering system that uses sixteen distinct symbols to represent values. Unlike the decimal system (base 10) that uses digits 0-9, hexadecimal extends the range with letters A-F.

    The Hexadecimal Digit System

    Hexadecimal uses 16 symbols:

    • Digits 0-9: Represent values 0 through 9 (same as decimal)
    • Letters A-F: Represent values 10 through 15

    Hexadecimal Digit Reference:

    HexDecimalBinary
    000000
    110001
    220010
    330011
    440100
    550101
    660110
    770111
    881000
    991001
    A101010
    B111011
    C121100
    D131101
    E141110
    F151111

    Why Use Hexadecimal in Computing?

    Hexadecimal is fundamental in computer science and programming for several reasons:

    1. Compact binary representation

    • One hex digit represents exactly 4 bits (a nibble)
    • Two hex digits represent exactly 8 bits (one byte)
    • Makes binary data much easier to read and write

    Example: The binary number 11111111 (8 bits) becomes simply FF in hex

    2. Memory addresses

    • Computer memory addresses are typically displayed in hexadecimal
    • Easier to work with than long binary strings
    • Example: 0x7FFF8000 is more readable than 0111111111111111100000000000000

    3. Color codes

    • RGB colors use hex notation
    • Each color channel (Red, Green, Blue) uses 2 hex digits (0-255)
    • Example: #FF5733 represents RGB(255, 87, 51)

    4. Byte values

    • Each byte (8 bits) ranges from 00 to FF in hex (0 to 255 in decimal)
    • Perfect alignment with computer architecture

    5. Programming and debugging

    • Machine code and assembly language use hex
    • Debugging tools display memory in hex
    • Easy conversion between hex and binary

    Understanding Positional Notation

    Like decimal, hexadecimal uses positional notation based on powers of 16:

    Example: Hex number 2A3F

    • Position 0 (rightmost): F x 160 = 15 x 1 = 15
    • Position 1: 3 x 161 = 3 x 16 = 48
    • Position 2: A x 162 = 10 x 256 = 2,560
    • Position 3: 2 x 163 = 2 x 4,096 = 8,192
    • Total: 8,192 + 2,560 + 48 + 15 = 10,815 (decimal)

    The 0x Prefix Convention

    In programming, hexadecimal numbers are often prefixed with 0x to distinguish them from decimal:

    • 0x10 = 16 in decimal (hex)
    • 10 = 10 in decimal

    This prefix is standard in:

    • C, C++, Java, JavaScript, Python
    • Assembly language
    • Memory dumps and debugger output

    Example in code:

    int value = 0xFF;  // 255 in decimal

    How to Convert Decimal to Hex (Step-by-Step)

    Converting from decimal to hexadecimal uses the division-by-16 method with remainders.

    The Division-by-16 Algorithm

    Steps:

    1. Divide the decimal number by 16
    2. Record the remainder (this will be a hex digit)
    3. Use the quotient for the next division
    4. Repeat until the quotient is 0
    5. Read the remainders in reverse order (bottom to top)

    Remainder to Hex Digit Conversion:

    • Remainders 0-9 -> Use digits 0-9
    • Remainder 10 -> A
    • Remainder 11 -> B
    • Remainder 12 -> C
    • Remainder 13 -> D
    • Remainder 14 -> E
    • Remainder 15 -> F

    Example 1: Convert 255 to Hex

    DivisionQuotientRemainderHex Digit
    255 / 161515F
    15 / 16015F

    Reading bottom to top: FF

    Answer: 25510 = FF16

    Verification:

    • F x 161 = 15 x 16 = 240
    • F x 160 = 15 x 1 = 15
    • Total: 240 + 15 = 255

    Example 2: Convert 7562 to Hex

    DivisionQuotientRemainderHex Digit
    7562 / 1647210A
    472 / 162988
    29 / 16113D
    1 / 16011

    Reading bottom to top: 1D8A

    Answer: 756210 = 1D8A16

    Verification:

    • 1 x 163 = 1 x 4,096 = 4,096
    • D x 162 = 13 x 256 = 3,328
    • 8 x 161 = 8 x 16 = 128
    • A x 160 = 10 x 1 = 10
    • Total: 4,096 + 3,328 + 128 + 10 = 7,562

    Example 3: Convert 4095 to Hex

    DivisionQuotientRemainderHex Digit
    4095 / 1625515F
    255 / 161515F
    15 / 16015F

    Reading bottom to top: FFF

    Answer: 409510 = FFF16

    This represents the maximum value that can be stored in 12 bits (three hex digits).

    Quick Mental Conversion Tips

    For small numbers (0-15): Simply use the hex digit reference table above.

    For multiples of 16:

    • 16 = 1016
    • 32 = 2016
    • 48 = 3016
    • 256 = 10016

    For powers of 2:

    • 2 = 2
    • 4 = 4
    • 8 = 8
    • 16 = 10
    • 32 = 20
    • 64 = 40
    • 128 = 80
    • 256 = 100

    Decimal Hex Quick Reference Table

    Common Decimal to Hexadecimal Conversions

    Small numbers (0-32):

    DecHexDecHexDecHexDecHex
    00991812271B
    1110A1913281C
    2211B2014291D
    3312C2115301E
    4413D2216311F
    5514E23173220
    6615F2418
    7716102519
    881711261A

    Important milestones:

    DecimalHexadecimalSignificance
    15FMax single hex digit
    1610First two-digit hex
    311FMax 5-bit value
    3220Common byte boundary
    633FMax 6-bit value
    1277FMax signed 8-bit
    12880Mid 8-bit value
    255FFMax 8-bit (1 byte)
    256100First three-digit hex
    5111FFMax 9-bit value
    10233FFMax 10-bit value
    20477FFMax 11-bit value
    4095FFFMax 12-bit value
    81911FFFMax 13-bit value
    163833FFFMax 14-bit value
    327677FFFMax signed 16-bit
    65535FFFFMax 16-bit (2 bytes)

    Powers of 16:

    DecimalHexadecimalPower
    1610161
    256100162
    4,0961000163
    65,53610000164
    1,048,576100000165
    16,777,2161000000166

    Common Use Cases

    The decimal to hexadecimal converter is essential across various computing and programming scenarios.

    1. Programming and Software Development

    Memory addresses: Developers use hex to represent memory locations and pointers.

    int *ptr = (int *)0x7FFEE4B3C8A0;  // Memory address in hex

    Bit flags and masks: Hexadecimal makes it easy to work with specific bits.

    const READ = 0x04;    // Binary: 0100 (decimal 4)
    const WRITE = 0x02;   // Binary: 0010 (decimal 2)
    const EXECUTE = 0x01; // Binary: 0001 (decimal 1)

    Constants and configuration:

    MAX_VALUE = 0xFFFF  # 65535 in decimal
    BUFFER_SIZE = 0x400  # 1024 in decimal

    2. Color Codes (RGB)

    Web colors use hexadecimal for RGB values:

    Each color channel (Red, Green, Blue) ranges from 0-255 (00-FF in hex):

    Example: #FF5733

    • Red: FF (255)
    • Green: 57 (87)
    • Blue: 33 (51)

    Common color conversions:

    • White: RGB(255, 255, 255) = #FFFFFF
    • Black: RGB(0, 0, 0) = #000000
    • Red: RGB(255, 0, 0) = #FF0000
    • Green: RGB(0, 255, 0) = #00FF00
    • Blue: RGB(0, 0, 255) = #0000FF

    3. Debugging and Logging

    Error codes: System and application errors are often represented in hexadecimal.

    Error 0x80070005: Access Denied
    Kernel Panic at address 0xC0000005

    Memory dumps: Debugging tools display memory contents in hex format for readability.

    0x00400000: 4D 5A 90 00 03 00 00 00
    0x00400008: 04 00 00 00 FF FF 00 00

    4. Network and Hardware

    MAC addresses:

    00:1A:2B:3C:4D:5E

    IPv6 addresses:

    2001:0db8:85a3:0000:0000:8a2e:0370:7334

    Port numbers:

    • HTTP: 80 (0x50)
    • HTTPS: 443 (0x1BB)
    • SSH: 22 (0x16)

    5. Data Representation

    File signatures (magic numbers):

    • PNG: 89 50 4E 47 (hex)
    • JPEG: FF D8 FF E0
    • PDF: 25 50 44 46

    Character encoding:

    • ASCII 'A': 65 (0x41)
    • Unicode emoji : U+1F600

    6. Embedded Systems and IoT

    Register values: Microcontroller programming uses hex for hardware registers.

    PORTA = 0xFF;  // Set all pins high (255)
    DDRB = 0x0F;   // Configure lower 4 bits as output (15)

    Sensor data: Raw sensor values are often read in hexadecimal format.

    Developer Examples

    Programming languages provide built-in functions for convert decimal to hexadecimal operations.

    JavaScript

    Using toString() with radix 16:

    // Basic conversion
    let decimal = 255;
    let hex = decimal.toString(16);
    console.log(hex);  // Output: "ff"
    
    // Uppercase
    let hexUpper = decimal.toString(16).toUpperCase();
    console.log(hexUpper);  // Output: "FF"
    
    // With 0x prefix
    let hexPrefixed = "0x" + decimal.toString(16).toUpperCase();
    console.log(hexPrefixed);  // Output: "0x FF"
    
    // Multiple examples
    console.log((10).toString(16));     // "a"
    console.log((255).toString(16));    // "ff"
    console.log((4095).toString(16));   // "fff"
    console.log((65535).toString(16));  // "ffff"

    Important notes:

    • The radix parameter can be 2-36
    • Negative numbers keep the minus sign: (-255).toString(16) = "-ff"
    • For very large numbers, consider precision limits (see MAX_SAFE_INTEGER)

    Padding with zeros:

    function toHex(num, width) {
      return num.toString(16).toUpperCase().padStart(width, '0');
    }
    
    console.log(toHex(15, 2));    // "0F"
    console.log(toHex(255, 4));   // "00FF"
    console.log(toHex(4095, 3));  // "FFF"

    Python

    Using hex() function:

    # Basic conversion (includes 0x prefix)
    decimal = 255
    hex_value = hex(decimal)
    print(hex_value)  # Output: "0x ff"
    
    # Remove 0x prefix
    hex_no_prefix = hex(decimal)[2:]
    print(hex_no_prefix)  # Output: "ff"
    
    # Uppercase
    hex_upper = hex(decimal)[2:].upper()
    print(hex_upper)  # Output: "FF"
    
    # Multiple examples
    print(hex(10))    # "0xa"
    print(hex(255))   # "0xff"
    print(hex(4095))  # "0xfff"
    print(hex(65535)) # "0xffff"

    Using format() and f-strings:

    decimal = 255
    
    # Format with different options
    print(f"{decimal:x}")    # "ff" (lowercase, no prefix)
    print(f"{decimal:X}")    # "FF" (uppercase, no prefix)
    print(f"{decimal:#x}")   # "0xff" (lowercase, with prefix)
    print(f"{decimal:#X}")   # "0x FF" (uppercase, with prefix)
    
    # Padding with zeros
    print(f"{decimal:04X}")  # "00FF" (4-digit uppercase)
    print(f"{15:02x}")       # "0f" (2-digit lowercase)
    
    # Using format() method
    print("{:X}".format(decimal))     # "FF"
    print("{:#06X}".format(decimal))  # "0x00FF"

    Legacy % formatting:

    decimal = 255
    
    print("%x" % decimal)   # "ff" (lowercase)
    print("%X" % decimal)   # "FF" (uppercase)
    print("0x%X" % decimal) # "0x FF" (with prefix)
    print("%04X" % decimal) # "00FF" (padded)

    C / C++

    Using printf() format specifiers:

    #include <stdio.h>
    
    int main() {
        int decimal = 255;
        
        // Basic hex output
        printf("%x\n", decimal);    // "ff" (lowercase)
        printf("%X\n", decimal);    // "FF" (uppercase)
        
        // With 0x prefix (# flag)
        printf("%#x\n", decimal);   // "0xff"
        printf("%#X\n", decimal);   // "0x FF"
        
        // Padded with zeros
        printf("%04X\n", decimal);  // "00FF"
        printf("%08X\n", decimal);  // "000000FF"
        
        // Multiple values
        printf("Dec: %d, Hex: %X\n", decimal, decimal);
        // Output: "Dec: 255, Hex: FF"
        
        return 0;
    }

    Format specifiers:

    • %x - Lowercase hexadecimal
    • %X - Uppercase hexadecimal
    • %#x - With 0x prefix (lowercase)
    • %#X - With 0x prefix (uppercase)
    • %04X - Padded to 4 digits with leading zeros

    C++ with iostream:

    #include <iostream>
    #include <iomanip>
    
    int main() {
        int decimal = 255;
        
        // Basic hex output
        std::cout << std::hex << decimal << std::endl;  // "ff"
        
        // Uppercase
        std::cout << std::hex << std::uppercase << decimal << std::endl;  // "FF"
        
        // With 0x prefix
        std::cout << std::showbase << std::hex << decimal << std::endl;  // "0xff"
        
        // Padded
        std::cout << std::setfill('0') << std::setw(4) 
                  << std::hex << std::uppercase << decimal << std::endl;  // "00FF"
        
        return 0;
    }

    Troubleshooting

    Common issues and solutions when converting decimal to hexadecimal.

    "Why is my output lowercase/uppercase?"

    Cause: Different tools and programming languages have different default cases.

    In our converter: Check the output format setting (if available)

    In programming:

    • JavaScript: toString(16) produces lowercase by default
    • Solution: Use .toUpperCase() for uppercase
    • Python: hex() produces lowercase
    • Solution: Use .upper() or format with :X
    • C: %x is lowercase, %X is uppercase
    • Solution: Choose appropriate format specifier

    Standard convention: Either case is valid; hex is case-insensitive (0xFF = 0xff)

    "Why is there (or isn't there) a 0x prefix?"

    What 0x means: The 0x prefix is a notation convention indicating hexadecimal, not part of the number itself.

    When it appears:

    • Python's hex() function includes it automatically
    • C's %#x or %#X format specifier adds it
    • Many programming contexts use it for clarity

    When it doesn't appear:

    • Pure hex converters typically omit it
    • JavaScript's toString(16) doesn't include it
    • HTML color codes don't use it (#FF5733, not #0xFF5733)

    To add/remove it:

    // Add prefix
    let withPrefix = "0x" + num.toString(16);
    
    // Remove prefix (Python)
    let noPrefix = hex(num)[2:];

    "Large numbers look wrong in JavaScript"

    Problem: JavaScript numbers have precision limits.

    MAX_SAFE_INTEGER: JavaScript can only safely represent integers up to 2^53 - 1 (9,007,199,254,740,991)

    // Safe
    console.log((9007199254740991).toString(16));  // "1fffffffffffff"
    
    // Potentially unsafe (loses precision)
    console.log((9007199254740992).toString(16));  // May be inaccurate

    Solution for large numbers: Use BigInt (ES2020+)

    // BigInt conversion
    let bigNum = 123456789012345678901234567890n;
    let hexBig = bigNum.toString(16);
    console.log(hexBig);  // Accurate for arbitrarily large numbers
    
    // Note: BigInt requires 'n' suffix and special handling

    When to worry:

    • Numbers > 9,007,199,254,740,991 in standard JavaScript
    • Financial calculations requiring exact precision
    • Cryptographic operations

    "I need fixed-width hex (like 00FF)"

    Padding with zeros makes hex values align and meet specific format requirements.

    JavaScript:

    let num = 15;
    num.toString(16).toUpperCase().padStart(2, '0');  // "0F"
    num.toString(16).toUpperCase().padStart(4, '0');  // "000F"

    Python:

    f"{15:02X}"  # "0F" (2 digits)
    f"{15:04X}"  # "000F" (4 digits)
    f"{15:08X}"  # "0000000F" (8 digits)

    C:

    printf("%02X", 15);  // "0F"
    printf("%04X", 15);  // "000F"
    printf("%08X", 15);  // "0000000F"

    Use cases:

    • Byte values: Always 2 hex digits (00-FF)
    • 16-bit values: 4 hex digits (0000-FFFF)
    • 32-bit values: 8 hex digits (00000000-FFFFFFFF)
    • Memory addresses: Platform-specific width

    "Can I convert negative numbers?"

    Yes, but understanding is important:

    Signed representation: Most converters simply add a minus sign:

    • Decimal: -255
    • Hex: -FF

    Two's complement (how computers actually store negatives):

    • Used in fixed-width binary representations
    • Requires knowing the bit width (8-bit, 16-bit, 32-bit, etc.)

    Example: -1 in two's complement

    • 8-bit: 0xFF (255 unsigned)
    • 16-bit: 0xFFFF (65535 unsigned)
    • 32-bit: 0xFFFFFFFF (4294967295 unsigned)

    If you need two's complement, specify the bit width and use specialized conversion.

    Frequently Asked Questions (FAQ)

    1. How do you convert decimal to hexadecimal?

    To convert decimal to hex, use the division-by-16 method:

    1. Divide the decimal number by 16
    2. Record the remainder (this becomes a hex digit: 0-9, or A-F for 10-15)
    3. Use the quotient for the next division
    4. Repeat until quotient is 0
    5. Read remainders in reverse order (bottom to top)

    Example: 255 to hex

    • 255 / 16 = 15 remainder 15 (F)
    • 15 / 16 = 0 remainder 15 (F)
    • Result: FF

    Alternatively, use our free online decimal to hex converter for instant results!

    2. Why do you divide by 16 to convert to hex?

    We divide by 16 because hexadecimal is a base-16 system. This method extracts each hexadecimal digit by finding how many times 16 (and powers of 16) fit into the number.

    The math behind it:

    • Each position in hex represents a power of 16 (160, 161, 162, etc.)
    • Division by 16 separates these positional values
    • The remainder tells us what digit belongs in each position

    This is the same principle as dividing by 10 to separate decimal digits, or by 2 for binary.

    3. What do A-F mean in hex?

    In hexadecimal, A through F represent the values 10 through 15 in decimal:

    • A = 10
    • B = 11
    • C = 12
    • D = 13
    • E = 14
    • F = 15

    Why letters? Since hex is base-16, we need 16 unique symbols. We use 0-9 for the first ten values, then letters A-F for the remaining six values. This keeps each "digit" as a single character.

    Case sensitivity: Hexadecimal is case-insensitive. Both uppercase (A-F) and lowercase (a-f) are valid and equivalent.

    4. What does 0x mean?

    The 0x prefix is a notation convention that indicates "this number is in hexadecimal format." It's used primarily in programming and technical contexts to avoid ambiguity.

    Examples:

    • 0xFF = 255 (hexadecimal)
    • FF = could be ambiguous without context
    • 255 = decimal

    Where it's used:

    • C, C++, Java, JavaScript, Python
    • Assembly language
    • Memory addresses and debugging output
    • Technical documentation

    Not part of the number: The 0x is just a prefix for clarity - the actual hex value is what follows (0xFF means hex FF, not "zero times FF").

    5. Why is 255 equal to FF in hex?

    255 is the maximum value that can be represented with 8 bits (one byte), and FF is its hexadecimal equivalent.

    The breakdown:

    • F in hex = 15 in decimal
    • FF in hex = (15 x 16) + 15 = 240 + 15 = 255

    Why it matters:

    • One byte = 8 bits = 2 hex digits
    • Range: 00 to FF (0 to 255 in decimal)
    • Commonly used for:
    • RGB color channels (0-255)
    • Byte values in programming
    • Character codes in ASCII

    6. How many bits are in one hex digit?

    One hexadecimal digit represents exactly 4 bits, also called a nibble.

    The relationship:

    • 4 bits can represent 16 different values (24 = 16)
    • Hexadecimal has 16 symbols (0-9, A-F)
    • Therefore, one hex digit perfectly represents 4 bits

    Practical implications:

    • 1 hex digit = 4 bits (nibble)
    • 2 hex digits = 8 bits (byte)
    • 4 hex digits = 16 bits (word on many systems)
    • 8 hex digits = 32 bits (double word / int on many systems)

    This perfect alignment makes hex ideal for representing binary data compactly.

    7. How do I convert hex back to decimal?

    To convert hexadecimal to decimal, use the positional notation method or our hex to decimal converter tool.

    Manual method:

    1. Start from the rightmost digit (position 0)
    2. Multiply each hex digit by 16 raised to its position
    3. Sum all the results

    Example: Convert 2A3F to decimal

    • F x 160 = 15 x 1 = 15
    • 3 x 161 = 3 x 16 = 48
    • A x 162 = 10 x 256 = 2,560
    • 2 x 163 = 2 x 4,096 = 8,192
    • Total: 10,815

    Quick link: Use our Hex to Decimal Converter for instant results!

    8. Does this tool support negative numbers?

    Most decimal to hexadecimal converters handle negative numbers in one of two ways:

    1. Signed notation (simple):

    • Input: -255
    • Output: -FF
    • The negative sign is preserved

    2. Two's complement (advanced):

    • Requires specifying bit width (8-bit, 16-bit, 32-bit, etc.)
    • Represents negatives as positive hex values
    • Example: -1 in 8-bit two's complement = 0xFF

    For basic conversions, signed notation (keeping the minus sign) is standard. For low-level programming or hardware work, you may need two's complement conversion with a specified bit width.

    9. What is the maximum input size this converter supports?

    The maximum depends on the implementation:

    Typical limits:

    • JavaScript-based: Up to 253 - 1 (9,007,199,254,740,991) for safe precision
    • Python-based: Virtually unlimited (Python handles arbitrary-precision integers)
    • Standard tools: Often capped at 64-bit values (up to 18,446,744,073,709,551,615)

    For very large numbers:

    • Use tools with BigInt support
    • Check tool documentation for specific limits
    • Consider whether you need exact precision

    Practical range: Most use cases involve numbers well below 232 (4,294,967,295), which any converter handles easily.

    10. How do I convert decimal to hex in JavaScript/Python/C?

    JavaScript:

    let decimal = 255;
    let hex = decimal.toString(16).toUpperCase();  // "FF"

    Python:

    decimal = 255
    hex_value = f"{decimal:X}"  # "FF"
    # Or: hex(decimal) for "0xff"

    C:

    int decimal = 255;
    printf("%X", decimal);  // Outputs: FF
    // Or: printf("%#X", decimal); for "0xFF"

    All three languages:

    • Support padding with zeros
    • Allow uppercase/lowercase output
    • Can add 0x prefix if needed
    • Handle large numbers (with language-specific limitations)
    Tool Point

    Free tools for everyday tasks, from quick text fixes to image edits, SEO checks, and calculators. No sign-up needed. Fast, private, and easy to use.

    © 2026 Tool Point. All rights reserved.