HEX to Jetpack Compose & Android XML Color Converter
Convert HEX to Jetpack Compose Color(0xFF...) and Android XML color resources with alpha. Copy ready-to-paste Kotlin and colors.xml snippets instantly.
Color
Generated code
Color(0xFF3B82F6)<color name="brand_primary">#FF3B82F6</color>Technical Specification & Mathematical Principles
How the Android Color Converter Works
Android stores colors as 32-bit ARGB integers in the order alpha, red, green, blue. Web HEX puts alpha last (#RRGGBBAA), so the generator moves the alpha byte to the front: opacity 0.5 becomes 0x80 and #3B82F6 with full opacity becomes 0xFF3B82F6.
Jetpack Compose accepts that literal as Color(0xFF3B82F6). In XML resources the same value is written with a hash: <color name="brand_primary">#FF3B82F6</color>. Resource names must be lowercase letters, digits and underscores, so the tool normalizes whatever you type.
Frequently Asked Questions
Why does Android put alpha first?
Do I need the L suffix in Kotlin?
Where do I paste the XML snippet?
Related Design & Color Instruments
SwiftUI Color Code Generator
Turn any HEX color into SwiftUI Color(.sRGB, red:, green:, blue:, opacity:) code, plus a UIKit UIColor snippet. Free, instant and processed locally.
Flutter Color Code Generator
Convert HEX to Flutter Dart const Color(0xFFRRGGBB) with an alpha channel, plus Color.fromRGBO output. Instant, private and ready to paste.
Design Tokens Export (DTCG JSON)
Generate W3C Design Tokens Community Group JSON for colors with $value and $type. Name up to 12 tokens and copy a spec-shaped file for Style Dictionary.
RGBA to 8-Digit HEX
Convert rgba() strings with transparency into modern 8-character hexadecimal web codes (#RRGGBBAA).