ConfKit is a lightweight and extensible .NET library for parsing and generating multiple configuration formats, including INI and UCI (OpenWrt Unified Configuration Interface).
It provides a consistent programming model, supports structured configuration access, and enables seamless conversion to JSON for strong typing and serialization.
- INI configuration parsing and generation
- UCI (OpenWrt) configuration parsing and generation
- Hierarchical sections and entries
- Strongly-typed object model
- Preserve structure and ordering
- Convert configurations to
JsonObject - Deserialize into custom strongly-typed classes
- Flexible integration with
System.Text.Json
- Simple and intuitive API
- Works with
netstandard2.0and modern .NET versions - Easy to extend for additional formats (TOML, YAML, etc.)
| Package | Target Frameworks | NuGet |
|---|---|---|
| ConfKit |
Package Details
| Package | Target Frameworks |
|---|---|
| ConfKit | ConfKit is a lightweight and extensible .NET library for parsing and generating multiple configuration formats, including INI and UCI. |
dotnet add package ConfKitstring iniContent = @"
[server.database]
host = localhost
port = 1433";
var config = IniParser.Parse(iniContent);
string host = config.Sections
.First(s => s.Name == "server")
.SubSections.First(s => s.Name == "database")
.Entries.First(e => e.Key == "host").Value;var config = new IniConfig
{
Entries =
[
new IniEntry("debug", "true"),
],
Sections =
[
new IniSection("server")
{
SubSections =
[
new IniSection("database")
{
Entries =
[
new IniEntry("host", "localhost"),
new IniEntry("port", "1433")
],
},
],
},
],
};
string output = config.ToString();string configContent = @"
package network
config interface 'lan'
option type 'bridge'
option ifname 'eth0'
option proto 'static'
";
var config = UciParser.Parse(configContent);
Console.WriteLine(config.PackageName);var config = new UciConfig
{
PackageName = "network",
Sections =
[
new UciSection("interface", "lan")
{
Options =
[
new UciOption("type", "bridge"),
new UciOption("ifname", "eth0"),
new UciOption("proto", "static")
]
}
]
};
string output = config.ToString();Both INI and UCI configurations can be converted into a JsonObject, making it easy to deserialize into custom types.
var config = IniParser.Parse(iniContent);
// Convert to JSON object
JsonObject json = config.ToSerializableJsonObject();
// Deserialize to custom type
var options = new JsonSerializerOptions
{
NumberHandling = JsonNumberHandling.AllowReadingFromString
};
var result = json.Deserialize<MyConfig>(options);- Add support for reading and writing comments (current parser just ignores comments)
MIT License
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.