Convert TOML to INI
Max file size 100mb.
TOML vs INI Format Comparison
| Aspect | TOML (Source Format) | INI (Target Format) |
|---|---|---|
| Format Overview |
TOML
Tom's Obvious Minimal Language
A minimal configuration file format created by Tom Preston-Werner with clear semantics and formal specification. Supports typed values including strings, integers, floats, booleans, dates, arrays, and tables. TOML was designed as a modern alternative to INI and other configuration formats. Configuration Format Formally Specified |
INI
Initialization File
One of the oldest and simplest configuration file formats, popularized by MS-DOS and Windows. INI files use sections in square brackets and key=value pairs. Despite having no formal specification, INI is ubiquitous in legacy systems, desktop applications, PHP (php.ini), MySQL (my.cnf), and many Unix/Linux tools. Legacy Standard Universal Support |
| Technical Specifications |
Structure: Key-value pairs with tables and arrays
Encoding: UTF-8 required Format: Plain text, human-readable Compression: None Extensions: .toml MIME Type: application/toml |
Structure: Sections with key=value pairs
Encoding: System-dependent (typically ASCII/UTF-8) Format: Plain text, human-readable Compression: None Extensions: .ini, .cfg, .conf, .cnf Standard: No formal specification |
| Syntax Examples |
TOML with typed values: [package] name = "myapp" version = "1.0.0" authors = ["Dev <[email protected]>"] [dependencies] serde = { version = "1.0", features = ["derive"] } tokio = "1.28" |
INI equivalent (simplified): [package] name = myapp version = 1.0.0 authors = Dev <[email protected]> [dependencies] serde = 1.0 tokio = 1.28 |
| Content Support |
|
|
| Advantages |
|
|
| Disadvantages |
|
|
| Common Uses |
|
|
| Best For |
|
|
| Version History |
Introduced: 2013 (Tom Preston-Werner)
Current Version: TOML v1.0.0 (2021) Status: Stable, formally specified Evolution: Community-driven development |
Introduced: 1980s (MS-DOS era)
Standard: No formal specification Status: De facto standard, stable Evolution: Various extensions by implementations |
| Software Support |
Editors: VS Code, Vim, Sublime Text, IntelliJ
Languages: Rust, Python, Go, JavaScript, Java Tools: Cargo, pip, Hugo, Netlify CLI Validation: taplo, toml-lint |
Languages: Python (configparser), PHP, C#, Java
Systems: Windows, Linux, macOS (universal) Applications: MySQL, PHP, Git, systemd, Samba Editors: Any text editor |
Why Convert TOML to INI?
Converting TOML to INI format is essential when migrating configurations to legacy systems, older applications, or tools that only support INI-style configuration files. While TOML was designed as a modern improvement over INI, many widely-used applications including PHP (php.ini), MySQL (my.cnf), Git (.gitconfig), and countless Windows applications still rely on INI format for their configuration.
INI is one of the most universally recognized configuration formats in computing. Its simplicity (sections with key=value pairs) means virtually every programming language has built-in INI parsing support. Python includes configparser in its standard library, PHP has parse_ini_file(), and C# has native INI support through the Windows API. This universal support makes INI the safest choice for maximum compatibility.
The conversion process maps TOML tables to INI sections and flattens TOML's typed values to INI strings. Since INI does not support native data types, arrays, or nested tables, some TOML features must be simplified during conversion. Simple TOML configurations with flat table structures convert cleanly, while complex nested structures may require flattening with dotted section names.
This conversion is particularly common in DevOps workflows where modern tools generate TOML configurations that need to be consumed by legacy infrastructure. For example, deploying to systems that read INI-format configs, configuring older PHP or MySQL instances, or integrating with Windows services that expect .ini files. The conversion bridges the gap between modern and legacy configuration paradigms.
Key Benefits of Converting TOML to INI:
- Legacy Compatibility: Works with systems that only accept INI format
- Universal Support: INI parsers available in every programming language
- Simplicity: INI's flat structure is easy for any tool to parse
- PHP/MySQL: Direct use with php.ini and my.cnf style configs
- Windows Integration: Native INI support in Windows applications
- Minimal Dependencies: No special libraries needed to read INI
- Human Editable: INI is one of the simplest formats to edit manually
Practical Examples
Example 1: Application Settings Migration
Input TOML file (config.toml):
[server] host = "0.0.0.0" port = 8080 debug = false workers = 4 [database] host = "localhost" port = 5432 name = "production" user = "admin" [logging] level = "warning" file = "/var/log/app.log"
Output INI file (config.ini):
[server] host = 0.0.0.0 port = 8080 debug = false workers = 4 [database] host = localhost port = 5432 name = production user = admin [logging] level = warning file = /var/log/app.log
Example 2: PHP Configuration Generation
Input TOML file (php-settings.toml):
[PHP] engine = true short_open_tag = false max_execution_time = 30 memory_limit = "128M" error_reporting = "E_ALL" [Date] timezone = "UTC" [Session] save_handler = "files" save_path = "/tmp" gc_maxlifetime = 1440
Output INI file (php.ini):
[PHP] engine = On short_open_tag = Off max_execution_time = 30 memory_limit = 128M error_reporting = E_ALL [Date] date.timezone = UTC [Session] session.save_handler = files session.save_path = /tmp session.gc_maxlifetime = 1440
Example 3: Git Configuration Export
Input TOML file (git-config.toml):
[user] name = "Jane Developer" email = "[email protected]" signingkey = "ABC123" [core] editor = "vim" autocrlf = "input" whitespace = "trailing-space,space-before-tab" [pull] rebase = true [alias] st = "status" co = "checkout" br = "branch"
Output INI file (.gitconfig):
[user]
name = Jane Developer
email = [email protected]
signingkey = ABC123
[core]
editor = vim
autocrlf = input
whitespace = trailing-space,space-before-tab
[pull]
rebase = true
[alias]
st = status
co = checkout
br = branch
Frequently Asked Questions (FAQ)
Q: What is INI format?
A: INI (Initialization) is one of the oldest configuration file formats, originating from MS-DOS in the 1980s. It uses a simple structure of sections enclosed in square brackets and key=value pairs. Despite having no formal specification, INI is universally supported and used by applications like PHP (php.ini), MySQL (my.cnf), Git (.gitconfig), and Windows desktop applications.
Q: What data is lost when converting TOML to INI?
A: INI format does not support TOML's typed values (all INI values are strings), arrays, inline tables, nested tables beyond one level, or date/time types. Arrays may be serialized as comma-separated values, nested tables may be flattened with dotted section names, and type information is lost. Simple, flat TOML configurations convert without significant data loss.
Q: How are TOML arrays handled in INI?
A: Since standard INI does not support arrays, TOML arrays are typically converted using one of several strategies: comma-separated values in a single key, numbered keys (key.1, key.2), or repeated keys (supported by some INI parsers). The exact approach depends on the target application that will read the INI file.
Q: How are nested TOML tables converted?
A: Nested TOML tables are flattened for INI format. A TOML table like [database.connection] becomes an INI section [database.connection] or the keys are prefixed with the parent table name. Some INI implementations support dotted section names, while others require complete flattening into a single level of sections.
Q: Why does INI have no formal specification?
A: INI format evolved organically from MS-DOS and early Windows without a formal standards body defining it. As a result, different implementations handle details differently: comment characters (; vs #), quoting rules, duplicate keys, multi-line values, and escape sequences all vary. This is one of the reasons TOML was created as a formally specified alternative.
Q: Can I convert INI back to TOML?
A: Yes, converting INI to TOML is generally straightforward since INI is simpler than TOML. Sections map to TOML tables and key-value pairs transfer directly. However, since INI values are untyped strings, you may need to manually specify types (numbers, booleans, dates) in the resulting TOML file for proper parsing.
Q: Which applications require INI configuration files?
A: Many widely-used applications require INI format: PHP (php.ini), MySQL/MariaDB (my.cnf/my.ini), Git (.gitconfig), Samba (smb.conf), Windows desktop applications, Python's setup.cfg, tox.ini (testing), and systemd unit files (which use an INI-like format). Converting TOML to INI is essential for these ecosystems.
Q: Is TOML really better than INI?
A: TOML offers significant advantages: formal specification, typed values, nested structures, arrays, and date/time support. However, INI is simpler, more universally supported, and sufficient for flat configurations. The choice depends on your needs: use TOML for complex typed configurations and INI for simple settings or legacy compatibility. TOML was explicitly designed as a modern INI replacement.