Convert Basic INI Key-Value Pairs to JSON
Learn how to convert simple INI key=value pairs without sections into a flat JSON object. Covers string, number, and boolean value coercion.
Detailed Explanation
From Key-Value Pairs to JSON
The simplest INI file contains key-value pairs at the top level, without any section headers. When converted to JSON, these become properties of a root object.
Example INI
name=MyApplication
version=2.5
debug=true
port=8080
host=localhost
Generated JSON
{
"name": "MyApplication",
"version": 2.5,
"debug": true,
"port": 8080,
"host": "localhost"
}
Type Coercion Rules
The converter automatically detects and converts value types:
| INI value | JSON type | Example |
|---|---|---|
| Unquoted text | String | host=localhost → "localhost" |
| Integer | Number | port=8080 → 8080 |
| Decimal | Number | version=2.5 → 2.5 |
| true/false/yes/no/on/off | Boolean | debug=true → true |
| Quoted string | String (preserved) | name="123" → "123" |
Important Notes
- Keys are preserved exactly as written --- no case conversion is applied
- Values with leading or trailing spaces are trimmed unless quoted
- Empty values (
key=) result in an empty string - Valueless keys (
keywithout=) can be treated astrueor empty string depending on options
Use Case
Converting a simple application configuration file (e.g., a legacy .ini settings file) into JSON for consumption by a modern Node.js or Python application that expects JSON configuration.
Try It — INI \u2194 JSON Converter
Related Topics
Convert INI Sections to Nested JSON Objects
Basic Conversion
Convert Nested INI Sections with Dot Notation to Deep JSON
Basic Conversion
INI Boolean Values to JSON: true/false, yes/no, on/off
Sections
Handling Quoted Values in INI to JSON Conversion
Sections
Convert php.ini Configuration to JSON
Common Files