Discord Webhook Embed Color Field: Hex to Decimal Conversion
🔍 WiseChecker

Discord Webhook Embed Color Field: Hex to Decimal Conversion

When you send an embed via a Discord webhook, the color field does not accept standard hex codes like #FF5733. Instead, Discord requires the color value as a decimal integer. This mismatch causes embeds to appear with the default gray color if you paste a hex code directly. This article explains why Discord uses decimal for embed colors and provides a reliable method to convert any hex color to the correct decimal number. You will also learn how to test the conversion in your webhook payload.

Key Takeaways: Converting Hex to Decimal for Discord Embeds

  • Remove the hash (#) from the hex code: The hex value must be a clean 6-character string for conversion.
  • Use parseInt(hex, 16) in JavaScript: This function converts the hex string to a decimal integer that Discord accepts.
  • Online color converters: Many tools can instantly convert hex to decimal; verify the result by testing the embed in a webhook.

Why Discord Requires Decimal for Embed Colors

Discord’s API uses an integer to represent colors in embed objects. This integer is the decimal equivalent of the standard RGB hex color. For example, the color white (hex #FFFFFF) is stored as 16777215 in decimal. The API does not parse hex strings or named colors. When you send a hex code, Discord ignores it and defaults to a dark gray embed border. The reason is technical: the API treats the color field as a numeric value for efficient processing. This design is consistent across all Discord bot and webhook endpoints.

The conversion process is straightforward. A hex color is a base-16 number. Converting it to base-10 decimal gives you the integer you need. The conversion does not affect the visual appearance of the color. The decimal value is mathematically identical to the hex code. Once you understand this, you can easily generate the correct value for any color.

How to Convert Hex to Decimal for Discord Webhook Embeds

Follow these steps to convert a hex color to a decimal number and use it in your webhook embed. You can use a programming language, a spreadsheet, or an online tool. The example below uses JavaScript, which is common for Discord bot development.

  1. Get your hex color code
    Choose a color and write its hex code. Example: #3498DB (a shade of blue). Remove the hash symbol. The result is 3498DB.
  2. Use parseInt with base 16
    In JavaScript, run parseInt('3498DB', 16). The second argument 16 tells the function to interpret the string as hexadecimal. The result is 3447003. This is the decimal value.
  3. Insert the decimal into the embed JSON
    Add the color field to your embed object. Example: "color": 3447003. The full embed JSON might look like this:
    { "embeds": [{ "title": "Hello", "color": 3447003 }] }.
  4. Send the webhook and verify
    Use a tool like Postman or cURL to send the payload to your webhook URL. Check the embed in Discord. The left border should display your chosen color. If it appears gray, the decimal value is incorrect.

If you prefer not to write code, use an online hex-to-decimal converter. Search for “hex to decimal converter” and enter your 6-character hex string. The tool returns the decimal integer. Copy that number into the color field.

Common Mistakes When Using the Color Field

Including the hash symbol in the color value

Discord does not accept the hash character. If you send "color": "#3498DB", the API treats it as a string and ignores it. Always send a plain integer without quotes.

Using a color name instead of a decimal

Discord does not support named colors like "red" or "blue". You must provide the numeric decimal value. If you send a string, the embed defaults to no color.

Forgetting that the color field is optional

If you omit the color field entirely, Discord applies a default dark gray border. This is not an error, but it may look unintentional. To set a specific color, always include the color field with a valid decimal integer.

Hex to Decimal Color Conversion Table

Color Hex Code Decimal Value
Red E74C3C 15158332
Green 2ECC71 3066993
Blue 3498DB 3447003
Yellow F1C40F 15844367
Orange E67E22 15105570
Purple 9B59B6 10181046
White FFFFFF 16777215
Black 000000 0

Use this table as a quick reference for common embed colors. For custom colors, perform the conversion using the method described above.

Testing Your Embed Color in Discord

After you build the webhook payload, send a test message. You can use the Discord webhook tester in the server settings or a tool like cURL. Below is a complete cURL example that sends an embed with a blue color.

curl -X POST -H "Content-Type: application/json" -d '{"embeds":[{"title":"Test Embed","description":"This embed has a blue border.","color":3447003}]}' YOUR_WEBHOOK_URL

Replace YOUR_WEBHOOK_URL with your actual webhook URL. Run the command. If the embed border is blue, the conversion worked. If the border is gray, check that the color value is an integer and not a string.

Conclusion

You can now convert any hex color to a decimal integer for Discord webhook embeds. Use the parseInt function in JavaScript or an online converter to get the correct number. Always remove the hash symbol and pass the integer without quotes. Test your embed with a simple webhook payload to confirm the color displays as expected. For advanced use, consider building a small script that generates multiple embeds with consistent color schemes.