Hoplite vs Konf vs Typesafe Config in 2026: Kotlin Configuration That Fails at Startup
The worst configuration bug is not a crash. It is a service that starts cleanly with timeout = 0, pool-size = 1, and an empty feature list because a key was spelled pool_size in one environment and poolSize in another. Everything is green in staging, the container passes its health check, and the first real request discovers the problem. Configuration is the one part of a Kotlin service where the type system usually stops at the door — and the whole point of the libraries below is to drag it back inside.
Three libraries cover the JVM in 2026, and they encode three different philosophies. Hoplite (1,045 stars, last push 2026-12-01) maps config files directly onto Kotlin data classes and treats any missing or unconvertible value as a startup failure with a detailed message. Konf (320 stars, last push 2023-05-17) is a type-safe cascading configuration system with layered sources and broad format support. Typesafe Config (6,323 stars, 2026-11-06) is the HOCON library that Akka, Play, and half the Kafka ecosystem are built on — untyped at its core, but the most battle-tested of the three.
TL;DR
Use Hoplite for new Kotlin services. You declare a data class, point it at application.yaml, and the library either gives you a fully populated immutable object or refuses to start with an error that names the path, the expected type, and what it found. That single property — fail at startup, with a precise message — is worth more than every feature on the comparison table.
Use Typesafe Config when you are in the Lightbend ecosystem (Akka, Play, Lagom), when you need HOCON’s substitution and include semantics, or when the service is polyglot JVM and Java code must read the same file. Wrap it in typed Kotlin helpers, because raw getString calls scatter string keys across the codebase.
Use Konf only if cascading multi-source layering (file → env → Consul → AWS Parameter Store) is a hard requirement and you accept that the project has not shipped a release since May 2023. Layering is exactly what Konf does well; maintenance is exactly what it does not.
The comparison table
| Dimension | Hoplite | Konf | Typesafe Config |
|---|---|---|---|
| GitHub stars | 1,045 | 320 | 6,323 |
| Last push | 2026-12-01 | 2023-05-17 | 2026-11-06 |
| Format support | YAML, JSON, TOML, HOCON, .properties | YAML, JSON, HOCON, TOML, .properties, plus remote backends | HOCON, JSON, .properties (no YAML) |
| Typed decoding | Native — data classes, enums, inline classes, Duration, collections | Yes, via ConfigSpec delegates | No — manual getString/getInt/getDuration |
| Missing key behaviour | Startup failure with a detailed error | Failure on required, default on optional | Throws on access, not at load |
| Validation | Constructor + init blocks run during decoding | Spec-level and manual | Manual |
| Sealed hierarchies | Supported via discriminator field | Manual | Manual |
| Env var overrides | First-class environment source | Layered source (a core feature) | CONFIG_FORCE_ convention + substitution |
| Remote sources (Consul, S3, etc.) | No | Yes | No |
| Android | Not a target | Stated support | Works |
| License | Apache-2.0 | Apache-2.0 | Apache-2.0 |
| Best fit | Data-class-first JVM services | Multi-backend layered config | HOCON-era ecosystems, Java interop |
Decision matrix: pick in ten seconds
| Use case | Choose | Why |
|---|---|---|
| New Kotlin microservice, one config file | Hoplite | Fail-fast decoding into immutable data classes with no boilerplate |
| Akka, Play, or Kafka Streams app | Typesafe Config | It is already a transitive dependency and the ecosystem expects HOCON |
| Config split across file, env, and Consul | Konf | Layered cascading sources are its design centre |
| Shared config read by both Java and Kotlin modules | Typesafe Config | HOCON is the JVM-wide lingua franca |
Config with enums, Duration, and nested objects | Hoplite | Decoders exist for all of them; no manual parsing |
| Secrets injected as environment variables | Hoplite or Typesafe Config | Env source in Hoplite; CONFIG_FORCE_ in Typesafe Config |
| Spring Boot service | Neither — use @ConfigurationProperties | Spring already provides validated, typed binding |
| Strict startup validation with actionable errors | Hoplite | Error messages name the path and the type mismatch |
Hoplite: configuration as a data class
Hoplite’s model is simple enough to state in one sentence: describe your configuration as Kotlin types, and the library populates them or fails. There is no annotation processing, no generated code, and no getString("app.db.url") anywhere in your service.
| |
Three properties of that snippet do the heavy lifting. First, defaults live in the type, so the documented default and the actual default cannot drift apart. Second, addEnvironmentSource() lets a container override any key without a second parsing layer — the standard twelve-factor path. Third, loadConfigOrThrow returns a fully constructed AppConfig; if database.url is missing, the process dies with a message that names the path. Compare that to a ConfigFactory.load() call that succeeds happily and throws ConfigException.Missing forty minutes later inside a request handler.
Validation goes where Kotlin already puts it — the constructor:
| |
Because init blocks run during decoding, a config that violates invariants never reaches the application. That is the whole argument for a typed config layer in one example: the failure happens at startup, in CI, or in a staging deploy — never at 3 a.m. in production.
Hoplite also handles the two shapes that usually force people back to manual parsing: enums (decoded by name, failing on typos) and Duration (parsed from ISO-8601 or human strings, depending on the decoder in use). Sealed hierarchies need a discriminator field in the file — a type: "postgres" key that selects the subtype — which is the standard polymorphic-config pattern rather than Kotlin’s @Serializable machinery.
Typesafe Config: HOCON, substitution, and the ecosystem
Typesafe Config is older, untyped, and still everywhere. If your service touches Akka, Play, Kafka Streams, or a Java library that takes a Config object, this library is already on your classpath whether you chose it or not. Its format, HOCON, adds three things plain JSON lacks: comments, omission of root braces and commas, and substitutions.
| |
The ${?VAR} versus ${VAR} distinction is the single most important detail in HOCON: the question mark makes the substitution optional, so the preceding value survives when the environment variable is absent. Without it, an unset variable is a resolution failure at load time — which is what you want for secrets and what you do not want for convenience defaults.
Reading it from Kotlin is deliberately boring, which is both the strength and the weakness:
| |
Two operational features earn Typesafe Config its longevity. -Dconfig.file=/etc/app/application.conf lets an operator point the process at a specific file, which is exactly what container entrypoints need. And the CONFIG_FORCE_ convention maps environment variables onto config paths — CONFIG_FORCE_app_database_pool_size=20 overrides app.database.pool-size — which is how many JVM services handle overrides without writing any code at all.
What it does not give you is safety. Every getString is a stringly-typed promise, every key is validated at access time rather than load time, and a typo in a rarely executed branch survives until that branch runs. The pragmatic pattern is a thin typed layer: one data class per config section, one loader that reads the Config and constructs them, and all getString calls confined to that file. That is roughly what Hoplite does for you, which is why teams on greenfield Kotlin generally skip the manual layer.
Konf: cascading layers, with a maintenance caveat
Konf’s differentiator is layering. A configuration value can come from a file, then be overridden by environment variables, then by a Consul key, then by a command-line flag — and Konf resolves the cascade in a defined order while keeping types intact through ConfigSpec delegates.
| |
The delegate model means the spec is the schema: required fails loudly when nothing in any layer supplies a value, optional(default) preserves a default, and the accessor returns the declared type instead of an Any you have to cast. Layered sources are exactly the right answer for the “config lives in four places” problem, and Konf also supports remote backends that Hoplite deliberately does not.
The caveat is unavoidable: no release since May 2023. For a config library that is not automatically fatal — the API is small, the formats are stable, and the code is Apache-licensed so you can fork it — but it does mean you are adopting a dependency with no active maintainer, on the JVM, where library ecosystems move. If layering is the requirement, weigh Konf against writing a 200-line resolver over Typesafe Config, or against centralising configuration in your platform layer (Kubernetes ConfigMaps, Vault, or your config service) and keeping the service-side loader simple.
Deployment: where config actually breaks
The library choice matters less than the pipeline that delivers values into it. A twelve-factor setup for either Hoplite or Typesafe Config looks like this:
| |
Two rules make this reliable. First, the health check must exercise a code path that touched the config — a /healthz that only returns 200 OK tells you nothing about whether the database URL decoded. Second, secrets come from the environment, structure from the file: the base config file is versioned and reviewable, while credentials are injected at runtime and never committed.
Startup ordering also deserves attention. Config loading should happen once, before the HTTP listener binds, and the resulting object should be injected — not re-read from a singleton inside request handlers. Re-reading is how you get a service where half the requests use the new pool size and half use the old one after a rolling deploy.
Where each library bites
Typesafe Config’s YAML gap is real and surprising. It parses HOCON, JSON, and .properties — not YAML. Teams routinely assume otherwise because Kubernetes ships YAML everywhere. Convert at the boundary (a small init container or an env-driven HOCON template) instead of adding a YAML parser and reimplementing substitution.
Reflection has a cost on Android and under shrinking. Hoplite constructs data classes reflectively and needs kotlin-reflect on the classpath; if you ship Android builds with R8 or run a JVM service with aggressive ProGuard-style shrinking, keep the config classes and their constructors from being stripped or renamed. Konf advertises Android support explicitly, and Typesafe Config is pure Java — both are safer picks for a shrunk mobile build.
Konf’s convenience hides staleness. A spec delegate that silently keeps a default is comfortable right up until the default diverges from the deployment’s intent. Because the project is not releasing, treat every upgrade of Kotlin or the JDK as a compatibility test rather than assuming it will just work.
HOCON substitution order is not top-to-bottom in the way people assume. Later definitions of the same key override earlier ones, and substitutions resolve against the merged result. A ${?PORT} in the middle of a block behaves differently from one at the end. Read the resolution rules once, carefully; guessing produces bugs that only appear when an environment variable is set.
Config and tests fight over singletons. A ConfigFactory.load() call inside an object initialiser is evaluated once per JVM, so a test that changes a system property after the first load sees the old value. Make loading a function with an explicit source, inject the result, and build a fresh config per test. Hoplite’s builder API makes this natural; Typesafe Config requires discipline.
Logging config dumps secrets. Whatever loader you use, do not log the whole config object at startup. Log the resolved shape (paths and types) and redact values for anything matching password, secret, token, or key.
FAQ
Is Hoplite the right choice for a new Kotlin service in 2026?
For most JVM services, yes. It gives you typed decoding, defaults in the type system, environment-variable overrides, and startup failures with actionable messages, with no annotation processing and no generated code. The exceptions are Spring Boot (use @ConfigurationProperties), Akka or Play services (Typesafe Config is already present), and Android apps where reflection-based instantiation complicates shrinking.
Does Typesafe Config support YAML files?
No. It supports HOCON, JSON, and .properties. HOCON is a superset of JSON with comments, optional braces, and substitutions, which is why it feels YAML-adjacent — but a .yaml file will not parse. If your platform standardises on YAML, use Hoplite (which reads YAML directly) or convert to HOCON at deploy time.
Is Konf abandoned?
The repository has not received a push since May 2023, which in practice means unmaintained rather than archived. The library still works, the API is stable, and it remains the most straightforward way to cascade configuration across file, environment, and remote backends in Kotlin. If long-term maintenance matters more than layering, Hoplite or a thin layer over Typesafe Config is the lower-risk choice.
Which library validates configuration best?
Hoplite, because validation is just Kotlin code — require, init blocks, and constructor signatures execute during decoding, so an invalid config cannot produce an object. Typesafe Config validates only when you access a key, and Konf validates per-spec. The practical difference shows up in CI: Hoplite fails a container start in seconds, while the untyped alternatives fail on the code path that happens to read the bad value.
Can these libraries reload config without a restart?
Hoplite and Typesafe Config load once; neither watches files for changes out of the box. Reloading is usually the wrong goal anyway — a config change that alters behaviour mid-flight makes incidents harder to reason about. Prefer a rolling restart with a readiness gate, and keep per-request behaviour in feature flags rather than in configuration files.
How do I keep secrets out of config files?
Inject them as environment variables or mount them from a secret store, and reference them with optional substitution (${?DATABASE_PASSWORD} in HOCON, an environment source in Hoplite). Never commit a file containing a real credential, and never let a startup log print the resolved config — redact anything matching password, secret, token, or key.
For the adjacent decisions, our Kotlin serialization comparison covers the wire-format side of the same problem, the Kotlin testing frameworks guide shows how to test config loading in isolation, and the Python configuration libraries comparison is a useful cross-language sanity check on the same design trade-offs.
💰 想测试你的市场判断力?我用 Polymarket 做预测市场交易——这是全球最大的预测市场平台,从大选结果到技术监管时间线,什么都可以押注。和赌博不同,这是真正的信息市场:你懂的信息越多,胜率越高。我靠预测技术相关事件的走向已经赚了不少。用我的邀请链接注册:Polymarket.com