INI to JSON: Parse Configuration Files for Modern Applications
INI files are among the oldest configuration formats — simple, human-readable, and still used by Python's configparser, PHP, game engines, and legacy Windows tools. When building a modern application or migration pipeline, converting INI to JSON lets you work with the config in JavaScript, REST APIs, or any language with a JSON library.
All INI values are strings in JSON output — cast to numbers or booleans in your code where needed.
INI Format Structure
[SectionName] headers create top-level objects. Key = value pairs (separated by = or :) inside a section become that object's properties. Comment lines starting with ; or # are stripped. Properties before the first section become root-level JSON properties. Inline comments (value ; comment) are also stripped.
Dotted Section Names
Some INI implementations support dotted section names like [database.pool]. This converter treats dots as path separators and creates nested objects: [database.pool] with max = 10 becomes { database: { pool: { max: '10' } } }. This mirrors how Python's configparser handles hierarchical configs.
Reading INI in Python, PHP, and Node.js
Python: configparser.ConfigParser() reads INI natively. PHP: parse_ini_file() returns an array. Node.js has no built-in INI parser — use the ini npm package or convert to JSON with this tool and use require('./config.json'). Go: use the gopkg.in/ini.v1 package.
Practical Examples
Migrating a Python App from INI to JSON Config
Convert a Python configparser INI file to JSON for use in a Node.js service.
- 1.Paste the .ini or .cfg config file
- 2.Review the JSON output — sections become nested objects
- 3.Save as config.json
- 4.Update your Node.js code to use require('./config.json') instead of parsing INI
What Gets Converted
- [sections] → nested JSON objects
- key = value pairs → JSON string properties
- ; and # comments → stripped from output
- Dotted [section.sub] → nested objects
- Inline comments on value lines → stripped
Good Use Cases
- Migrating legacy INI configs to JSON for modern apps
- Reading Windows .ini or .cfg files in JavaScript
- Converting game engine configs (Godot, Unity) for tooling
- Processing Python configparser output in non-Python services
Frequently Asked Questions
What is the INI file format?
INI is a simple configuration file format from Windows. It consists of sections (denoted by [SectionName]) containing key-value pairs (key = value). Comments start with ; or #. INI is used by Python's configparser, PHP's parse_ini_file(), Windows Registry export, many game engines, and legacy system tools.
How are sections converted to JSON?
Each [section] becomes a nested JSON object. Key-value pairs inside the section become properties of that object. Key-value pairs before any section (at the top of the file) become root-level properties.
Are values typed (numbers, booleans)?
No. INI has no type system — all values are strings. The converter preserves them as JSON strings. If you need typed values, parse them in your code after reading the JSON (e.g., parseInt(config.database.port) or config.server.debug === 'true').
Does this support dotted section names like [database.pool]?
Yes. Dotted section names are treated as nested paths. [database.pool] with key max = 10 becomes { database: { pool: { max: '10' } } }.