INI to JSON
Convert INI configuration files to JSON and back.
About this tool
INI files are a simple, human-readable format for storing configuration settings used by applications, especially on Windows systems and legacy software. Converting between INI and JSON formats is essential when integrating legacy configuration systems with modern web applications or APIs that expect JSON input. This tool makes that conversion instant and transparent, eliminating manual transcription errors and saving development time.
To use this tool, paste your INI file into the input editor and click 'Convert to JSON' to see the formatted JSON output, or paste JSON and click 'Convert to INI' to reverse the process. The tool preserves the structure and hierarchy of your data—sections become JSON objects and key-value pairs become properties. Common use cases include migrating configuration files when upgrading applications, formatting settings for cloud deployments, or preparing data for API submissions that require JSON input.
Frequently Asked Questions
Code Implementation
import configparser
import json
def ini_to_json(ini_text: str) -> dict:
config = configparser.ConfigParser()
config.read_string(ini_text)
result = {}
for section in config.sections():
result[section] = dict(config[section])
# Top-level keys (DEFAULT section workaround)
for key, value in config.defaults().items():
result[key] = value
return result
ini_text = """
[database]
host = localhost
port = 5432
name = mydb
"""
data = ini_to_json(ini_text)
print(json.dumps(data, indent=2))Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.