An INI file is a configuration file for computer software that consists of a text-based content with a structure and syntax comprising key–value pairs for properties, and sections that organize the properties. The name of these configuration files comes from the filename extension INI, for initialization, used in the MS-DOS operating system which popularized this method of software configuration. The format has become an informal standard in many contexts of configuration, but many applications on other operating systems use different file name extensions, such as conf and cfg.
History
The primary mechanism of software configuration in Windows was originally a text file format that comprised text lines with one key–value pair per line, organized into sections. This format was used for operating system components, such as device drivers, fonts, and startup launchers. INI files were also generally used by applications to store individual settings.
The format was maintained in 16-bit Microsoft Windows platforms up through Windows 3.1x. Starting with Windows 95 Microsoft favored the use of the Windows Registry and began to steer developers away from using INI files for configuration. All subsequent versions of Windows have used the Windows Registry for system configuration, but applications built on the .NET Framework use special XML .config files. The initialization-file functions are still available in Windows and developers may still use them.
Besides Windows software, platform-agnostic software may use this file format for configuration. Some Unix-like config files also use a similar format. INI is human-readable and simple to parse, so it is a usable format for configuration files that do not require much greater complexity.
Examples of use
Desktop.ini files determine the display of directories in Windows, e.g., the icons for a directory.
Git configuration files are similar to INI files. The freedesktop.org format, which provides a link to an application, uses a similar format. Other examples with Unix-like system software include systemd service files and . PHP uses the INI format for its "php.ini" configuration file in both Windows and Linux systems.
Example
The following example file has two sections: one for the owner of the software, and one for a payroll database connection. Comments record the last person who modified the file and the reason for modification. ; last modified 1 April 2001 by John Doe [owner] name = John Doe organization = Acme Widgets Inc.
[database]
; use IP address in case network name resolution is not working
server = 192.0.2.62
port = 143
file = "payroll.dat"
Format
INI is an informal format, with features that vary from parser to parser (INI dialects). Some features are more shared across different parsers than others and can be considered as the hard core of the format (e.g. square brackets for sections, newlines for delimiting different nodes, etc.). Attempts to create parsers able to support as many dialects as possible exist, and in its most advanced form the INI format is able to express a tree object with a power comparable to that of other structured formats (JSON, XML) using a more relaxed syntax.
Stable features
Keys (properties) The basic element contained in an INI file is the key or property. Every key has a name and a value, delimited by an equals sign (=). The name appears to the left of the equals sign. In the Windows implementation the equal sign and the semicolon are reserved characters and cannot appear in the key. The value can contain any character.
name = value
Leading and trailing whitespaces around the outside of the property name are ignored.
Sections
Keys may, but need not, be grouped into arbitrarily named sections. The section name appears on a line by itself, in square brackets ([ and ]). All keys after the section declaration are associated with that section. There is no explicit "end of section" delimiter; sections end at the next section declaration, or at the end of the file. Sections cannot be nested. [section] key1 = a key2 = b
Case sensitivity
Section and property names are case insensitive.
Comments
Semicolons (;) at the beginning of the line indicate a comment. Comment lines are ignored. ; comment text
Order of sections and properties
The order of properties in a section and the order of sections in a file is irrelevant.