SwiftUI Color Set Generator

Hex colours in, Assets.xcassets colour sets out, with dark mode and Swift usage lines.

Updated

Everything is built in this browser tab. Your colours and names are not sent anywhere.

Colours

Colour space
Your hex values are written as they are in the space you pick. Nothing is converted between sRGB and Display P3.
Component format
NameLightDark (optional)
Assets.xcassets/Brand Primary.colorset/Contents.json
{
  "colors": [
    {
      "color": {
        "color-space": "srgb",
        "components": {
          "alpha": "1.000",
          "blue": "0.898",
          "green": "0.275",
          "red": "0.310"
        }
      },
      "idiom": "universal"
    },
    {
      "color": {
        "color-space": "srgb",
        "components": {
          "alpha": "1.000",
          "blue": "0.973",
          "green": "0.549",
          "red": "0.506"
        }
      },
      "idiom": "universal",
      "appearances": [
        {
          "appearance": "luminosity",
          "value": "dark"
        }
      ]
    }
  ],
  "info": {
    "author": "xcode",
    "version": 1
  }
}
Swift usage
// SwiftUI, by name (all Xcode versions)
Text("Hello").foregroundStyle(Color("Brand Primary"))

// UIKit
let color = UIColor(named: "Brand Primary")

// Xcode 15 and later: generated symbol (see the note below)
Text("Hello").foregroundStyle(Color(.brandPrimary))

What this follows, and what we could not verify (checked 2026-11-11)

  • The file layout (a colors array with universal, dark, high contrast and dark plus high contrast entries, color-space srgb or display-p3, and an info block with author xcode and version 1) is the structure Xcode writes for colour sets. Apple's documentation pages are rendered by script and could not be fetched as text, so we could not quote Apple's own reference for it. Open the result in Xcode once and check the inspector.
  • The float format writes strings with three decimals, as Xcode does; the 8-bit option writes values such as 0x4F. We could not confirm from Apple's pages that Xcode reads the hex form back, so test it in Xcode; the float form is the safe default.
  • Color(.name) uses the symbol Xcode 15 and later generates for each asset. We write the name in lowerCamelCase (Brand Primary becomes brandPrimary). Check the exact symbol in Xcode, and your project's asset symbol build setting, before relying on it.
  • Colours are opaque (alpha 1.000). Light is the default (any appearance) entry.

How to make Xcode colour sets from hex values

  1. 1
    List your coloursGive each colour a name and a light hex value. Add a dark hex for dark mode, or paste a list with one colour per line to fill the table at once.
  2. 2
    Pick the colour space and formatChoose sRGB or Display P3 and whether components are written as 0 to 1 floats or 8-bit hex. Switch on high contrast variants if your design has them.
  3. 3
    Check the JSON and Swift linesThe first colour's Contents.json and the Color, UIColor and generated-symbol lines are shown so you can see exactly what will be written.
  4. 4
    Download and add to XcodeDownload the ZIP and copy the .colorset folders into your Assets.xcassets, or drag in the whole catalog for a new project. Select a colour in Xcode to check its values.

Frequently asked questions

What is inside a .colorset folder?
A single Contents.json. It has a colors array with one entry per appearance (the default, dark, high contrast, and dark with high contrast), each with a color-space and red, green, blue and alpha components, plus an info block. The asset catalog name is the folder name without .colorset.
Does the tool convert my hex between sRGB and Display P3?
No. It writes your numbers into the colour space you choose. If you pick Display P3, the hex is treated as P3 values. A true sRGB to P3 conversion would change the numbers, and designers usually copy P3 values straight from their design tool.
Why are there two component formats?
Xcode writes floats as strings such as 0.310, and its colour inspector also accepts 8-bit values written as 0x4F. The float form is the safe default. We could not confirm from Apple's pages that Xcode reads the hex form back, so test it before you commit a large palette.
How does Color(.brandPrimary) work?
Xcode 15 and later can generate a Swift symbol for each asset, so a colour set named Brand Primary becomes Color(.brandPrimary). It is checked at compile time, unlike Color("Brand Primary"), which fails quietly at runtime if the name has a typo. We could not fetch Apple's page text for the exact naming rule, so check the symbol in Xcode.
Do I have to add a dark colour?
No. With only a light colour, the set has one entry that Xcode uses in every appearance. Add a dark colour when dark mode needs a different shade, and high contrast colours only when your design defines them.
Are my colours sent to a server?
No. The JSON files and ZIP are built in your browser tab.

Related tools

See all 135 free tools

Need a custom dev tool for your team?

We build internal tools, dashboards, APIs, and SaaS platforms. If you can describe it, we can ship it.

Built by CountryDevs · No signup · No ads · We count visits, never what you enter