The Config Problem
YAML: indentation errors that break prod. JSON: no comments, no variables. TOML: limited nesting. Jsonnet: nobody knows it.
Pkl (Pickle) by Apple is a typed configuration language. Write config once, generate JSON, YAML, XML, or Plist. With validation.
What Pkl Gives You
Typed Configuration
class ServerConfig {
host: String
port: Int(isBetween(1, 65535))
debug: Boolean = false
workers: Int(isPositive) = 4
}
production: ServerConfig = new {
host = "api.example.com"
port = 443
workers = 16
}
staging: ServerConfig = (production) {
host = "staging.example.com"
debug = true
workers = 2
}
Staging inherits from production. Override only what's different.
Validation Built In
class DatabaseConfig {
host: String(!isEmpty)
port: Int(isBetween(1, 65535))
maxConnections: Int(isBetween(1, 1000))
sslMode: "disable"|"require"|"verify-full"
}
Invalid config? Compile-time error. Not a runtime crash.
Generate Any Format
pkl eval config.pkl -f json # → config.json
pkl eval config.pkl -f yaml # → config.yaml
pkl eval config.pkl -f plist # → config.plist
pkl eval config.pkl -f xml # → config.xml
Modules and Imports
import "base-config.pkl"
server = (base.server) {
host = "custom.example.com"
}
Share config modules across teams. Publish to a registry.
Dynamic Values
local replicas = 3
services: Listing<Service> = new {
for (i in IntSeq(1, replicas)) {
new {
name = "worker-\(i)"
port = 8080 + i
}
}
}
IDE Support
VS Code extension with autocomplete, type checking, and inline errors.
Quick Start
brew install pkl
pkl eval config.pkl
SDKs available for: Swift, Kotlin, Java, Go.
Why This Matters
Configuration is code — it should have types, validation, and IDE support. Pkl brings software engineering practices to the one place that still uses untyped text files.
Managing configuration for data pipelines? Check out my web scraping actors on Apify Store — configurable data extraction. For custom solutions, email spinov001@gmail.com.
Top comments (0)