Configuration that is Programmable, Scalable, and Safe
name = "Swallow"
job {
title = "Sr. Nest Maker"
company = "Nests R Us"
yearsOfExperience = 2
}
↓
{
"name": "Swallow",
"job": {
"title": "Sr. Nest Maker",
"company": "Nests R Us",
"yearsOfExperience": 2
}
}
name: Swallow
job:
title: Sr. Nest Maker
company: Nests R Us
yearsOfExperience: 2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Swallow</string>
<key>job</key>
<dict>
<key>title</key>
<string>Sr. Nest Maker</string>
<key>company</key>
<string>Nests R Us</string>
<key>yearsOfExperience</key>
<integer>2</integer>
</dict>
</dict>
</plist>
name = Swallow
job.title = Sr. Nest Maker
job.company = Nests R Us
job.yearsOfExperience = 2
Generate any static configuration format
Define all your data in Pkl, and generate output for JSON, YAML, Property Lists, and other configuration formats.
Integrated application configuration
Embed Pkl into your applications for runtime configuration, and receive code generation for Java, Kotlin, Swift, and Go.
module example.MyAppConfig
/// The hostname for the application
host: String
/// The port to listen on
port: UInt16(this > 1000)
package example;
public final class MyAppConfig {
/**
* The hostname for the application
*/
public final @NonNull String host;
/**
* The port to listen on
*/
public final int port;
public MyAppConfig(
@Named("host") @NonNull String host,
@Named("port") int port) {
this.host = host;
this.port = port;
}
public MyAppConfig withHost(@NonNull String host) { /*...*/ }
public MyAppConfig withPort(int port) { /*...*/ }
@Override
public boolean equals(Object obj) { /*...*/ }
@Override
public int hashCode() { /*...*/ }
@Override
public String toString() { /*...*/ }
}
package example
data class MyAppConfig(
/**
* The hostname for the application
*/
val host: String,
/**
* The port to listen on
*/
val port: Int
)
// Code generated from Pkl module `example.myAppConfig`. DO NOT EDIT.
enum MyAppConfig {}
extension MyAppConfig {
struct Module {
/// The hostname for the application
let host: String
/// The port to listen on
let port: UInt16
}
}
// Code generated from Pkl module `example.myAppConfig`. DO NOT EDIT.
package myappconfig
import (
"context"
"github.com/apple/pkl-go/pkl"
)
type MyAppConfig struct {
// The hostname for the application
Host string `pkl:"host"`
// The port to listen on
Port uint16 `pkl:"port"`
}
Incredible IDE Integration
Great tooling for writing Pkl with the same ease as a static typed language. We offer plugins and extensions for IntelliJ, Visual Studio Code and Neovim, and also provide the Pkl Language Server so you can easily your own editor integrations.
Catch errors before deployment
With a rich type and validation system, catch configuration errors before deploying your application.
email: String = "[email protected]"
port: Int(this > 1000) = 80
↓
–– Pkl Error ––
Type constraint `this > 1000` violated.
Value: 80
3 | port: Int(this > 1000) = 80
^^^^^^^^^^^
at config#port (config.pkl, line 3)
3 | port: Int(this > 1000) = 80
^^
at config#port (config.pkl, line 3)
106 | text = renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^