What is an INI File? — Configuration File Format Explained
Definition
An INI file is a simple configuration file format originally from early Windows software that organizes settings as key-value pairs grouped under named sections. The format is human-readable and easy to edit manually. INI files have no formal specification, leading to slight variations between implementations, but the basic structure of [section], key = value, and # or ; comments is universally understood. INI format is used in Windows configuration files, PHP's php.ini, Git's .gitconfig, Python's configparser, and many other tools.
How It Works
An INI file consists of sections (names in square brackets like [database]) and key-value pairs under each section (key = value). Keys and values are separated by = or :. Comments start with # or ;. Sections group related settings and allow the same key name to appear in different sections with different values. There is no support for nested structures, arrays, or data types beyond strings — all values are plain text that applications parse themselves. The global section (before any section header) is supported by some parsers.
Common Use Cases
- ▸PHP configuration in php.ini for settings like memory_limit and upload_max_filesize
- ▸Git configuration in ~/.gitconfig for user name, email, and aliases
- ▸Windows registry-like configuration for legacy Windows applications
- ▸Python configparser-based application configuration
- ▸Database connection settings in Django's legacy my.cnf-style configs
Example
[server] host = localhost port = 8080 debug = true [database] host = db.example.com port = 5432 name = myapp user = appuser password = secret [logging] level = INFO file = /var/log/app.log
Related Tools
FAQ
- What is the difference between INI, TOML, and .env files?
- INI files have sections and key-value pairs but no type system. TOML adds explicit types, arrays, inline tables, and strict parsing rules, making it better for complex configs. .env files have no sections and are simple KEY=VALUE pairs for environment variable injection.
- What is a .properties file?
- A .properties file is a Java convention similar to INI with no sections — just key=value pairs with # comments. It is used extensively in Java applications, Spring Boot, and Android for i18n resource bundles. Unlike INI, there is no concept of sections.
- Should I still use INI for new projects?
- For new projects, prefer TOML (if you need sections and types) or YAML (if the tooling requires it). INI is fine for simple legacy systems and tools that already use it, but the lack of a standard and type system make it less suitable for complex modern applications.