INI Cheat Sheet | JR Academy


title: INI date: 2022-12-30 09:51:44 background: bg-[#6d94c7] tags: categories: - Programming intro: | This is a quick reference cheat sheet for understanding and writing INI-format configuration files. plugins: - copyCode

Getting Started

Introduction

Now an informal standard for many configurations, other operating systems may use .conf or .cfg as a suffix

Example

; Here are the comments
[owner]
name=John Doe
organization=Acme Products

[database]
; Here are the comments
server=192.0.2.42
port=143
file="acme payroll.dat"

[section.subsection]
foo = bar

Comments

Comment (;)

; This is the comment text and will be ignored

Comment (#)

# Here is the comment text, ⚠️ Some compilers support it

Comments after a line (;,#) (not standard)

var = a ; this is an inline comment
foo = bar # this is another inline comment

Comments must appear alone on lines in some cases

Sections

[section]
key1 = a
key2 = b

The same as JSON below 👇

{
	"section": {
		"key1": "a",
		"key2": "b"
	}
}

Nesting (supported by some parsers)

[section]
domain = cheatsheets.zip
[section.subsection]
foo = bar

The same as JSON below 👇

{
  "section": {
    "domain": "cheatsheets.zip"
    "subsection": {
      "foo": "bar"
    }
  }
}

Nest to previous section (shorthand)

[section]
domain = cheatsheets.zip
[.subsection]
foo = bar

Escape character

sequencemeaning
\\\ (single backslash, escape escape character)
\'apostrophe
\"double quotes
\0null character
\aringtone/alert/sound
\bBackspace, [Bell character] for some applications (https://en.wikipedia.org/wiki/Bell_character)
\ttab character
\rcarriage return
\nnewline
\;semicolon
\#number sign
\=equal sign
\:colon
\x????Unicode character for the hexadecimal code point corresponding to ????

Array

[section]
domain = cheatsheets.zip
array[]=first value
array[]=second value

The same as JSON below 👇

{
	"section": {
		"domain": "cheatsheets.zip",
		"array": ["first value", "second value"]
	}
}

Interpreter

See also