INI to YAML Converter
Convert INI configuration files into clean, structured YAML. Section headers become top-level keys, with key-value pairs nested underneath.
Use Cases
- Config Modernization — Move from INI config files to YAML format
- Python to YAML Migration — Convert Python
configparserfiles to YAML - Cross-Platform — Bridge INI-based config into YAML-native workflows
- Documentation — Generate readable YAML from INI configuration files
Example
Input (INI):
[database]
host=localhost
port=5432
pool.maxActive=10
[app]
name=MyApp
debug=true
[logging]
level=INFOOutput (YAML):
database:
host: localhost
port: "5432"
pool:
maxActive: "10"
app:
name: MyApp
debug: "true"
logging:
level: INFOThe INI Format: A Brief History
INI files originated in the 1990s as the standard configuration format for Windows applications. The format is simple: sections delimited by [brackets] contain key=value pairs. Despite its age, INI remains widely used in:
- Python's
configparserstandard library module - PHP
php.iniconfiguration files systemdservice unit files on Linuxsetup.cfgandtox.iniin Python packaging- Legacy enterprise applications
While INI is easy to write, it lacks YAML's nested structure, type support, and cross-platform tooling ecosystem. Converting from INI to YAML unlocks modern configuration management workflows.
INI vs YAML: Key Differences
| Aspect | INI | YAML |
|---|---|---|
| Structure | Flat sections with key-value pairs | Arbitrary nesting depth |
| Types | All values are strings | Strings, numbers, booleans, nulls, lists, maps |
| Comments | ; or # at line start |
# anywhere |
| Lists | Not natively supported | Native list syntax with - |
| Multi-line | Not supported | ` |
| Ecosystem | Limited to config files | Docker, K8s, CI/CD, Ansible, etc. |
Nested Key Reconstruction (Dot Notation to Indentation)
The converter recognizes dot-separated keys within INI sections and reconstructs them as nested YAML. This is one of the most powerful features, as it bridges INI's flat format with YAML's hierarchy.
For example, pool.maxActive=10 inside [database] becomes:
database:
pool:
maxActive: "10"The dot splitting rules are:
- Split the key name on dots
- The last segment becomes the leaf key
- All preceding segments create nesting levels
- Numeric values are quoted to preserve them as strings
- Multiple dots produce multiple nesting levels
Use Case: Python configparser Migration
Python's configparser is the standard library for INI files. Migrating to YAML unlocks PyYAML integration and better cross-language portability:
[celery]
broker_url=redis://localhost:6379/0
result_backend=redis://localhost:6379/0
task_serializer=json
result_serializer=json
accept_content=json
timezone=UTC
enable_utc=true
worker_max_tasks_per_child=1000Output (YAML):
celery:
broker_url: redis://localhost:6379/0
result_backend: redis://localhost:6379/0
task_serializer: json
result_serializer: json
accept_content: json
timezone: UTC
enable_utc: "true"
worker_max_tasks_per_child: "1000"Use Case: Legacy System Modernization
Many enterprise systems still use INI configuration files. Converting to YAML is often the first step in a modernization pipeline:
- Export INI config from legacy application
- Convert to YAML with this tool
- Import into Kubernetes ConfigMaps or Ansible playbooks
- Version control the YAML in your infrastructure repository
Use Case: PHP INI to Structured Config
PHP applications rely on php.ini for runtime settings. Converting to YAML helps document and analyze configuration:
[PHP]
display_errors=Off
error_reporting=E_ALL
max_execution_time=30
memory_limit=128M
upload_max_filesize=2M
post_max_size=8M
[session]
session.save_handler=files
session.save_path=/tmp
session.use_strict_mode=1
session.cookie_httponly=1
session.cookie_secure=1Output (YAML):
PHP:
display_errors: "Off"
error_reporting: E_ALL
max_execution_time: "30"
memory_limit: 128M
upload_max_filesize: 2M
post_max_size: 8M
session:
save_handler: files
save_path: /tmp
use_strict_mode: "1"
cookie_httponly: "1"
cookie_secure: "1"Advanced Example: Multi-Section Application Config
[server]
host=0.0.0.0
port=8080
workers=4
keepalive_timeout=5
[database]
engine=postgresql
host=db.internal
port=5432
name=production
pool.size=20
pool.max_overflow=10
pool.timeout=30
[cache]
backend=redis
host=redis.internal
port=6379
db=1
key_prefix=myapp:
ttl=3600
[logging]
level=INFO
format=[%(asctime)s] %(levelname)s %(message)s
handlers=console,file
file.path=/var/log/myapp.log
file.max_bytes=10485760
file.backup_count=5Output (YAML):
server:
host: 0.0.0.0
port: "8080"
workers: "4"
keepalive_timeout: "5"
database:
engine: postgresql
host: db.internal
port: "5432"
name: production
pool:
size: "20"
max_overflow: "10"
timeout: "30"
cache:
backend: redis
host: redis.internal
port: "6379"
db: "1"
key_prefix: "myapp:"
ttl: "3600"
logging:
level: INFO
format: "[%(asctime)s] %(levelname)s %(message)s"
handlers: console,file
file:
path: /var/log/myapp.log
max_bytes: "10485760"
backup_count: "5"How the Conversion Works
- Parse sections — INI sections are identified by
[bracket]headers - Extract keys — Each
key=valuepair within a section is extracted - Split dot notation — Keys containing dots are split into nesting levels
- Build tree — A nested object hierarchy is constructed
- Serialize — The hierarchy is rendered as indented YAML
- Cleanup — Empty or comment-only sections are optionally omitted
Best Practices
- Use dot notation — Leverage dot-separated keys (
pool.maxActive) for nested YAML output - Quote special values — Values containing
=,:, or#should be quoted in YAML output - Remove trailing whitespace — Extra whitespace in INI values can produce unexpected YAML strings
- Consistent section naming — Use consistent section names for predictable YAML structure
- Validate the result — Run the YAML output through a YAML linter to confirm correctness
Related Tools
- YAML to INI — Reverse conversion from YAML back to INI format
- YAML to ENV — Convert YAML to flat environment variable format
- YAML to Bash — Convert YAML to shell export statements
- Python Dict to YAML — Convert Python dictionary literals to YAML
- YAML Validator — Validate generated YAML output
FAQs
Q: Does the converter handle INI comments?
A: Yes. Lines starting with ; or # are treated as comments and are preserved in the output as YAML comments.
Q: What about duplicate keys within the same section? A: The last occurrence of a duplicate key wins. For best results, ensure your INI file has unique keys per section.
Q: Can it handle sections with no keys? A: Yes. Empty sections produce empty top-level YAML keys.
Q: Are values with special characters handled? A: Yes. Values containing colons, quotes, or other YAML-special characters are automatically quoted in the output.
Q: Is my data sent to a server? A: No. All processing happens entirely in your browser. Your configuration never leaves your computer.
Q: What encoding is supported? A: UTF-8 is fully supported. ASCII INI files also work without issues.