INI
Getting Started
Introduction
- INI is a configuration file with a fixed standard format
- Base elements are keys or properties
- Each key consists of a name and a value, separated by an equal sign (
=) - key name is displayed to the left side of the equals sign
- Equal sign (
=) and semicolon (;) are reserved characters - INI configuration method comes from the MS-DOS operating system
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 Doeorganization=Acme Products
[database]; Here are the commentsserver=192.0.2.42port=143file="acme payroll.dat"
[section.subsection]foo = barComments
Comment (;)
; This is the comment text and will be ignoredComment (#)
# Here is the comment text, ⚠️ Some compilers support itComments after a line (;,#) (not standard)
var = a ; this is an inline commentfoo = bar # this is another inline commentComments must appear alone on lines in some cases
Sections
- The name appears on a line by itself
- Names are enclosed in square brackets
[and] - No explicit
section enddelimiter - End at the next
sectiondeclaration or at the end of the file - Section and attribute names are case insensitive
[section]key1 = akey2 = bThe same as JSON below 👇
{ "section": { "key1": "a", "key2": "b" }}Nesting (supported by some parsers)
[section]domain = cheatsheets.zip[section.subsection]foo = barThe same as JSON below 👇
{ "section": { "domain": "cheatsheets.zip" "subsection": { "foo": "bar" } }}Nest to previous section (shorthand)
[section]domain = cheatsheets.zip[.subsection]foo = barEscape character
| sequence | meaning |
|---|---|
\\ | \ (single backslash, escape escape character) |
\' | apostrophe |
\" | double quotes |
\0 | null character |
\a | ringtone/alert/sound |
\b | Backspace, [Bell character] for some applications (https://en.wikipedia.org/wiki/Bell_character) |
\t | tab character |
\r | carriage return |
\n | newline |
\; | semicolon |
\# | number sign |
\= | equal sign |
\: | colon |
\x???? | Unicode character for the hexadecimal code point corresponding to ???? |
Array
[section]domain = cheatsheets.ziparray[]=first valuearray[]=second valueThe same as JSON below 👇
{ "section": { "domain": "cheatsheets.zip", "array": ["first value", "second value"] }}Interpreter
- @go-ini/ini (golang)
- @npm/ini (nodejs)
- @zonyitoo/rust-ini (rust)
- @rxi/ini (c)
- @pulzed/mINI (c++)
- @rickyah/ini-parser (c#)
- @Enichan/Ini (c#)
See also
- INI file configuration(wikipedia.org)