INI file
Simple key-value configuration file format
An INI file is a plain-text configuration file format that organizes settings as key-value pairs grouped under named sections, using a simple syntax popularized by early Windows applications. Each section is marked with a bracketed name,…
Definition
An INI file is a plain-text configuration file format that organizes settings as key-value pairs grouped under named sections, using a simple syntax popularized by early Windows applications. Each section is marked with a bracketed name, and each line beneath it typically assigns a value to a key using an equals or colon separator. The format has no official specification body behind it, so exact syntax details such as comment characters and value quoting vary somewhat between the applications and libraries that read them.
Overview
INI files exist to give applications a human-readable, easily editable way to store configuration settings without requiring a database or a more complex structured format. The format's name derives from the ".ini" file extension used by early Windows software, where it became the standard way for programs to persist user preferences, application settings, and system configuration outside of compiled code, letting both the program and a human editing a text file agree on the same simple structure. Mechanically, an INI file consists of section headers written in square brackets, such as `[Database]`, followed by lines of the form `key=value` that belong to that section until the next section header appears. Some implementations support inline comments prefixed by a semicolon or hash character, nested or duplicate keys handled in implementation-specific ways, and value types that are always parsed as strings by the format itself, leaving type conversion, such as interpreting `true` as a boolean, to the application reading the file rather than to the format. INI differs from more structured configuration formats like JSON, YAML, or TOML in that it has no formal specification, no native support for nested data structures beyond one level of sections, and no standardized way to represent lists or complex types, which is exactly why formats like TOML were later created to bring INI's readability together with an unambiguous, formally specified grammar. Compared to XML, INI is far less verbose and easier for a non-technical user to hand-edit, at the cost of expressing only flat, shallow configuration data. In practice, INI files remain common for simple application settings, particularly in older Windows software, some Python libraries via the standard library's configparser module, PHP's php.ini configuration, and version-control tool configuration such as Git's `.gitconfig` and `.git/config` files, which follow an INI-like structure. Developers favor it for configuration that is genuinely flat and simple, where the overhead of a schema-validated format would be unnecessary. The format's core limitation is its lack of standardization: different parsers disagree on case sensitivity of keys, how to handle duplicate keys or sections, whether values can span multiple lines, and how special characters should be escaped, which makes an INI file written for one application not reliably portable to another's parser. For any configuration that needs nested structures, typed values, or strict interoperability across tools, formats such as TOML, YAML, or JSON are generally preferred today. Despite these gaps, INI's simplicity remains a real advantage for small, human-maintained configuration where a non-programmer might need to edit a value directly, since there is no indentation sensitivity to get wrong and no bracket-matching discipline required the way JSON demands. Many applications that started with INI decades ago have kept it for backward compatibility even as they added optional support for newer formats, which is why INI persists in legacy codebases long after more expressive alternatives became available.
Key Concepts
- organizes settings as key-value pairs grouped under bracketed sections
- plain-text format that is easy to read and hand-edit
- no official specification, leading to parser-specific syntax variations
- values are always strings; type conversion is left to the application
- commonly used historically in Windows application configuration
- still used by tools such as Git and Python's configparser module
Use Cases
Frequently Asked Questions
From the Blog
Python File I/O: Reading and Writing Files
Almost every real Python program reads or writes files — logs, configs, CSVs, JSON, reports. This guide covers text files, CSV, JSON, binary files, and the modern pathlib approach, with best practices for safe file handling.
Read More ProgrammingPython File Handling: Read and Write Files
Learn to read and write files in Python using open() and the with statement. Covers text and binary modes, reading line by line, appending, and safe file handling.
Read More ProgrammingUnderstanding Python Modules and Packages
A Python module is a single .py file and a package is a folder of modules. Learn how imports, __init__.py, and namespaces organize larger Python projects.
Read More ProgrammingNext.js App Router Explained: Routing, Rendering, Data
The App Router works on one rule: everything is a server component until you opt out, and the file system defines both the URL and the UI nesting. Learn how routes, layouts, server and client boundaries, data fetching and the caching layers fit together, so rendering and hydration behaviour stops being surprising.
Read More