Jsson Docs
Guides

Multi-Format Transpilation

Learn how to transpile JSSON to JSON, YAML, TOML, and TypeScript.

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

FormatCLI FlagBest For
JSONDefaultAPIs, Web Configs, Data Interchange
YAML-f yamlKubernetes, CI/CD, CloudFormation
TOML-f tomlRust Configs, Python (pyproject.toml), Hugo
TypeScript-f tsFrontend Constants, Design Systems, Shared Types

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

Consider this JSSON file defining a server configuration:

// server.jsson
server {
  host = "localhost"
  port = 8080
  
  // Dynamic environment
  env = production
  
  // Computed timeout
  timeout = 30 * 1000
  
  features = [ logging, metrics, tracing ]
}

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: production
  features:
    - logging
    - metrics
    - tracing
  host: localhost
  port: 8080
  timeout: 30000

Standard TOML output.

[server]
env = "production"
host = "localhost"
port = 8080
timeout = 30000
features = ["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

The TypeScript transpiler is particularly powerful because it bridges the gap between your configuration and your application code.

Features

  1. as const Assertions: All objects are generated with as const, making them immutable and narrowing types to their literal values.
  2. Type Inference: JSSON automatically exports a TypeScript type for each top-level object (e.g., export type Server = typeof server).
  3. Zero Runtime: The output is pure TypeScript/JavaScript. No JSSON runtime is needed in your application.

Use Case: Design Systems

You can define your design tokens in JSSON and generate typed TypeScript constants for your frontend:

// tokens.jsson
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!

On this page