YINI Code Examples
Below are practical examples written in YINI, a text-based data format, showing how the format handles structure, data types, and readability — without relying on indentation-based syntax.New to YINI format? See Intro to the YINI format
💡 Note: YINI uses indentation only for human readability. Section markers (^, ^^, ^^^) define the section nesting.
Basic example
// A small, practical YINI config.
// The App section starts here
^ 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 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
More examples
The following full examples demonstrate how YINI scales from small configs to complete real-world setups.
File example 1: Web server configuration (sections, numbers, booleans)
/*
Features:
- Section headers
- Nested sections
- Strings (single quotes)
- Number values, booleans, nulls
*/
^ Server
host = '0.0.0.0'
port = 8080
enable_ssl = false
log_file = '/var/log/server.log'
max_connections = 200
^^ SSL
enabled = false
cert_path = null
key_path = null
File example 2: User profile settings (objects, lists, and comments)
@yini
/*
Features:
- Section nesting (up to 3 levels)
- Strings (single/double quotes)
- Strings, nulls, booleans
- List
*/
^ profile
username = "robinkoda"
display_name = 'Robin Koda'
email = "robin@example.com"
avatar = null
is_active = true
roles = ["user", "editor"]
created_at = "2024-05-12T10:30:00Z"
^^ preferences
theme = 'light'
language = "en"
notifications = true
^^^ editor
font = "Fira Code"
tab_width = 4
autosave = on
File example 4: Build project configuration (real-world example)
/*
Features:
- Sections
- Nested sections
- Lists
- Strings (double quotes), booleans,
*/
^ Build
entry = "src/index.ts"
output = "dist/"
source_map = true
minify = true
target = "ES2022"
^^ Plugins
enabled = ["eslint", "prettier", "typedoc"]
^^ Env
NODE_ENV = "production"
API_URL = "https://api.example.com"
DEBUG = false
Next steps
-
➡️ Get Started
Learn how to install and use YINI. -
➡️ Quick Tutorial
A 5-minute guided walkthrough of YINI basics.
