INI to JSON Converter

Convert classic INI files (php.ini, MySQL my.cnf, Git .gitconfig, Windows .ini) to JSON, or take a JSON object and emit a clean INI document. Sections map to nested objects, keys keep their case, comments are stripped on parse, and repeated keys collect into arrays so nothing is lost.

How to use the INI to JSON Converter

INI→JSON: paste any INI document. Section headers like [server] become object keys; key=value pairs become properties; lines starting with ; or # are comments and skipped. Repeated keys (common in MySQL configs) collect into a JSON array. Toggle key-lowercasing for case-insensitive sections, and toggle type coercion to keep everything as strings if you need exact preservation.

JSON→INI: paste a flat or one-level-nested JSON object. Top-level scalar properties become orphan key=value pairs; top-level object properties become sections; arrays emit as repeated keys.

About INI to JSON Converter

The INI format is older than the web and survives because it’s easy for humans to edit and for software to parse in any language. PHP’s php.ini, MySQL’s my.cnf, Git’s .gitconfig, Windows .ini files, Python’s ConfigParser, and many CI tools all use variants of the same syntax: optional section headers in square brackets, key=value pairs, and # or ; comments. The catch is that “INI” is not a single spec — each tool has subtle differences (whether quoted strings are allowed, how to handle = inside values, whether sections can nest, what coerces to a boolean).

This converter targets the common subset that round-trips between most tools. It assumes one level of section nesting, treats values as strings unless coercion is enabled, and collects repeated keys into arrays (the way MySQL’s configs use them). For deeper structure (nested sections, dotted keys), convert to JSON, manipulate, and convert back — INI was never designed for arbitrary depth.

Common use cases

  • Migrating php.ini to a config-management format like Ansible variables or a JSON-driven deployer.
  • Reading a MySQL my.cnf programmatically via the JSON output — simpler than writing an INI parser in your build script.
  • Generating .gitconfig fragments from a JSON template stored in your dotfiles repo.
  • Auditing a Windows .ini export by converting to JSON and diffing against a reference.

Frequently asked questions

Are nested sections supported?

Headers with dots like [a.b.c] are treated as single-level sections by default (key is a.b.c). For true nesting, edit the JSON output manually \xE2\x80\x94 INI itself doesn\xE2\x80\x99t standardise nested sections.

How are quoted values handled?

Double-quoted values are unquoted on parse (preserving any escaped characters). Other quoting conventions vary by tool and may need manual cleanup.

What about MySQL\xE2\x80\x99s <code>!includedir</code> directives?

They\xE2\x80\x99re passed through as literal keys. This tool doesn\xE2\x80\x99t follow includes; that would need filesystem access.