My program need to parse css files into an in-memory object format. Any advice on how this should be done ?

Solution 1

ExCSS (supports CSS2.1 and CSS3) on GitHub:

Which is a newer version of the code project article:

Solution 2

And a slightly slower search turns up the blog post "CSS parser class in .NET" which embeds this gist on GitHub (in case the blog ever dies).

Solution 3

There is a CSS grammar file for GoldParser:

GoldParser is easy to include in a C# project, and generates an real LALR parser - not some regex hack.

Solution 4

Have you tried the one featured in JsonFx? It's written in C#, parses CSS3 syntax and is distributed under a MIT style license.

Solution 5

I wrote one, using the grammar specified in the CSS 2.1 spec. I have also released it now: for details, see

Solution 6

Here you can find another one especially for C# with sample source.