Schema
Schema defaults are optional. Keys without defaults are required.
Schema constraints are written after the type and before an optional default:
- String
- Int
- Float
- Bool
- Duration
- Lists: [Type]
- Maps: { key: Type ... }
- Int 1..100 requires an integer inside the inclusive range.
schema { host: String port: Int 1..65535 = 8080 mode: String oneof ["dev", "prod"] = "dev" service_name: String min-length 3 timeout: Duration features: [String] database: { url: String pool: Int = 4 }}Values
Nested assignment paths are supported:
References point to another key path and are resolved after parsing:
References must resolve to a known config value or schema default and must match the target key type.
- String concatenation with + for String + String.
- Numeric arithmetic with +, -, *, and / for Int and Float values.
- Parentheses for grouping arithmetic and concatenation.
- Conditionals with if CONDITION then VALUE else VALUE; the condition must be Bool.
host = "0.0.0.0"port = 8080service_name = "api"timeout = 30sfeatures = ["auth", "search"]database = { url = "postgres://localhost/app" }Includes
Include another Envra file with a string path:
Relative include paths are resolved from the including file's directory. Included schema entries, assignments, and environment overlays are loaded before the including file's own entries.
Environment Overlays
Named overlays merge over the base config:
Use --env NAME to apply an overlay:
schema { host: String port: Int = 8080} host = "localhost" env prod { host = "api.example.com"}Validation
Validate a single file:
Validate every .envra file in a directory tree:
When --env NAME is provided, each file is checked with that overlay.
envra validate configs/envra check configs/Durations
Durations are integer amounts with one of these units:
Durations emit to JSON as strings, preserving the literal form after validation.
- ms
- s
- m
- h
Output Formats
envra build emits canonical JSON by default:
Select another output format with --format:
YAML and TOML output preserve the same resolved config shape. Env output flattens nested paths to uppercase underscore keys, for example database.url becomes DATABASE_URL.
- Object keys are sorted lexicographically.
- Strings are JSON escaped.
- Defaults are included.
- References are resolved.
- Selected environment overlays are merged over base assignments.
- Secrets are emitted as "<redacted>".
envra build config.envra --format jsonenvra build config.envra --format yamlenvra build config.envra --format tomlenvra build config.envra --format envJSON Schema Export
Export a JSON Schema derived from the Envra schema block:
The exported schema uses JSON Schema draft 2020-12, emits object properties for Envra schema keys, marks keys without defaults as required, disables additional object properties, and maps Envra constraints as follows:
- Int 1..100 becomes minimum and maximum.
- String oneof [...] becomes enum.
- String min-length N becomes minLength.
- Duration becomes a string with the duration literal pattern.
JSON Schema Import
Scaffold an Envra schema block from a JSON Schema file:
The importer supports JSON Schema object properties, nested objects, arrays with items, primitive type values, required, default, minimum/maximum, string enum, minLength, and the Envra duration pattern ^[0-9]+(ms|s|m|h)$.
Download
Envra is in active development and has no public downloads or releases yet.
No public download artifacts are available yet for this language.
Looking for everything in one place? See the downloads index.
