Core & Basic Examples

Below are practical examples written in the YINI configuration format, showing how YINI handles structure, data types, and readability β€” without relying on indentation-based syntax.

New to YINI? Start with Learn the format or keep the Cheat Sheet open while reading.


Start with these minimal examples to understand the core syntax.

Basic and quick examples

Basic example 1

@yini

^ App
name = "Nebula"
version = "1.4.0"
debug = false
maxUsers = 500

^ Server
host = "0.0.0.0"
port = 8080
useTls = true

Basic example 2

@yini

^ App
name = "Nebula"
features = ["search", "dark-mode"]
isDebug = false

^ Server
host = "0.0.0.0"
port = 8080
limits = { rpm: 1200, burst: 60 }

πŸ’‘ Note: YINI uses indentation only for human readability. Section markers (^, ^^, ^^^) define the section nesting.

Basic example 3

@yini

// The section "App" starts here
^ App
name = "Nebula"
environment = "production"

// Sub-section of App
^^ Network
bindAddress = "127.0.0.1"
bindPort = 8080
allowedOrigins = ["https://myapp.com", "http://localhost:3000"]

Basic example 4

/*
    YINI config.
*/

@yini

^ App
name = "Demo App"
version = 1.2
features = ["search", "logs"]
debug = false    // on/off, yes/no would work too
pageSize = 25

    // Another section (sub-section of App)
    ^^ Server
    host = "localhost"
    port = 8080    # Can comment with # too
    useTLS = off

Section examples

Sections

/*
    sections.yini
    sections + key/value basics (no lists/objects).
*/

// Section named App
^ App
name = "Demo App"
version = "1.2.3"
debug = off

// Section named Server
^ Server
host = "0.0.0.0"
port = 8080
useTLS = false

// Section named Logging
^ Logging
level = "info"
file = "/var/log/demo-app.log"

^ Database
driver = "postgres"
host = "localhost"
port = 5432
username = "demo"
password = "change-me"
database = "demo_db"
poolSize = 10

Nested sections

# nested-sections.yini β€” clear section nesting without indentation rules.

// Indentation is optional β€” section markers (^, ^^, ^^^) define the section nesting.
^ App
name = "Demo App"
env = "production"

    // Nested sub-section of App
    ^^ Features
    caching = on
    telemetry = off

    // Another sub-section of App
    ^^ UI
    theme = "dark"
    language = "en"

        // This is sub-section of UI
        ^^^ Editor
        font = "Fira Code"
        tabWidth = 4
        autosave = true


// Back to sub-section of App
^ Server
host = "0.0.0.0"
port = 8080

    ^^ TLS
    enabled = false
    certPath = null
    keyPath = null

    ^^ Limits
    maxConnections = 200
    timeoutSeconds = 60

^ Logging
level = "info"

    ^^ Output
    format = "json"
    color = yes

Indentation examples

Indentation in YINI is only used for human readability. Section markers define the structure, so you can choose a formatting style that works for your file.

See the dedicated indentation examples for side-by-side formatting styles.


Comments & compound types

Comments

// comments.yini β€” demonstrates every comment style YINI supports.

@yini
^ App
    // Single-line comment (most common style)
    name = "Demo App"
    version = "1.2"
    features = ["search", "logs"]
    debug = false    // inline comment, after a value

    # Full-line comment using the alternate "#" style
    pageSize = 25

^^ Logging
    level = "info"    // e.g. "debug" during development
    file = "logs/app.log"

/*
    Block comments can span multiple lines.
    Useful for longer notes or documenting a whole section.
*/

Lists and objects

// lists-and-objects.yini
// Arrays (lists) + objects + nesting.

@yini

// Indentation is optional β€” section markers (^, ^^, ^^^) define the section nesting.
^ App
name = "Demo App"
enabled = true

tags = ["demo", "config", "v1"]

ports = [80, 443, 8080]

features = [
    "search",
    "dark-mode",
    "metrics"
]

limits = { retries: 3, timeoutSeconds: 30, backoffMs: [250, 500, 1000] }

database = {
    type: "postgres",
    host: "localhost",
    port: 5432,
    credentials: { user: "app", pass: "change-me" },
    options: { ssl: off, pool: { min: 2, max: 10 } }
}

    ^^ Users
    allow = ["alice", "bob", "charlie"]
    roles = {
        alice: ["admin", "editor"],
        bob: ["editor"],
        charlie: ["viewer"]
    }

Numbers and structured nesting

Number formats

# number-formats.yini
# Numeric literals and where they're useful.

^ Numbers
    # Integers
    retries = 3
    max_connections = 200
    timeout_seconds = 60

    # Floats
    ratio = 0.75
    threshold = 1.25
    pi = 3.14159

    # Negatives
    offset = -12
    temperature_c = -7.5

    # Underscore separators (readability)
    big_int = 1000000
    bytes = 16384
    price = 12345.67

    # Hex (often used for colors, bitmasks, ids)
    primary_color = 0x336699
    feature_mask = 0x1F

    # Scientific notation (when specs/data use it)
    avogadro = 6.022e23
    small = 1e-6

    # Edge-ish values (still normal numbers)
    zero = 0
    one = 1

Nested and structured

/*
    nested-and-structured.yini

    Example: Nestable & Structured (without indentation ambiguity).
*/

// Indentation is optional β€” section markers (^, ^^, ^^^) define the section nesting.
^ App
name = "DemoApp"
features = ["search", "sync", "export"]

    ^^ Server
    host = "0.0.0.0"
    port = 8080
    options = { timeout: 30, secure: true }

    ^^ Database
    engine = "postgres"
    credentials = {
        user: "admin",
        password: "secret"
    }

        ^^^ Pool
        min = 5
        max = 50

Continue exploring:
β€’ Common real-world examples.
β€’ Large YINI configuration examples.


Next steps

  • ➑️ Get Started
    Learn how to install and use YINI.
  • ➑️ Quick Tutorial
    A 5-minute guided walkthrough of YINI basics.