World Library  
Flag as Inappropriate
Email this Article

INI file

Article Id: WHEBN0001908172
Reproduction Date:

Title: INI file  
Author: World Heritage Encyclopedia
Language: English
Subject: List of file formats, Windows Registry, Configuration file, SYSTEM.INI, WIN.INI
Collection: Computer File Formats, Configuration Files
Publisher: World Heritage Encyclopedia

INI file

The INI file format is an informal standard for configuration files for some platforms or software. INI files are simple text files with a basic structure composed of sections, properties, and values.[1]

In MS-DOS and 16-bit Windows platforms up through Windows ME, the INI file served as the primary mechanism to configure operating system and installed applications features, such as device drivers, fonts, startup launchers, and things that needed to be initialized in booting Windows. INI files were also generally used by applications to store their individual settings.[2]

In Windows NT Microsoft introduced the 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, and applications built on the .NET Framework use special XML .config files. The APIs still exist in Windows, however, and developers may still use them.

The name "INI file" comes from the commonly used filename extension, .INI, which stands for "initialization". Other common initialization file extensions are .CFG, .conf,[3] and .TXT,[4] especially 'config.txt' occurrences.

Linux and Unix systems also use a similar file format for system configuration. In addition, platform-agnostic software may use this file format for configuration. It is human-readable and simple to parse, so it is a usable format for configuration files that do not require much greater complexity.


  • Format 1
    • Keys (properties) 1.1
    • Sections 1.2
    • Case insensitivity 1.3
    • Comments 1.4
    • Varying features 1.5
      • Blank lines 1.5.1
      • Comments 1.5.2
      • Duplicate names 1.5.3
      • Escape characters 1.5.4
      • Global properties 1.5.5
      • Hierarchy 1.5.6
      • Name/value delimiter 1.5.7
      • Quoted values 1.5.8
      • Whitespace 1.5.9
    • Order of sections and properties 1.6
  • Example 2
  • Accessing INI files 3
  • File mapping 4
  • Alternatives 5
  • See also 6
  • References 7
  • External links 8


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.



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 the end of the file. Sections may not be nested.


Case insensitivity

Section and property names are not case sensitive in the Windows implementation.[5]


Semicolons (;) at the beginning of the line indicate a comment. Comment lines are ignored.

; comment text

Varying features

The INI file format is not well defined. Many programs support features beyond the basics described above. The following is a list of some common features, which may or may not be implemented in any given program.

Blank lines

Some rudimentary programs do not allow blank lines. Every line must therefore be a section head, a property, or a comment.


Some software supports the use of the number sign (#) as an alternative to the semicolon for indicating comments.

In some implementations, a comment may begin anywhere on a line, including on the same line after properties or section declarations. In others, including the WinAPI 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; the second occurrence may be ignored (and the value discarded); the second occurrence may override the first occurrence (discard the first value). 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 together, as if they occurred contiguously. Others may abort, or ignore some aspect of the INI file.

Escape characters

Some implementations also offer varying support for an escape character, typically with the backslash (\). 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 sequences escapes is also seen.

Common escape sequences
Sequence Meaning
\\ \ (a single backslash, escaping the escape character)
\0 Null character
\a Bell/Alert/Audible
\b Backspace, Bell character for some applications
\t Tab character
\r Carriage return
\n Line feed
\; Semicolon
\# Number sign
\= Equals sign
\: Colon
\x???? Unicode character with hexadecimal code point corresponding to ????

Global properties

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


Most commonly, INI files have no hierarchy of sections within sections. Some files appear to have a hierarchical naming convention, however. For section A, subsection B, sub-subsection C, property P and value V, they may accept entries such as [A.B.C] and P=V (Windows' xstart.ini), [A\B\C] and P=V (the IBM Windows driver file devlist.ini), or [A] and B,C,P = V (Microsoft Visual Studio file AEMANAGR.INI).

It is unclear whether these are simply naming conventions that an application happens to use in order to give the appearance of a hierarchy, or whether the file is being read by a module that actually presents this hierarchy to the application programmer.

Name/value delimiter

Some implementations allow a colon (:) as the name/value delimiter (instead of the equals sign).

Quoted values

Some implementations allow values to be quoted, typically using double quotes and/or apostrophes. This allows for explicit declaration of whitespace, and/or for quoting of special characters (equals, semicolon, etc.). The standard Windows function GetPrivateProfileString supports this, and will remove quotation marks that surround the values.


Interpretation of whitespace varies. Most implementations ignore leading and trailing whitespace around the outside of the property name. Some even ignore whitespace within values (for example, making "host name" and "hostname" equivalent). Some implementations also ignore leading and trailing whitespace around the property value; others consider all characters following the equals sign (including whitespace) to be part of the value.

Order of sections and properties

In most cases the order of properties in a section and the order of sections in a file is irrelevant, but implementations may vary.


Following is an example INI file for an imaginary program. It has two sections: one for the owner of the software, and one for a payroll database connection. Comments note who modified the file last and why an IP address is used instead of a DNS name.

; last modified 1 April 2001 by John Doe
name=John Doe
organization=Acme Widgets Inc.

; use IP address in case network name resolution is not working

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, the GetPrivateProfileString function retrieves a string from the specified section in an initialization file.

The following sample C program demonstrates reading property values from the above sample INI file (Let the name of configuration file be dbsettings.ini)


int main(int argc, _TCHAR *argv[])
  _TCHAR dbserver[1000];
  int dbport;
  GetPrivateProfileString("database", "server", "", dbserver, sizeof(dbserver) / sizeof(dbserver[0]), ".\\dbsettings.ini");
  dbport = GetPrivateProfileInt("database", "port", 143, ".\\dbsettings.ini");
  // N.B. WritePrivateProfileInt() does not exist
  return 0;

File mapping

Initialization File Mapping[7][8] creates a mapping between an INI file and the Registry. 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 above, 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:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\

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.

(Default) @USR:Software\oldprogs\inisettings\all
database USR:Software\oldprogs\inisettings\db

So, in this case the profile call for the [owner] section is mapped through to:

name John Doe
organization Acme Products

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 [database] section only, settings in the Registry are taken first followed by settings in the dbsettings.ini file on disk.


Starting with Windows 95, Microsoft began strongly promoting the use of Windows registry over the INI file.[9] INI files are typically limited to two levels (sections and properties) and do not handle binary data well

Later XML-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 and YAML can serve as configuration formats. These three alternative formats can nest arbitrarily, but have a more heavyweight syntax than the INI file.

See also


  1. ^ Microsoft TechNet: Configure an Ini File Item
  2. ^ Microsoft: Windows NT Workstation Resource Kit
  3. ^ .conf initialization files
  4. ^ See Trainz which uses config.txt for virtually all data base assets. (Trainsoptions.txt is that app's version of a .ini file)
  5. ^ "GetPrivateProfileString function". Microsoft Developer Network. Microsoft. Retrieved 2012-06-02. 
  6. ^ Apache Documentation for org.apache.commons.configuration.HierarchicalINIConfiguration, The Apache Software Foundation
  7. ^ Initialization Files and the Registry, Windows NT Workstation Resource Kit, Microsoft TechNet
  8. ^ Administering the NT Registry, Managing the Windows NT Registry, Paul Robichaux, O'Reilly Media
  9. ^ The System Registry

External links

  • RudeConfig™ Open Source C++ Config File Library: INI parser written in C++.
  • qLibc - General C Library: INI parser written in C.
  • ConfigParser — Configuration file parser: INI parser written in Python.
  • clinicap (CLiki): INI parser/generator written in Common Lisp.
  • A very simple data file metaformat: INI parser tutorial in Groovy.
  • Cloanto Implementation of INI File Format: The particular syntax allowed by a parser implementation called Cloanto.
  • Bohr: File format: The particular syntax with hierarchical extensions allowed by a parser implementation called Nickel in a project called Bohr.
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.