
Download free sample INI and CFG files instantly — Windows-style, Python configparser, Git config, PHP-style, and more. Valid syntax, realistic content, generated entirely in your browser.
Real-world config templates — for testing parsers, app startup logic, and config loaders
Dialect-specific syntax — test your parser against style variants it may or may not handle
Special cases — duplicate keys, deep nesting, unusual values, and minimal valid files
Configure dialect, template, comment style, and formatting options
| Feature | Standard (Windows) | Python configparser | Git config | PHP php.ini |
|---|---|---|---|---|
| Comment char | ; or # | # or ; | # or ; | ; only |
| Key=value spacing | key=value or key = value | key = value (space required) | key = value | key = value |
| Section headers | [Section] | [section] (lowercased) | [section "subsection"] | [section] |
| Subsections | ✗ Not standard | ✗ Not standard | ✓ [sec "sub"] | ✗ Not standard |
| Multiline values | ✗ | ✓ Indent continuation | ✗ | ✗ |
| DEFAULT section | ✗ | ✓ Inherited by all | ✗ | ✗ |
| Variable interpolation | ✗ | ✓ %(key)s | ✗ | ✗ |
| Quoted values | Optional | Optional | ✓ Required for spaces | Optional |
| Boolean values | 1/0 or true/false | yes/no, true/false, on/off, 1/0 | true/false | On/Off, 1/0, true/false |
What is an INI file and what reads it?
An INI file is a plain-text configuration file format that organizes settings into named sections. Each section is a heading in square brackets like [database], followed by key-value pairs like host = localhost. The format originated with early versions of Windows and MS-DOS, which used it for application settings — Windows itself still uses .ini files for some system configuration.
Today INI files are read by Python's built-in configparser module, PHP's parse_ini_file() function, .NET's IConfiguration system, many game engines, desktop applications, and tools like MySQL, Ansible, and Supervisor. The .cfg, .conf, and .config extensions are often used interchangeably for the same format.
What is the difference between .ini, .cfg, and .conf files?
There is no technical difference — all three extensions refer to the same class of plain-text key-value configuration files. The choice of extension is purely conventional: .ini is most common in Windows software and games; .cfg is widely used in game engines (Source Engine, Quake), Python tools, and some Unix programs; .conf is the most common extension on Linux/Unix systems (Nginx, Apache, MySQL, SSH all use .conf). The Custom Generator on this page lets you choose whichever extension your tool or project expects.
What is Python configparser and how does it differ from standard INI?
Python's configparser module reads INI-style files but adds several extensions. It supports a special [DEFAULT] section whose values are automatically inherited by every other section — useful for shared base configuration. It supports multiline values by indenting continuation lines. It supports variable interpolation using %(key)s syntax, so a value can reference another key in the same section. Keys are lowercased by default (so Host and host are the same key). Boolean values are flexible: yes, no, true, false, on, off, 1, and 0 all work. Standard Windows INI parsers don't support any of these extensions.
How does Git config format differ from standard INI?
Git config files use a superset of INI format with two key differences. First, they support subsections — a section header can include a quoted subsection name: [remote "origin"] or [branch "main"]. This allows multiple instances of the same section type (multiple remotes, multiple branches) without key collisions. Second, string values that contain spaces must be double-quoted. Git config is read by git config and the underlying libgit2 library, and the three levels (system, global, local) are merged at read time with local taking highest priority.
How do I read an INI file in Python?
Python's standard library includes configparser which reads INI files directly. The basic pattern is: import configparser; config = configparser.ConfigParser(); config.read('sample.ini'). Access values with config['section']['key'] or config.get('section', 'key'). Use config.getint(), config.getfloat(), and config.getboolean() to automatically coerce types. The config.sections() method returns a list of all section names. If a key isn't found, get() accepts a fallback: config.get('section', 'key', fallback='default_value').
Can INI files have duplicate keys or sections?
It depends on the parser. The INI format has no official specification, so behavior varies. Python's configparser by default raises a DuplicateSectionError or DuplicateOptionError for duplicates, but you can pass strict=False to allow them (the last value wins). PHP's parse_ini_file() silently uses the last value. Windows Registry-style parsers often use the first value and ignore subsequent duplicates. The Duplicate Keys edge case file on this page is specifically designed to test how your parser handles this ambiguity.
What is variable interpolation in INI files?
Variable interpolation lets a value reference another key's value using a substitution syntax. Python configparser uses %(key)s — for example, if base_dir = /var/www is defined, then log_dir = %(base_dir)s/logs resolves to /var/www/logs. This avoids repeating paths and makes global base values easy to change in one place. The interpolation is done at read time by the parser, so the raw file still contains the %(key)s placeholder text — the file itself has no idea it's being interpolated. Standard Windows INI parsers don't support this; it's a Python configparser extension.
What is a DEFAULT section and how does inheritance work?
In Python configparser, a [DEFAULT] section (case-insensitive) defines fallback values that are automatically available in every other section. If [DEFAULT] contains timeout = 30, then any section that doesn't define its own timeout key will return 30 when that key is accessed. Sections can override DEFAULT values by defining the same key — the section-level value takes precedence. This pattern is useful for multi-environment configs where most settings are shared but a few differ per environment. The DEFAULT section does not appear in the config.sections() list; it's treated as a special namespace.
