Conformance
How Saturon is tested against the Web Platform Tests, how it compares with other color libraries, and the known gaps
Saturon's parser is built from the CSS color grammar rather than a set of per-format patterns. The most direct way to check that claim is to run it against the same tests browsers use. The conformance script clones the web-platform-tests (WPT) repository, the shared cross-browser test suite for the web platform, and runs the color strings from its CSS color parsing tests through Saturon. Each string is expected to be valid, invalid, or to resolve to a specific computed value, and the library has to agree. The same strings are run through chroma-js, colorjs.io and culori so the numbers have something to be compared against.
Current results
These numbers use only what ships in the package. Nothing extra is registered in Saturon.
- WPT commit:
6f22f9eab8 - Saturon version:
v0.4.7 - Last run:
October 23, 2026
Most of the misses come from CSS Color Level 6
Saturon's built-in parser targets Levels 4 and 5. Most of the cases it misses
use syntax from the CSS Color Module Level 6 draft, most visibly
color-layers(). Those are intentionally not built in, but they can be registered. With the Level 6 recipes
registered, Saturon's results become:
The recipes used are color-layers() and
display-p3-linear.
Reading the numbers
The three columns answer different questions:
- Valid accepted is how many of the strings a browser accepts the library also accepts.
- Invalid rejected is how many of the strings a browser throws away the library also rejects.
- Computed match is how many of the strings resolve to the exact same computed value a browser reports.
Both parsing directions matter. A lenient parser can accept every valid string and still accept strings a browser would discard, which is why the invalid column is reported separately.
A syntax test, not a feature comparison
These libraries don't all aim to cover the full CSS Color grammar. chroma-js in particular targets a smaller set of formats, so its low scores mostly reflect syntax it was never meant to parse. The table shows how closely each library follows browser parsing, not which one is better.
How the tests run
The script lives at apps/conformance/wpt.mjs. It clones WPT (shallow and sparse, only css/css-color) and reads every .html file in css/css-color/parsing. Each file's inline scripts are evaluated in a sandbox that records calls to WPT's test_valid_value, test_invalid_value, and test_computed_value helpers. Only cases for the color property are kept.
Some kinds of cases are left out because they can't be judged from the string alone, such as: var(), currentcolor, sibling-index() or sibling-count().
Duplicate cases (the same string with the same expected result) are counted once, so a string that appears in several WPT files doesn't count several times.
How each library is asked
For valid and invalid cases, every library is given the same string and has to say whether it parses it or throws. For computed cases, each library is asked to produce a CSS string for the input and it is compared to the value WPT expects.
| Library | Counts as valid when | Computed value comes from |
|---|---|---|
| Saturon | Color.isValid(string) returns true | Color.computed(string) |
| chroma-js | chroma.valid(string) returns true | chroma(string).css() |
| colorjs.io | new Color(string) doesn't throw | new Color(string).toString() |
| culori | parse(string) returns something other than undefined |
Computed values are tricky
Saturon has a dedicated function for this, Color.computed(), which resolves a color
string to its computed value the way a browser does. The other libraries have no equivalent, so the closest
serialization they offer is used, and a library that throws counts as a mismatch. This is part of why their computed
scores are low: they weren't built to produce browser-style computed values.
What is tested
Each case checks one direction of the grammar:
- Valid strings must be accepted. For example
rgb(none none none / .5)andrgb(calc(infinity), 0, 0). - Invalid strings must be rejected. For example
rgb(none, none, none)(legacy comma syntax can't usenone) andrgb(10%, 20, 30%)(legacy syntax can't mix percentages and numbers). - Computed strings must resolve to the exact value a browser reports.
The tests cover, among others:
- Named colors, system colors, and hex colors
rgb(),hsl(),hwb(),lab(),lch(),oklab(), andoklch()color()across its predefined spacescolor-mix()- Relative color syntax, including nested origin colors and channel keywords
- The
nonekeyword, andcalc()withinfinityandNaN - CSS Color Level 6 syntax such as
color-layers()(only passes with the Level 6 recipes registered)
What isn't tested
Computed cases compare the serialized string only. Passing means the library produced the same text a browser does, not that every internal conversion matches to the last digit.
It also leaves out:
- Cases for properties other than
color(background-colorandopacity) - The
var(),currentcolor,sibling-index()andsibling-count()cases listed above - Everything outside
css/css-color/parsing
Run it yourself
The script needs git and network access, since it clones WPT every time it runs.
git clone https://github.com/ganemedelabs/saturon.git
cd saturon
pnpm install
pnpm conformance:wptFlags are passed through to the script:
pnpm conformance:wpt --verbose # list every string each library got wrong, colorized
pnpm conformance:wpt --all # include the var(), currentcolor and sibling-*() cases
pnpm conformance:wpt --level-6 # register the Level 6 recipes in Saturon before testing
pnpm conformance:wpt --json # also write results to results.json
pnpm conformance:wpt --json=out/results.jsonTo reuse an existing WPT checkout instead of cloning, set WPT_DIR to its path. Set NO_COLOR=1 to turn off colored output.
The script prints the WPT commit it ran against. Without WPT_DIR it always clones the latest WPT, so results can change as WPT adds or edits cases. The numbers on this page come from the commit listed above, so a run today may not match them exactly.
Found a disagreement?
If Saturon accepts a string that a browser rejects, or rejects one a browser accepts, please open an issue with the exact string and the browser version you tested in.
To see how the parser works, read Dual-Path Parsing.
Extensibility & Dynamic Registry
Explore how Saturon's decoupled registry allows you to dynamically inject and unregister custom color spaces, syntaxes, formatters, and algorithms at runtime.
Benchmarks
How Saturon's parsing, conversion, and serialization speed compares to chroma-js, colorjs.io, and culori, and how to reproduce the numbers