A type-safe F# library for reading configuration from environment variables and AppSettings.
FsConfig is a configuration library for F# that provides a type-safe way to read settings from environment variables, AppSettings, and other sources like JSON, XML, and INI files. It eliminates boilerplate code by allowing developers to define configuration as F# record types, automatically handling parsing, error reporting, and naming conventions. The library solves the problem of verbose, error-prone configuration management in F# applications, especially those following patterns like The Twelve-Factor App.
F# developers building applications that require robust configuration management, such as web services, microservices, or cloud-native apps following The Twelve-Factor App methodology. It is particularly useful for teams needing type safety, reduced boilerplate, and seamless integration with .NET Core's IConfiguration.
Developers choose FsConfig over alternatives because it leverages F#'s type system to ensure configuration values are correctly typed at compile time, eliminating runtime errors from manual parsing. Its unique selling point is the combination of type safety with flexible customization—supporting complex types like records, lists, and discriminated unions, along with detailed error handling for missing or invalid values.
FsConfig is a F# library for reading configuration data from environment variables and AppSettings with type safety.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses F# record types and .NET TryParse methods to ensure configuration values are correctly typed at compile time, reducing runtime parsing errors as highlighted in the README's comparison with manual environment variable reading.
Returns specific error types like NotFound or BadValue when configuration is missing or invalid, making debugging straightforward, as shown in the error handling examples in the README.
Supports customization via attributes such as Convention for prefixes and separators, and CustomName for explicit overrides, allowing adaptation to various environment variable naming standards.
Handles nested records, lists with custom separators, option types, and discriminated unions without extra boilerplate, enabling rich configuration schemas as demonstrated in the README examples.
Integrates with Microsoft.Extensions.Configuration to read from JSON, XML, and INI files through the AppConfig type, providing a unified type-safe interface for modern .NET applications.
AppConfig support for non-.NET Core applications is only available in version 0.0.6 or below, which restricts usability in older .NET Framework projects without migration.
Requires familiarity with F# record types, discriminated unions, and attribute-based programming, which can be a barrier for developers new to the language or team environments with mixed expertise.
Lacks support for automatic configuration reloading; changes to files like JSON or environment variables require application restart or manual re-initialization, which is inconvenient for dynamic deployments.