Value Literal Examples

These examples focus on the basic value types used inside YINI members: strings, booleans, numbers, and common literal forms.

Use this page when you want to compare value syntax directly. For sections and nesting, start with the Core and basic examples.


Strings

Basic strings

Playground
# strings-and-escapes.yini
# Basic string examples.

^ Strings

^^ BasicStrings
# YINI strings must be quoted.
name = "Robin"
city = 'Stockholm'
message = "Hello, YINI"

^^ ChoosingQuotes
# Use the other quote type when the text contains a quote.
owner = "Amanda's file"
quoted_text = 'He said "hello"'

^^ RawByDefault
# Backslashes are ordinary text unless you use a C-string.
windows_path = "C:\Users\Kim\Documents"
literal_text = "Line 1\nLine 2"

Escaped strings

Playground
# string-escapes.yini
# Use C-strings when escape sequences should be interpreted.

^ EscapedStrings

^^ NewlinesAndTabs
line_break = C"Line 1\nLine 2"
tabbed = C"key\tvalue"

^^ QuotesAndBackslashes
quoted = C"He said \"hello\""
folder = C"C:\\Users\\Kim\\Documents"

^^ LowercasePrefix
# The C prefix is case-insensitive.
message = c"Ready\nDone"

Multi-line strings

Playground
# string-multiline.yini
# Triple-quoted strings are useful for longer text.

^ MultiLineStrings

^^ RawBlock
description = """This text spans
more than one line.
Line breaks are preserved.
"""

^^ MessageTemplate
welcome_message = """Hello,

Welcome to the service.

Kind regards,
The Example Team
"""

String concatenation

Playground
# string-concatenation.yini
# Concatenation joins string values with +.

^ Concatenation

^^ ShortValues
title = "YINI: " + "Readable config"
label = "port-" + "8080"

^^ LongValues
# A line break may appear after +.
description = "Section markers " +
              "define structure."

Booleans

Boolean literals

Playground
# boolean-literals.yini
# Boolean literals are case-insensitive.

^ FeatureFlags
search = true
dark_mode = ON
new_checkout = YES

^^ DisabledFeatures
legacy_api = false
debug_toolbar = OFF
beta_banner = NO

Numbers

The number examples include decimal values, signs, exponents, base prefixes, and underscore digit separators such as 12_345 and 1_234_567.

Number formats

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

^ Numbers

^^ Decimal
integer = 42
positive_integer = +42
negative_integer = -12
zero = 0

^^ Floats
ratio = 0.75
threshold = 1.25
temperature_c = -7.5
signed_decimal = +12.5

^^ Exponents
large = 3e4
precise = 1.23e4
small = 1e-6
explicit_plus = 6.022e+23
grouped_exponent = 1.5e1_0

^^ DigitSeparators
two_groups = 12_345
grouped_millions = 1_234_567
big_int = 1_000_000
bytes = 16_384
price = 12_345.67
precise_decimal = 1_000.5_25

^^ Binary
permissions = 0b1101
grouped_bits = 0b1111_0001
alt_binary = %1010
alt_binary_grouped = %_1010

^^ Octal
file_mode = 0o755
grouped_octal = 0o755_644

^^ Duodecimal
base_twelve = 0z2EX9
base_twelve_alt_digits = 0z2BA9
grouped_duodecimal = 0z_2EX9

^^ Hexadecimal
primary_color = 0x336699
feature_mask = 0x1F
grouped_hex = 0xCAFE_BABE
hex_color = hex:FFAA00
hex_color_grouped = hex:_FF_AA_00
uppercase_hex_prefix = HEX:FA90

Explore more examples:
- Core and practical YINI config examples.
- Common real-world examples.