Free tool
Hex to Flutter Color converter
Turn any hex, RGB or HSL colour into Flutter code, then generate a MaterialColor swatch and a Material 3 theme from it.
Accepts #RGB, #RRGGBB, 8-digit hex, 0xAARRGGBB, Color(0x…), rgb(), rgba(), hsl() and hsla().
Flutter code
- Hex (recommended)
const Color(0xFF2196F3) - fromARGB
const Color.fromARGB(255, 33, 150, 243) - fromRGBO
const Color.fromRGBO(33, 150, 243, 1) - Color.from (Flutter 3.27+)
const Color.from(alpha: 1, red: 0.129, green: 0.588, blue: 0.953)
Contrast with white text 3.12:1 · with black text 6.72:1 (4.5:1 or more is readable for body text).
MaterialColor swatch
- 500xFFE9F5FE
- 1000xFFCEE8FC
- 2000xFFA6D5FA
- 3000xFF7AC0F8
- 4000xFF4DABF5
- 5000xFF2196F3
- 6000xFF1E87DB
- 7000xFF1A75BE
- 8000xFF1663A0
- 9000xFF114E7E
const MaterialColor brand = MaterialColor(
0xFF2196F3,
<int, Color>{
50: Color(0xFFE9F5FE),
100: Color(0xFFCEE8FC),
200: Color(0xFFA6D5FA),
300: Color(0xFF7AC0F8),
400: Color(0xFF4DABF5),
500: Color(0xFF2196F3),
600: Color(0xFF1E87DB),
700: Color(0xFF1A75BE),
800: Color(0xFF1663A0),
900: Color(0xFF114E7E),
},
);Material 3 theme from this colour
MaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF2196F3)),
),
darkTheme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF2196F3),
brightness: Brightness.dark,
),
),
home: const HomeScreen(),
)Why I built this
Designers hand me colours as #2196F3 from Figma, and Flutter wants Color(0xFF2196F3). The conversion is simple once you know it, but I still see the same mistakes in code reviews and beginner questions: a missing FF that makes the colour invisible, an 8-digit Figma hex with the alpha in the wrong place, or Colors.blue used as primarySwatch because building a custom MaterialColor by hand takes ten lines. This tool does all three in one place.
How to convert a hex colour to a Flutter Color
Flutter stores a colour as one 32-bit number in ARGB order: alpha (opacity) first, then red, green and blue. To write a hex colour in Flutter:
- Remove the
#:#2196F3→2196F3. - Add the alpha in front.
FFis fully opaque:FF2196F3. - Add
0xand wrap it:const Color(0xFF2196F3).
If you write Color(0x2196F3) without the FF, the alpha is 00, so the colour is completely transparent. That is the most common reason a custom colour “doesn’t show up” in Flutter.
Opacity: the alpha values you need
The first two hex digits set the opacity. Some values I use all the time: FF = 100%, E6 = 90%, CC = 80%, B3 = 70%, 99 = 60%, 80 = 50%, 66 = 40%, 4D = 30%, 33 = 20%, 1A = 10%. Type any colour with transparency above, such as rgba(33, 150, 243, 0.5), and the tool gives you the exact value.
To change the opacity of an existing colour in code, Flutter 3.27 changed the method:
// Deprecated since Flutter 3.27:
color.withOpacity(0.5)
// Use instead:
color.withValues(alpha: 0.5)8-digit hex: Figma vs Flutter
This trips people up. CSS and Figma write transparency at the end, #2196F380 (RRGGBBAA). Flutter and Android put it at the start, 0x802196F3 (AARRGGBB). Copy an 8-digit value from Figma straight into Color(0x…) and you get the wrong colour. When you paste 8 digits, the tool asks which order you mean and converts it correctly.
The four ways to write a colour in Flutter
Color(0xFF2196F3): the hex form. Short, works withconst, and it is what Flutter prints in the debugger, so it is the one I use.Color.fromARGB(255, 33, 150, 243): every channel as 0–255.Color.fromRGBO(33, 150, 243, 1.0): RGB as 0–255 and opacity as 0.0–1.0, like CSSrgba().Color.from(alpha: 1, red: 0.129, …): added in Flutter 3.27 for wide-gamut colours. Every channel is 0.0–1.0.
All four create the same colour, so pick whichever reads best to you and stay consistent.
MaterialColor swatch or ColorScheme.fromSeed?
MaterialColor is the Material 2 way: ten shades from 50 to 900, used with primarySwatch or when you want brand[100] for a light background and brand[700] for text. The swatch above uses lighter tints above 500 and darker shades below it, with your colour as 500. It is a close, practical approximation, not Google’s exact palette algorithm.
For a new app on Material 3 (the default since Flutter 3.16), use ColorScheme.fromSeed instead. It builds the full set of matching colours (primary, secondary, surface, error and more) for light and dark mode from one seed. My guide on dark mode and theme toggles shows it inside a real app.
Parsing a hex string at runtime
If the colour comes from an API or Firestore as text, convert it in Dart with a small extension:
extension HexColor on Color {
/// HexColor.fromHex('#2196F3') or HexColor.fromHex('2196F3')
static Color fromHex(String hex) {
final value = hex.replaceFirst('#', '');
return Color(int.parse(value.length == 6 ? 'FF$value' : value, radix: 16));
}
}FAQ
Why is my Color(0x…) not showing? Check the first two digits after 0x. If they are missing or 00, the colour is transparent.
Which text colour should I use on it? The tool shows the contrast ratio with white and black text. Aim for at least 4.5:1 for normal text and 3:1 for large, bold text.
Can I use this in a BoxShadow or gradient? Yes, any Color works there. For shadows, try the Flutter BoxShadow generator, which outputs these colour codes for you.
More free Flutter tools
JSON to Dart Converter
Paste JSON and get null-safe Dart model classes for Flutter: plain fromJson/toJson, json_serializable or freezed.
Open toolPubspec Checker
Paste your pubspec.yaml and find outdated, discontinued and new-major-version packages, with the updated file to copy.
Open toolcURL to Dart (Dio & http)
Turn a cURL command into Flutter code for Dio or http, with headers, JSON, forms, uploads and a response model.
Open toolFlutter BoxShadow Generator
Design shadows with a live preview: soft cards, Material elevation, neumorphism and glow. Copy the BoxDecoration code.
Open toolDevice Frame Mockup Generator
Put your app screenshot in an iPhone 17 Pro Max, Pixel or Galaxy frame and download a high-resolution PNG.
Open toolApp Store Screenshot Generator
Make App Store and Google Play screenshots with headlines and device frames, plus a Play Store feature graphic.
Open toolFlutter Splash Screen Generator
Preview your splash on Android 12+, older Android and iPhone, see what the Android 12 circle cuts off, and get the flutter_native_splash files.
Open toolApp Icon Generator
Upload one image and get every iOS, Android adaptive, web and Play Store icon size for your Flutter app.
Open toolCode to Image
Turn Dart, Flutter and other code into a beautiful, syntax-highlighted image for posts and slides.
Open tool