Paste INI content and click Parse
Parse .ini / .cfg config files and convert to JSON
β devnestioPaste INI content and click Parse
INI File Parser reads and displays INI configuration files in a structured format. Paste any INI file to see its sections and key-value pairs parsed into a clean tree view, with type inference (string, number, boolean, list). Also converts INI to JSON and validates the syntax. Useful for understanding configuration files for PHP, Python (ConfigParser), Git, Ansible, and Windows Registry exports.
INI (Initialization) is a simple configuration file format originating from DOS and Windows. Structure: sections in square brackets ([section]), key-value pairs separated by = or :, comments starting with ; or #. The format has no official specification β different parsers handle edge cases differently (multi-line values, escaped characters, duplicate keys, section nesting). Python's configparser module, PHP's parse_ini_file(), and Git's config format all use INI-like syntax with slight variations.
INI vs TOML vs YAML for config files: INI is the simplest β good for flat or one-level-nested config. No support for arrays or nested objects natively (though some parsers add extensions). TOML has a formal spec, types, and nested tables β better for complex configs. YAML is the most expressive but has notorious parsing gotchas (indentation errors, type coercion surprises like 'yes' β boolean). For new developer tool configs, TOML is the modern choice. For legacy system compatibility, INI is often required.
Simple INI
Result: [database]\nhost=localhost\nport=5432 β {database: {host:'localhost', port:5432}}
Git config
Result: [core]\nrepositoryformatversion = 0\nfilemode = true β {core: {repositoryformatversion:0, filemode:true}}
PHP php.ini
Result: [PHP]\nmemory_limit = 128M\nerror_reporting = E_ALL β parsed with PHP-style values
What is the INI file format and where is it used?
INI files are simple configuration files with sections ([section]) and key=value pairs. Origins: Windows 3.x system initialization files (win.ini, system.ini) β hence 'INI'. Current uses: Git configuration (~/.gitconfig, .git/config). Python: ConfigParser module (common for Django settings, Ansible inventory). PHP: php.ini (PHP configuration), parse_ini_file() function. Windows: .ini files still used for some applications. MySQL: my.cnf (uses INI format). Ansible: inventory files use INI format. Pip: pip.ini/pip.conf.
What is the difference between INI and TOML?
INI: no official spec (behavior varies by parser), no support for typed values beyond strings (types inferred or handled in code), no arrays or nested structures (extensions like [section.subsection] vary), comments with ; or #. TOML: has a strict specification (toml.io), typed values (integers, floats, booleans, dates, datetime), arrays ([1,2,3]) and tables, string types (basic, literal, multiline), standardized. For new projects: prefer TOML for structured config. Use INI when the tool/system requires it (git config, php.ini) or for very simple flat configs.
How does Python's ConfigParser handle INI files?
Python's configparser module reads INI-style config files: config = configparser.ConfigParser(); config.read('config.ini'). Access: config['section']['key'] or config.get('section', 'key', fallback='default'). Features: DEFAULT section (values inherited by all other sections), interpolation (%(value)s references within the same section), type methods (config.getboolean(), config.getint(), config.getfloat()). Gotcha: keys are automatically lowercased by default (can be overridden). Duplicate keys: last value wins. For Python web projects, python-decouple or pydantic-settings are more powerful alternatives.
What is the format of git config files?
Git config files use INI-like syntax: section headers [section] or [section "subsection"], key = value pairs. Locations: system (/etc/gitconfig), user (~/.gitconfig or ~/.config/git/config), repository (.git/config). Example: [user] / name = Alice Smith / email = alice@example.com. [core] / editor = vim / autocrlf = input. [alias] / st = status / lg = log --oneline --graph. [remote "origin"] / url = https://github.com/user/repo.git / fetch = +refs/heads/*:refs/remotes/origin/*. Read/write: git config --global user.name 'Alice' or git config --list to view all.
How do I convert INI to JSON programmatically?
Python: import configparser, json; config = configparser.ConfigParser(); config.read('config.ini'); result = {s: dict(config[s]) for s in config.sections()}; print(json.dumps(result, indent=2)). JavaScript: use the ini npm package: import ini from 'ini'; const config = ini.parse(fs.readFileSync('config.ini', 'utf-8')); console.log(JSON.stringify(config, null, 2)). Note: values are strings by default β add type coercion if needed. For complex configs with array-like repeated keys, the behavior varies by parser β test thoroughly.