Multi-Format Transpilation
JSSON is a universal meta-format. This means you can write your configuration logic once in JSSON and output it to whatever format your tools require.
Supported Formats
Section titled “Supported Formats”| Format | CLI Flag | Best For |
|---|---|---|
| JSON | Default | APIs, Web Configs, Data Interchange |
| YAML | -f yaml | Kubernetes, CI/CD, CloudFormation |
| TOML | -f toml | Rust Configs, Python (pyproject.toml), Hugo |
| TypeScript | -f ts | Frontend Constants, Design Systems, Shared Types |
How It Works
Section titled “How It Works”The JSSON compiler takes your source code, evaluates all logic (templates, maps, ranges, expressions), and then serializes the resulting data structure into the target format.
Example
Section titled “Example”Consider this JSSON file defining a server configuration:
server {host = "localhost"port = 8080
// Dynamic environmentenv = production
// Computed timeouttimeout = 30 * 1000
features = [ logging, metrics, tracing ]}Output Comparison
Section titled “Output Comparison”Standard JSON output.
{ "server": { "host": "localhost", "port": 8080, "env": "production", "timeout": 30000, "features": [ "logging", "metrics", "tracing" ] } }Clean YAML output, perfect for infrastructure.
server:env: productionfeatures: - logging - metrics - tracinghost: localhostport: 8080timeout: 30000Standard TOML output.
[server]env = "production"host = "localhost"port = 8080timeout = 30000features = ["logging", "metrics", "tracing"]Generates as const objects and type definitions.
export const server = { host: "localhost", port: 8080, env: "production", timeout: 30000, features: [ "logging", "metrics", "tracing" ] } as const; export type Server = typeof server;TypeScript Generation
Section titled “TypeScript Generation”The TypeScript transpiler is particularly powerful because it bridges the gap between your configuration and your application code.
Features
Section titled “Features”as constAssertions: All objects are generated withas const, making them immutable and narrowing types to their literal values.- Type Inference: JSSON automatically exports a TypeScript type for each top-level object (e.g.,
export type Server = typeof server). - Zero Runtime: The output is pure TypeScript/JavaScript. No JSSON runtime is needed in your application.
Use Case: Design Systems
Section titled “Use Case: Design Systems”You can define your design tokens in JSSON and generate typed TypeScript constants for your frontend:
colors { primary = "#0070f3" secondary = "#ff4081"
gray [ template { shade, value } map (item) = { shade = item.shade * 100 value = "#" + item.shade + item.shade + item.shade } 1..9 ]}Generates:
export const colors = { primary: "#0070f3", secondary: "#ff4081", gray: [ { shade: 100, value: "#111" }, { shade: 200, value: "#222" }, // ... ],} as const;
export type Colors = typeof colors;Now you have full autocompletion for your design tokens in your React/Vue/Svelte components!