DEV Community

Alex Spinov
Alex Spinov

Posted on

Pkl Has a Free Configuration Language — Type-Safe Configs That Generate JSON, YAML, and More

Pkl (by Apple) is a configuration language — write type-safe configs and generate JSON, YAML, XML, or any format.

What You Get for Free

  • Type safety — catch config errors at build time
  • Validation — constraints on values (ranges, patterns)
  • Modules — reusable config templates
  • Multi-format output — generate JSON, YAML, plist, properties
  • IDE support — IntelliJ and VS Code extensions
  • Packages — share config schemas as packages
  • Templating — inheritance, composition, overrides
  • CLI — evaluate, test, format Pkl files

Quick Start

brew install pkl
Enter fullscreen mode Exit fullscreen mode
// server.pkl
host: String = "localhost"
port: Int(isBetween(1, 65535)) = 8080
database {
  url: String = "postgres://localhost/mydb"
  maxConnections: Int(isPositive) = 10
}
Enter fullscreen mode Exit fullscreen mode
pkl eval server.pkl -f json
# {"host":"localhost","port":8080,"database":{"url":"postgres://localhost/mydb","maxConnections":10}}

pkl eval server.pkl -f yaml
# host: localhost
# port: 8080
# database:
#   url: postgres://localhost/mydb
#   maxConnections: 10
Enter fullscreen mode Exit fullscreen mode

Why Developers Switch from Raw YAML

YAML has no types, no validation, and indentation bugs:

  • Type-safeport: Int catches port: "8080" at build time
  • ValidationisBetween(1, 65535) rejects port 70000
  • Multi-format — one source, generate JSON, YAML, XML
  • IDE support — autocomplete, error highlighting

A team deployed to production with maxConnections: "10" (string, not int) in YAML — caused a 3-hour outage. After Pkl: type system would have caught it at build time.

Need Custom Data Solutions?

I build production-grade scrapers and data pipelines for startups, agencies, and research teams.

Browse 88+ ready-made scrapers on Apify → — Reddit, HN, LinkedIn, Google, Amazon, and more.

Custom project? Email me: spinov001@gmail.com — fast turnaround, fair pricing.

Top comments (0)