UtilityKit

500+ fast, free tools. Most run in your browser only; Image & PDF tools upload files to the backend when you run them.

JSON INI Converter

Convert JSON objects to INI and parse INI back to JSON.

About JSON INI Converter

INI is the oldest config format still in active use — php.ini, my.cnf, .gitconfig, and hundreds of legacy apps all use it. Sections in square brackets contain flat key=value pairs. Converting it to and from JSON without a custom script is fiddly, especially when dealing with section-less global keys, both ; and # comment styles, and the absence of any formal spec. This converter handles PHP, MySQL, Git, and Python configparser conventions. Each section becomes a top-level JSON object key. Section-less keys are placed at the JSON root, matching how PHP and Python's configparser both interpret them. Comment stripping, quoted value handling, and optional boolean and number coercion are configurable. Sysadmins with production passwords in my.cnf and developers with API tokens can use this safely — no data leaves the browser.

Why use JSON INI Converter

[section] → JSON Object

Each INI [section] header becomes a top-level JSON key whose value is an object of that section's key-value pairs. The mapping is always predictable: [database] becomes {"database": {"host": ..., "port": ...}} — no ambiguity.

Comment Stripping (Both ; and #)

Recognises both Unix-style # and Windows/PHP-style ; comment markers and removes them when converting to JSON. A warning is shown that comments cannot be reconstructed, so you can preserve them manually if needed.

Quoted Value Handling

Values wrapped in double or single quotes are unwrapped when parsing. On output to INI, values containing spaces, special characters, or ambiguous patterns are automatically re-wrapped in quotes to ensure the config is parsed correctly.

Boolean and Number Coercion

Strings like "true", "1", and "yes" can be converted to real JSON booleans and numbers with configurable coercion, or kept as strings to preserve original config behaviour. Toggle based on how your downstream code reads the values.

Section-less Keys Supported

Top-level keys appearing before any [section] header are placed at the JSON root object, matching how PHP's parse_ini_file() and Python's configparser both interpret global keys. No data is lost and no extra wrapper object is added.

Browser-Local Privacy

Database passwords inside my.cnf, authentication tokens in app.ini, and API keys in any config file stay entirely on your machine. No upload, no logging, and no network request is made during conversion.

How to use JSON INI Converter

  1. Pick the conversion direction: INI to JSON or JSON to INI
  2. Paste the source config content into the input panel
  3. Choose the comment style for INI output: semicolons (;) or hash marks (#)
  4. Toggle boolean and number type coercion to control whether 'true', '1', or 'yes' become real JSON booleans and numbers
  5. Decide how to handle deeply nested JSON (2+ levels) — flatten with dot-notation section names or limit to one level
  6. Copy the result or download it as a .ini or .json file

When to use JSON INI Converter

  • Converting a MySQL my.cnf or php.ini configuration to JSON for programmatic inspection or modification
  • Migrating a legacy INI-based application configuration to a modern JSON config format
  • Generating INI config files from JSON data produced by an API or configuration management tool
  • Reading a .gitconfig or .npmrc in JSON format to extract specific settings for a script
  • Porting a Windows application's INI settings into a cross-platform JSON configuration system
  • Comparing two INI configs by converting both to JSON and using a JSON diff tool

Examples

MySQL my.cnf → JSON

Input: [client] port = 3306 socket = /tmp/mysql.sock [mysqld] user = mysql bind-address = 127.0.0.1 max_connections = 200

Output: { "client": { "port": 3306, "socket": "/tmp/mysql.sock" }, "mysqld": { "user": "mysql", "bind-address": "127.0.0.1", "max_connections": 200 } }

JSON → app.ini

Input: { "app": { "name": "reporter", "debug": true }, "smtp": { "host": "mail.local", "port": 587 } }

Output: [app] name = reporter debug = true [smtp] host = mail.local port = 587

Section-less keys

Input: version = 2 log_level = info [server] port = 8080

Output: { "version": 2, "log_level": "info", "server": { "port": 8080 } }

Tips

  • INI does not support nesting beyond one level — JSON objects two or more levels deep get flattened with dot notation in the section name when converting to INI.
  • Comments in INI are valuable documentation for non-obvious config values; copy them out before converting if the reasoning behind a value matters.
  • Keep values that look numeric but should stay strings — ZIP codes, phone numbers, account numbers — by turning off type coercion before conversion.
  • INI files lack a formal specification — double-check that your output works with your specific reader (PHP, Python configparser, or Git) after conversion.
  • Round-tripping JSON arrays through INI is inherently lossy — INI represents arrays as repeated keys, which not all parsers handle identically.

Frequently Asked Questions

What does an INI section become in JSON?
Each [sectionName] header becomes a top-level key in the JSON object. The key-value pairs under that section become properties of a nested object. For example, [database] with host=localhost becomes {"database": {"host": "localhost"}}.
Are comments preserved when converting INI to JSON?
No. Comments (lines starting with ; or #) are stripped when converting to JSON because JSON has no comment syntax. The tool shows a warning before conversion. Copy comments to a separate file if they document important configuration decisions.
How are nested objects (more than one level) handled?
INI only supports one level of nesting (section → key). Deeper JSON structures are represented with dot-notation section names when converting JSON to INI — for example, {"db": {"host": {"primary": "..."} } } would produce a [db.host] section.
Will boolean values like 'yes' or '1' become real JSON booleans?
Only when type coercion is enabled. With coercion on, "true", "false", "yes", "no", "1", and "0" are converted to their JSON equivalents. With coercion off, all values remain strings — safer for values that look boolean but should stay as strings.
Does it work for php.ini and my.cnf style configs?
Yes. Both use INI-like formats that the converter handles. PHP uses ; for comments and my.cnf uses both ; and #. The converter recognises both comment styles and handles quoted values and unquoted strings from both formats.
What if my INI has duplicate keys in the same section?
INI has no formal spec for duplicates. The converter uses last-value-wins semantics by default — if the same key appears twice in a section, the second value overwrites the first. Some parsers (like Python's configparser) do the same.
Are values with spaces wrapped in quotes automatically?
Yes. When converting JSON to INI, values containing spaces, comment characters, or other special characters are automatically wrapped in double quotes in the output to ensure the INI is parsed correctly by target readers.
Is my data uploaded anywhere?
No. The conversion runs entirely in your browser using JavaScript string processing. No data is sent to any server. Production database passwords, API keys, and other secrets in your config files are safe to paste.

Explore the category

Glossary

[Section] header
A line in an INI file containing a name enclosed in square brackets, such as [database]. All key-value pairs that follow belong to this section until the next section header appears.
Key-value pair
The fundamental unit of an INI file: a key name, an equals sign (or colon in some dialects), and a value — for example host=localhost or port=3306.
Comment marker (; / #)
A character that starts a comment line in INI files. Semicolons are used by PHP's php.ini and Windows apps; hash marks are used by Unix-style configs like my.cnf and .gitconfig. Both are stripped during JSON conversion.
Quoted string
A value enclosed in double or single quotes in an INI file, allowing spaces and special characters. Quotes are stripped when parsing and re-added on output only when the value requires them.
Section-less / global keys
Key-value pairs appearing before the first [section] header in an INI file. These are treated as belonging to the global scope and are placed at the top level of the JSON output object.
Configparser dialect
The specific INI flavour used by Python's built-in configparser module, which supports interpolation (%(key)s references), multiline values using indentation, and both = and : as key-value separators.