Fork me on GitHub


A tool for lexing and parsing text for the .NET framework, intended for those medium sized parsing applications where you used to cobble together a parser by hand. When a parsing task is too complex for regular expressions but too simple for dragging in a huge tool, Piglet can help! With a fluent and readable syntax and a low footprint, everyone can use proper parsing techniques.

Fluent configuration

Piglet boasts a fluent configuration interface, where you type what you mean to parse and not how you indend do to so. With modern code completion guiding you along the way, writing a parser is easy.


Dependency free, no pre-build step needed. A single assembly is all that you need. Download it here or on NuGet. Open sourced under the MIT license.

GitHub » NuGet »


Open sourced and open for contributors at any skill level. Fork away here at github.

View details »

Parsing with Piglet

Piglet is designed to make parsing as quick and easy as possible. The key to this is to avoid technical terms as much as possible and use a fluent configuration that describes what you actually want the parser to do. But enough talk, here is a JSON parser implemented in Piglet:

var config = ParserFactory.Fluent();

var jsonObject = config.Rule();
var jsonElement = config.Rule();
var jsonValue = config.Rule();
var jsonArray = config.Rule();

	.WhenFound( o => new JsonObject { Elements = o.ElementList } );

	.WhenFound( o => new JsonElement { Name = o.Name, Value = o.Value } );

	.Or.By("null").WhenFound(o => null);

	   .WhenFound(o => o.Values);

var parser = config.CreateParser();

That's all you need to do. The parser object now contains a working parser ready to do your bidding, pass it a string and receive a JSONobject back. Most of the common things a user might want to parse are already implemented, such as integers, doubles and quoted strings. Less work for you.