Advanced YINI Code Examples

Level: Advanced / Optional features

These examples show how YINI supports more advanced configuration scenarios beyond everyday usage, including optional syntax features, extended value formats, and production-level setups.

⚠️ Note: These examples demonstrate optional syntax, edge cases, and advanced capabilities. You do not need these features to use YINI effectively. If you're new to YINI, start with the Get Started guide or the Basic examples.

See everyday YINI configuration examples on the main Examples page.

Example: CLI application options

@yini

/*

Features:
  - The disable line "--", it's used to disable a line.
  - Sections
  - Strings (double quotes), numbers, booleans
  - A list
  - A full line-comment with ;

*/

^ CLI
command = "deploy"
dry_run = false
verbosity = 2
include_paths = ["src/", "lib/", "config/"]
--exclude_patterns: "*.test.ts", "*.spec.js"
timeout = 60

    ; Output settings.
    ^^ Output
    format = "json"
    color = yes
    log_level = "debug"

Example: Database connection configuration

@YINI

/*

Features:
  - Using alternative section marker "Β§" (for high-end systems)
  - Nested sections
  - Objects
  - Strings (double quotes)
  - Numbers, booleans, nulls

*/

Β§ Database
type = "postgres"
host = "localhost"
port = 5432
username = "admin"
password = "s3cr3t"
db_name = "myapp"
pool = { max: 10, min: 2, idle: 10000 }

    Β§Β§ Options
    ssl = off
    connection_timeout = 30
    retry_attempts = 3

Example: Feature flags configuration

/*

Features:
  - Backticked keys and section headers:
    Backticked keys and section headers let you use more flexible section
    names, such as names with spaces or punctuation, while keeping normal
    section names simple and easy to read.

  - Section nesting

  - Booleans (YES/NO/ON/OFF/TRUE/FALSE/NULL)
  
  - Lists
  
  - Nulls

*/

^ `Features`
beta = TRUE
dark_mode = ON
experimental_ui = NO
`welcome tour` = YES

    ^^ `User Groups`
    admin = ["alice", "bob"]
    beta_testers = ["charlie", "dana"]
    `regular users` = []

    ^^ `Feature Toggles`
    feature_x = TRUE
    feature_y = FALSE
    feature_z = NULL

Example: Email SMTP configuration

@yini

/*

Example: SMTP email configuration at a deep section level

Features shown:
  - Numeric shorthand section markers:
    `^10` means a level 10 section, and `^11` means a nested level 11 section.

    Numeric shorthand is mainly useful when repeated section markers are no longer
    practical, or when the nesting level is deeper than the repeated-marker form
    should be used for.

    In this example, the earlier sections build the path down to level 9.
    Then `^10 SMTP` creates a level 10 section inside `Mail`.

  - Numbers:
    Useful for ports, timeouts, retry counts, and size limits.

  - Booleans:
    Useful for on/off settings such as TLS, authentication, and debug logging.

  - Multi-line triple-quoted strings:
    Useful for longer text values, such as email signatures or message templates.

  - Null (upper case):
    `NULL` means no value is set. This can be useful when a setting is optional.

*/

// This is an example.

^ Application
^^ Services
^^^ Messaging
^^^^ Providers
^^^^^ Email
^^^^^^ Outbound
^^^^^^^ Production
^^^^^^^^ RegionEU
^^^^^^^^^ Mail
^10 SMTP
server = 'smtp.mailserver.com'
port = 587
use_tls = true
auth_required = true
debug_logging = false

username = 'mailer'
password = 'change_me'

timeout_seconds = 30
max_retries = 3
max_message_size_mb = 25

^11 Defaults
from_address = 'noreply@example.com'
reply_to = NULL

signature = """Kind regards,
The Example Team
"""

welcome_subject = 'Welcome to Example App'

welcome_message = """Hello,

Welcome to Example App.

Your account is now ready to use.

Kind regards,
The Example Team
"""

Looking for everyday examples?
β€’ Common real-world examples.
β€’ Core and practical YINI config examples.


Next steps

  • ➑️ Get Started
    Learn how to install and use YINI.
  • ➑️ Basic Examples
    See minimal, everyday YINI configuration examples.