INI File
   HOME

TheInfoList



OR:

An INI file is a configuration file for
computer software Software is a set of computer programs and associated documentation and data. This is in contrast to hardware, from which the system is built and which actually performs the work. At the lowest programming level, executable code consists ...
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 A filename extension, file name extension or file extension is a suffix to the name of a computer file (e.g., .txt, .docx, .md). The extension indicates a characteristic of the file contents or its intended use. A filename extension is typically d ...
''INI'', for ''initialization'', used in the
MS-DOS MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few ope ...
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 Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
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 Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
platforms up through
Windows 3.1x Windows 3.1 is a major release of Microsoft Windows. It was released to manufacturing on April 6, 1992, as a successor to Windows 3.0. Like its predecessors, the Windows 3.1 series ran as a shell on top of MS-DOS. Codenamed Janus, Windows 3. ...
. Starting with
Windows 95 Windows 95 is a consumer-oriented operating system developed by Microsoft as part of its Windows 9x family of operating systems. The first operating system in the 9x family, it is the successor to Windows 3.1x, and was released to manufacturin ...
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 Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
''.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 A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
config files also use a similar format. INI is
human-readable A human-readable medium or human-readable format is any encoding of data or information that can be naturally read by humans. In computing, ''human-readable'' data is often encoded as ASCII or Unicode text, rather than as binary data. In most c ...
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 freedesktop.org (fd.o) is a project to work on interoperability and shared base technology for Free software, free-software desktop environments for the X Window System (X11) and Wayland (display server protocol), Wayland on Linux and other Uni ...
format, which provides a link to an application, uses a similar format. Other examples with Unix-like system software include
systemd systemd is a software suite that provides an array of system components for Linux operating systems. Its main aim is to unify service configuration and behavior across Linux distributions; Its primary component is a "system and service manager ...
service files and . *
PHP PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by The PHP Group ...
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
wner WNER (1410 AM broadcasting, AM) is a sports radio station in Watertown (city), New York, Watertown, New York, United States. The station is owned by Stephens Media Group (broadcasting), Stephens Media Group. It broadcasts the national programming ...
name = John Doe organization = Acme Widgets Inc. atabase; 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,
newline Newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in character encoding specifications such as ASCII, EBCDIC, Unicode, etc. This character, or a ...
s for delimiting different nodes, etc.). Attempts to create parsers able to support as many dialects as possible exist,libconfini's Library Function Manual
/ref> 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 equals sign (British English, Unicode) or equal sign (American English), also known as the equality sign, is the mathematical symbol , which is used to indicate equality in some well-defined sense. In an equation, it is placed between two ...
(=). 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 A bracket is either of two tall fore- or back-facing punctuation marks commonly used to isolate a segment of text or data from its surroundings. Typically deployed in symmetric pairs, an individual bracket may be identified as a 'left' or 'r ...
(''
' and '' The apostrophe ( or ) is a punctuation mark, and sometimes a diacritical mark, in languages that use the Latin alphabet and some other alphabets. In English, the apostrophe is used for two basic purposes: * The marking of the omission of one o ...
'). 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. ectionkey1 = a key2 = b


Case sensitivity

Section and property names are case insensitive.


Comments

Semicolon The semicolon or semi-colon is a symbol commonly used as orthographic punctuation. In the English language, a semicolon is most commonly used to link (in a single sentence) two independent clauses that are closely related in thought. When a ...
s ('';'') at the beginning of the line indicate a
comment Comment may refer to: * Comment (linguistics) or rheme, that which is said about the topic (theme) of a sentence * Bernard Comment (born 1960), Swiss writer and publisher Computing * Comment (computer programming), explanatory text or informat ...
. 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.


Varying features

As the INI file format is not rigidly defined, many parsers support features beyond the basics already described. The following is a list of some common features, which may or may not be implemented in any given program.


Global properties

Optional "global" properties may also be allowed, that are declared before any section is declared.


Name/value delimiter

Some implementations allow a colon (:) as the name/value delimiter (instead of the equals sign). Whitespace is occasionally used in the Linux world.


Hierarchy (section nesting)

Some parsers allow section nesting, using dots as path delimiters: ectiondomain = wikipedia.org ection.subsectionfoo = bar In some cases relative nesting is supported too, where a leading dot expresses nesting to the previous section: ectiondomain = wikipedia.org subsectionfoo = bar Historically, ways for expressing nesting alternative to the dot have existed too (for example, IBM's driver file for Microsoft Windows devlist.ini, in which the backslash was used as nesting delimiter in the form of \B\C/code>; or Microsoft Visual Studio's AEMANAGR.INI file, which used a completely different syntax in the form of /code> and B,C,P = V). Some parsers did not offer nesting support at all and were hierarchy-blind, but nesting could still be partially emulated by exploiting the fact that .B.C/code> constitutes a unique identifier.


Comments

Some software supports the use of the number sign (#) as an alternative to the semicolon for indicating comments, especially under Unix, where it mirrors shell comments. The number sign might be included in the key name in other dialects and ignored as such. For instance, the following line may be interpreted as a comment in one dialect, but create a variable named "#var" in another dialect. If the "#var" value is ignored, it would form a pseudo-implementation of a comment. #var = a In some implementations, a comment may begin anywhere on a line after a space (inline comments), including on the same line after properties or section declarations. var = a ; This is an inline comment foo = bar # This is another inline comment In others, including the
WinAPI The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to several different platform implementations ...
function ''GetPrivateProfileString'', comments must occur on lines by themselves.


Duplicate names

Most implementations only support having one property with a given name in a section. The second occurrence of a property name may cause an abort, it may be ignored (and the value discarded), or it may override the first occurrence (with the first value discarded). Some programs use duplicate property names to implement multi-valued properties. Interpretation of multiple section declarations with the same name also varies. In some implementations, duplicate sections simply merge their properties, as if they occurred contiguously. Others may abort, or ignore some aspect of the INI file.


Quoted values

Some implementations allow values to be quoted, typically using
double quotes Quotation marks (also known as quotes, quote marks, speech marks, inverted commas, or talking marks) are punctuation marks used in pairs in various writing systems to set off direct speech, a quotation, or a phrase. The pair consists of an ...
and/or
apostrophe The apostrophe ( or ) is a punctuation mark, and sometimes a diacritical mark, in languages that use the Latin alphabet and some other alphabets. In English, the apostrophe is used for two basic purposes: * The marking of the omission of one o ...
s. This allows for explicit declaration of whitespace, and/or for quoting of special characters (equals, semicolon, etc.). The standard Windows functio
GetPrivateProfileString
supports this, and will remove quotation marks that surround the values.


Escape characters

Some implementations offer varying support for an
escape character In computing and telecommunication, an escape character is a character (computing), character that invokes an alternative interpretation on the following characters in a character sequence. An escape character is a particular case of metacharac ...
, typically with the backslash (\) following the C syntax. Some support "line continuation", where a backslash followed immediately by EOL (end-of-line) causes the line break to be ignored, and the "logical line" to be continued on the next actual line from the INI file. Implementation of various "special characters" with escape sequences is also seen.


Accessing INI files

Under Windows, the ''Profile API'' is the programming interface used to read and write settings from classic Windows .ini files. For example, th
GetPrivateProfileString
function retrieves a string from the specified section in an initialization file. (The "private" profile is contrasted with , which fetches from
WIN.INI WIN.INI is a basic INI file that was used in versions of the Microsoft Windows operating environment up to Windows 3.11 to store basic settings at boot time. By default, all font, communications drivers, wallpaper, screen saver, and language set ...
.) The following sample C program demonstrates reading property values from the above sample INI file (let the name of configuration file be dbsettings.ini): #include int main(int argc, _TCHAR *argv[]) The third parameter of the GetPrivateProfileString function is the default value, which are "127.0.0.1" and 143 respectively in the two function calls above. If the argument supplied for this parameter is NULL, the default is an empty string, "". Under Unix, many different configuration libraries exist to access INI files. They are often already included in frameworks and toolkits. Examples of INI parsers for Unix includ
GLibiniparser
an
libconfini


Comparison of INI parsers


File mapping

Initialization file mapping creates a mapping between an INI file and the
Registry Registry may refer to: Computing * Container registry, an operating-system-level virtualization registry * Domain name registry, a database of top-level internet domain names * Local Internet registry * Metadata registry, information system for re ...
. It was introduced with Windows NT and Windows 95 as a way to migrate from storing settings in classic .ini files to the new Windows Registry. File mapping traps the Profile API calls and, using settings from the IniFileMapping Registry section, directs reads and writes to appropriate places in the Registry. Using the example below, a string call could be made to fetch the ''name'' key from the ''owner'' section from a settings file called, say, ''dbsettings.ini''. The returned value should be the string "John Doe":
GetPrivateProfileString("owner", "name", ... , "c:\\programs\\oldprogram\\dbsettings.ini");
INI mapping takes this Profile API call, ignores any path in the given filename and checks to see if there is a Registry key matching the filename under the directory: :HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\
   CurrentVersion\IniFileMapping
If this exists, it looks for an entry name matching the requested section. If an entry is found, INI mapping uses its value as a pointer to another part of the Registry. It then looks up the requested INI setting in that part of the Registry. If no matching entry name is found and there is an entry under the (Default) entry name, INI mapping uses that instead. Thus each section name does not need its own entry. So, in this case the profile call for the
wner WNER (1410 AM broadcasting, AM) is a sports radio station in Watertown (city), New York, Watertown, New York, United States. The station is owned by Stephens Media Group (broadcasting), Stephens Media Group. It broadcasts the national programming ...
/nowiki> section is mapped through to: where the "name" Registry entry name is found to match the requested INI key. The value of "John Doe" is then returned to the Profile call. In this case, the @ prefix on the default prevents any reads from going to the dbsettings.ini file on disk. The result is that any settings not found in the Registry are not looked for in the INI file. The "database" Registry entry does not have the @ prefix on the value; thus, for the atabase/nowiki> section ''only'', settings in the Registry are taken first followed by settings in the dbsettings.ini file on disk.


Alternatives

Starting with
Windows 95 Windows 95 is a consumer-oriented operating system developed by Microsoft as part of its Windows 9x family of operating systems. The first operating system in the 9x family, it is the successor to Windows 3.1x, and was released to manufacturin ...
, Microsoft began strongly promoting the use of Windows registry over the INI file. INI files are typically limited to two levels (sections and properties) and do not handle binary data well. This decision however has not been immune to critiques, due to the fact that the registry is monolithic, opaque and binary, must be in sync with the filesystem, and represents a single point of failure for the operating system. Later
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
-based configuration files became a popular choice for encoding configuration in text files. XML allows arbitrarily complex levels and nesting, and has standard mechanisms for encoding binary data. More recently, data serialization formats, such as
JSON JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other ser ...
, TOML, and
YAML YAML ( and ) (''see '') is a human-readable data-serialization language. It is commonly used for configuration files and in applications where data is being stored or transmitted. YAML targets many of the same communications applications as Exte ...
can serve as configuration formats. These three alternative formats can nest arbitrarily, but have a different syntax than the INI file. Among them, TOML most closely resembles INI, but the idea to make TOML deliberately compatible with a large subset of INI was rejected. The newest INI parsers however allow the same arbitrary level of nesting of
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
,
JSON JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other ser ...
, TOML, and
YAML YAML ( and ) (''see '') is a human-readable data-serialization language. It is commonly used for configuration files and in applications where data is being stored or transmitted. YAML targets many of the same communications applications as Exte ...
, offer equivalent support of typed values and
Unicode Unicode, formally The Unicode Standard,The formal version reference is is an information technology Technical standard, standard for the consistent character encoding, encoding, representation, and handling of Character (computing), text expre ...
, although keep the "informal status" of INI files by allowing multiple syntaxes for expressing the same thing.libconfini/README
/ref>


See also

* BOOT.INI *
MSConfig MSConfig (officially called System Configuration in Windows Vista, Windows 7, Windows 8 or Windows 10, or Windows 11 and Microsoft System Configuration Utility in previous operating systems) is a system utility to troubleshoot the Microsoft Windo ...
*
Sysedit Sysedit () is a specialized text/ASCII editor for core Microsoft Windows configuration files (such as , , , , and ). This executable is installed in the Windows system directory: (Windows 3.x and 9x editions) or (Windows NTx editions). Sysedit ...
* SYSTEM.INI * TOML, a very similar but more formally-specified configuration file format *
WIN.INI WIN.INI is a basic INI file that was used in versions of the Microsoft Windows operating environment up to Windows 3.11 to store basic settings at boot time. By default, all font, communications drivers, wallpaper, screen saver, and language set ...
*
Amiga Amiga is a family of personal computers introduced by Commodore in 1985. The original model is one of a number of mid-1980s computers with 16- or 32-bit processors, 256 KB or more of RAM, mouse-based GUIs, and significantly improved graphi ...
's
IFF In logic and related fields such as mathematics and philosophy, "if and only if" (shortened as "iff") is a biconditional logical connective between statements, where either both statements are true or both are false. The connective is bicon ...
files *
.DS_Store In the Apple macOS operating system, .DS_Store is a file that stores custom attributes of its containing folder, such as folder view options, icon positions, and other visual information. The name is an abbreviation of ''Desktop Services Store' ...
*
.properties .properties is a file extension for files mainly used in Java-related technologies to store the configurable parameters of an application. They can also be used for storing strings for Internationalization and localization; these are known as P ...


References

{{Reflist * Infobox - http://filext.com/file-extension/INI * Infobox - https://wikiext.com/ini


External links


libconfini's Library Function Manual
The particular syntax allowed by libconfini.
Cloanto Implementation of INI File Format
The particular syntax allowed by a parser implemented by Cloanto.
A very simple data file metaformat
INI parser tutorial in Apache Groovy. * Microsoft'
GetPrivateProfileString()
an
WritePrivateProfileStringA()
functions Configuration files Computer file formats