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 config with lists and objects.

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

^ 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 2

// A small, practical YINI config.

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

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

Basic example 3

/*
    YINI config.
*/

^ 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 β€” how you indent your YINI is up to you πŸ™‚ However, it is recommended to stick to one style per file.

Indentation style 1: Indenting whole nested sections.

// Indentation example 1 of Basic App Config - indent-ex-conf1.yini

/*
 * Indentation is optional - section markers (^, ^^, ^^^)
 * define the section nesting.
 *
 * Style 1: indent the entire nested section, including the section header.
 */

^ App
name = "My Application"
version = "1.0.0"
debug = off // Disable debugging

    ^^ Database    // Nested section of App
    host = "localhost"
    port = 5432
    user = "admin"
    password = "secret"

        ^^^ Pool    // Nested section of Database
        min = 2
        max = 10
        idleTimeout = 300

    ^^ Logging      // Another section of App
    level = "info"
    logToFile = true
    filePath = "./logs/app.log"

Indentation style 2: Indenting only the section body in nested sections.

// Indentation example 2 of Basic App Config - indent-ex-conf2.yini

/*
 * Indentation is optional - section markers (^, ^^, ^^^)
 * define the section nesting.
 *
 * Style 2: indent only the section body, not the section header.
 */

^ App
    name = "My Application"
    version = "1.0.0"
    debug = off // Disable debugging

        ^^ Database    // Nested section of App
            host = "localhost"
            port = 5432
            user = "admin"
            password = "secret"

                ^^^ Pool    // Nested section of Database
                    min = 2
                    max = 10
                    idleTimeout = 300

        ^^ Logging      // Another section of App
            level = "info"
            logToFile = true
            filePath = "./logs/app.log"

Indentation style 3: Flat sections nesting, not indenting at all.

// Indentation example 3 of Basic App Config - indent-ex-conf3.yini

/*
 * Indentation is optional - section markers (^, ^^, ^^^)
 * define the section nesting.
 *
 * Style 3: no indentation for nested sections.
 */

^ App
name = "My Application"
version = "1.0.0"
debug = off // Disable debugging

^^ Database    // Nested section of App
host = "localhost"
port = 5432
user = "admin"
password = "secret"

^^^ Pool    // Nested section of Database
min = 2
max = 10
idleTimeout = 300

^^ Logging      // Another section of App
level = "info"
logToFile = true
filePath = "./logs/app.log"

Comments & compound types

Comments

# Line comments + inline comments + block comments.

/* App configuration. */

^ App
name = "Demo App"           // Inline comment (//)
debug = off                 # Inline comment (#)
pageSize = 25

; Semicolon comments are line comments (start of line only).

# You can also use full-line comments between entries.

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

      /* Another block comment:
         - Works across multiple lines
         - Good for documenting sections
      */

Lists and objects

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

// 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 = #336699
    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.