INI ↔ JSON Converter

Convert between INI configuration files and JSON format with section handling, comment preservation, and real-time validation.

About This Tool

The INI to JSON Converter is a free, browser-based utility that transforms data between INI configuration file format and JSON in real time. Whether you are working with php.ini, MySQL's my.cnf, Git configuration, .desktop entry files, or any other INI-style configuration, this tool lets you quickly convert to JSON for programmatic processing, API consumption, or interoperability with modern tooling that expects JSON.

INI (Initialization) files have been one of the most widely used configuration formats since the early days of computing. The format is human-readable and simple: sections are denoted by square brackets [section], key-value pairs use an equals sign key=value, and comments start with a semicolon or hash character. Despite its simplicity, INI lacks a formal specification, which means different applications handle edge cases differently --- this tool supports the most common conventions including nested sections via dot notation, inline comments, valueless keys, and duplicate key handling.

JSON (JavaScript Object Notation) is the standard data interchange format for web applications and APIs. Converting INI to JSON is useful when you need to consume configuration in a Node.js or Python application, store settings in a database, or validate config structure programmatically. The reverse direction --- JSON to INI --- is equally useful when you need to generate configuration files for legacy applications, PHP, MySQL, or system services. If you work with other configuration formats, you might also find the JSON ↔ YAML converter or the TOML ↔ JSON converter helpful. For general JSON work, check out the JSON Formatter.

All processing happens entirely in your browser. Your configuration data never leaves your machine --- there are no server round-trips, no logging, and no third-party services involved. This makes it safe to use with production configuration files containing sensitive paths, credentials placeholders, or internal hostnames.

How to Use

  1. Select the conversion direction using the INI → JSON or JSON → INI toggle button at the top.
  2. Paste your INI content or JSON into the Input panel on the left. Output updates automatically in the right panel.
  3. Choose a Preset from the dropdown (php.ini, my.cnf, Git config, Desktop entry) to load a real-world sample.
  4. Adjust JSON Indent (2 or 4 spaces) to control the output formatting when converting to JSON.
  5. Toggle Preserve Comments to include INI comments as special __comment_* keys in JSON output (and restore them when converting back).
  6. Set Duplicate Keys to “Last wins” (default INI behavior) or “As array” to collect multiple values for the same key.
  7. Click Copy or press Ctrl+Shift+C to copy the output to your clipboard. Use Swap to move the output back to input for round-trip conversion.

Popular INI / JSON Conversion Examples

View all INI / JSON conversion examples →

FAQ

What INI features are supported?

The parser supports sections ([section]), nested sections via dot notation ([section.subsection]), key=value pairs, comments (lines starting with ; or #), inline comments, valueless keys, quoted values (single and double quotes), and automatic type coercion for booleans (true/false/yes/no/on/off) and numbers.

How are INI sections converted to JSON?

Each INI section becomes a nested JSON object. The section name becomes the key, and all key-value pairs within that section become properties of the nested object. Nested sections using dot notation (e.g., [section.subsection]) create deeply nested JSON objects.

How are comments handled during conversion?

By default, comments are stripped during conversion. When 'Preserve Comments' is enabled, comments are stored as special keys like __comment_0, __comment_1, etc. in the JSON output. When converting back to INI, these keys are restored as comment lines.

How are duplicate keys handled?

INI files sometimes contain duplicate keys within the same section. The 'Last wins' option (default) keeps only the last value, matching standard INI behavior. The 'As array' option collects all values into a JSON array, which is useful for configuration files that use repeated keys for lists.

Can I convert JSON back to INI?

Yes. Use the direction toggle to switch to JSON to INI mode. The converter generates proper INI sections from nested JSON objects, and handles arrays by repeating the key for each value. Deeply nested objects use dot notation for section names.

Is my data safe?

Yes. All parsing and conversion runs entirely in your browser using JavaScript. No data is sent to any server. You can verify this by checking the Network tab in your browser's developer tools while using the tool. It is safe to use with production configuration files.

What types of INI files can I convert?

The tool handles all common INI-style configuration files including php.ini, MySQL my.cnf, Git config (.gitconfig), Windows INI files, Samba configuration (smb.conf), systemd unit files, .desktop entry files, and Python configparser-compatible files. Any file using the [section] / key=value convention will work.

Related Tools