Overview
Introduction
Plenty of legacy tools, PHP's php.ini, Windows application settings, older game servers, still ship configuration as INI text, but modern tooling almost always wants JSON.
This tool parses that INI syntax directly into a JSON object so it can be consumed, diffed, or transformed with the rest of a JSON-based toolchain.
What Is INI to JSON Converter?
An INI parser that reads [section] headers, key=value (or key: value) assignment lines, and ;/# comments, and builds a JSON object where each section becomes a nested object and each key becomes a property inside it.
Keys that appear before any [section] header are treated as an implicit top-level section and placed directly on the root JSON object.
How INI to JSON Converter Works
The parser reads the INI text line by line, skipping blank lines and comment lines, and switches the "current object" pointer to a fresh nested object whenever it encounters a [section] header.
Every key=value or key: value line is assigned into whichever object is currently active, with true/false and numeric-looking values converted to their JSON types and everything else kept as a string.
When To Use INI to JSON Converter
Use it when you need to read a legacy application's INI config file from JavaScript/TypeScript code or any JSON-based pipeline.
It's also useful for quickly diffing two INI files by converting both to JSON first.
Often used alongside JSON to INI Converter, TOML to JSON Converter and Properties to JSON Converter.
Features
Advantages
- Correctly separates an implicit global section from named [section] blocks.
- Converts obvious booleans and numbers to their JSON types instead of leaving everything as strings.
- Handles both ; and # comment styles, the two conventions different INI dialects use.
Limitations
- Only one level of section nesting is supported, matching classic INI itself; there's no deeper nested-section syntax to parse.
- INI has no native array syntax, so repeated keys or list-like values aren't automatically collected into a JSON array.
Examples
Best Practices & Notes
Best Practices
- Confirm whether your source INI uses = or : for assignment, this parser accepts both.
- Check the output types for values that look numeric but are meant to stay strings (like a zero-padded ID) before relying on them downstream.
- Use this before diffing two INI config files, JSON diff tools are far more readable than a raw INI text diff.
Developer Notes
Type coercion happens per-value with two lightweight checks, an exact match against "true"/"false" and a Number()-based numeric test, rather than a full INI type grammar, since real-world INI files rely on convention rather than a formal type system for their values.
INI to JSON Converter Use Cases
- Reading a legacy php.ini or application settings file into a JSON-based build script
- Diffing two versions of an INI config file by comparing their JSON representations
- Migrating a legacy INI-based config to a JSON or YAML-based configuration system
Common Mistakes
- Expecting a doubly-nested [section.subsection] style header to produce nested JSON objects; INI itself doesn't support that syntax.
- Assuming a zero-padded numeric string (like "0042") stays a string; the type coercion may convert obviously numeric values.
- Forgetting that repeated keys within a section aren't collected into an array, later occurrences simply overwrite earlier ones.
Tips
- Use JSON to INI afterward to confirm the round trip preserves your data as expected.
- For config files with deeper nesting than INI supports, consider whether the source is really TOML or YAML and use the matching converter instead.