Convert INI to TOML
Max file size 100mb.
INI vs TOML Format Comparison
| Aspect | INI (Source Format) | TOML (Target Format) |
|---|---|---|
| Format Overview |
INI
Initialization File
Simple configuration file format using sections and key-value pairs. Originated in early Windows systems for storing application settings. Human-readable with minimal syntax. No formal specification, leading to implementation variations across platforms. Configuration Legacy Standard |
TOML
Tom's Obvious Minimal Language
Modern configuration file format created by Tom Preston-Werner (GitHub co-founder) in 2013. Designed to be a minimal, human-readable configuration format that maps unambiguously to a hash table. Features explicit data types and a formal specification. Modern Config Typed Values |
| Technical Specifications |
Structure: Sections with key-value pairs
Encoding: Typically ASCII or UTF-8 Data Types: Strings only (no typing) Nesting: Single level (sections only) Extensions: .ini, .cfg, .conf |
Structure: Tables with typed key-value pairs
Encoding: UTF-8 required Data Types: String, Integer, Float, Boolean, Datetime, Array, Table Nesting: Multi-level via dotted keys and sub-tables Extensions: .toml |
| Syntax Examples |
INI uses sections and key-value pairs: [database] host = localhost port = 3306 ; This is a comment name = mydb |
TOML adds explicit types and nesting: [database] host = "localhost" port = 3306 # This is a comment name = "mydb" enabled = true |
| Content Support |
|
|
| Advantages |
|
|
| Disadvantages |
|
|
| Common Uses |
|
|
| Best For |
|
|
| Version History |
Introduced: 1980s (early Windows)
Specification: No formal spec Status: Widely used, legacy Evolution: Largely unchanged |
Introduced: 2013 (Tom Preston-Werner)
Current Version: TOML v1.0.0 (2021) Status: Active, growing adoption Evolution: Regular improvements |
| Software Support |
Python: configparser (built-in)
PHP: parse_ini_file() (built-in) Windows: Native API support Other: Most languages via libraries |
Python: tomllib (3.11+), toml, tomli
Rust: toml crate (native) Go: BurntSushi/toml Other: Libraries for most languages |
Why Convert INI to TOML?
Converting INI files to TOML format is an excellent way to modernize your configuration management. While INI files have served the computing world well since the 1980s, they lack features that modern applications demand such as explicit data types, nested structures, and arrays. TOML was specifically designed as a successor to INI-style configuration with these capabilities built in.
TOML (Tom's Obvious Minimal Language) was created in 2013 by Tom Preston-Werner, the co-founder of GitHub, to address the shortcomings of INI files while maintaining their simplicity and readability. Unlike INI where all values are treated as strings, TOML supports integers, floats, booleans, dates, arrays, and nested tables natively. This means your configuration values are validated at parse time, reducing runtime errors caused by type mismatches.
The transition from INI to TOML is particularly natural because both formats share a similar section-based structure. INI sections map directly to TOML tables, and key-value pairs maintain the same intuitive syntax. The main difference is that TOML adds type information, making the configuration more explicit and less error-prone. For example, a port number that was a string in INI becomes a proper integer in TOML.
TOML has been widely adopted by modern development tools and ecosystems. Rust's package manager (Cargo) uses Cargo.toml, Python's build system uses pyproject.toml, and many other tools like Hugo, InfluxDB, and various CI/CD systems use TOML for configuration. Converting your INI files to TOML positions your projects for compatibility with these modern toolchains.
Key Benefits of Converting INI to TOML:
- Type Safety: Native support for integers, floats, booleans, and dates
- Formal Specification: TOML v1.0 provides unambiguous parsing rules
- Nested Structures: Sub-tables and dotted keys for hierarchical config
- Array Support: Native arrays and array of tables for list data
- Modern Ecosystem: Used by Rust, Python, Go, and many CI/CD tools
- Easy Migration: INI sections map naturally to TOML tables
- Better Validation: Type checking prevents configuration errors at parse time
Practical Examples
Example 1: Application Server Configuration
Input INI file (server.ini):
[server] host = 0.0.0.0 port = 8080 debug = false workers = 4 [database] host = db.example.com port = 5432 name = production_db pool_size = 10 [logging] level = INFO file = /var/log/app.log
Output TOML file (server.toml):
[server] host = "0.0.0.0" port = 8080 debug = false workers = 4 [database] host = "db.example.com" port = 5432 name = "production_db" pool_size = 10 [logging] level = "INFO" file = "/var/log/app.log"
Example 2: Python Project Configuration
Input INI file (setup.ini):
[project] name = my-package version = 1.2.3 description = A useful Python library [build] requires = setuptools backend = setuptools.build_meta [options] python_requires = >=3.8 install_requires = requests,click
Output TOML file (pyproject.toml):
[project] name = "my-package" version = "1.2.3" description = "A useful Python library" [build] requires = "setuptools" backend = "setuptools.build_meta" [options] python_requires = ">=3.8" install_requires = "requests,click"
Example 3: Git-like Tool Configuration
Input INI file (tool.ini):
[user] name = John Doe email = [email protected] [core] editor = vim autocrlf = true whitespace = fix [remote] url = https://git.example.com/repo.git fetch = +refs/heads/*:refs/remotes/origin/*
Output TOML file (tool.toml):
[user] name = "John Doe" email = "[email protected]" [core] editor = "vim" autocrlf = true whitespace = "fix" [remote] url = "https://git.example.com/repo.git" fetch = "+refs/heads/*:refs/remotes/origin/*"
Frequently Asked Questions (FAQ)
Q: What is TOML format?
A: TOML (Tom's Obvious Minimal Language) is a modern configuration file format created in 2013 by Tom Preston-Werner. It is designed to be easy to read due to its clear semantics, and it maps unambiguously to a hash table. Unlike INI files, TOML has a formal specification and supports explicit data types including strings, integers, floats, booleans, dates, arrays, and nested tables.
Q: How do INI sections map to TOML?
A: INI sections map directly to TOML tables. A section like [database] in INI becomes a [database] table in TOML. The key-value pairs within the section are preserved. The main difference is that TOML adds type information to the values -- strings get quotes, numbers stay unquoted, and booleans use true/false keywords.
Q: Will my INI comments be preserved?
A: Comments in INI files (using ; or #) can be converted to TOML comments (which use # only). However, the exact positioning and formatting of comments may change during conversion. The content of your comments will be preserved, but INI's semicolon-style comments will be converted to TOML's hash-style comments.
Q: What happens to values that look like numbers in INI?
A: Since INI treats all values as strings, the converter analyzes each value to determine its appropriate TOML type. Values that look like integers (e.g., 8080) become TOML integers, decimal values become floats, "true"/"false" become booleans, and everything else remains as quoted strings. This automatic type inference makes the TOML output more semantically correct.
Q: Can TOML handle nested INI sections?
A: Yes, and TOML actually improves upon INI's flat structure. While INI files can only have one level of sections, TOML supports nested tables using dotted keys (e.g., [server.database]) and sub-tables. This means your INI configuration can be restructured into a more logical hierarchy in TOML.
Q: Which tools and languages support TOML?
A: TOML is widely supported: Python has tomllib (built-in since 3.11), Rust uses the toml crate natively, Go has BurntSushi/toml, and JavaScript has @iarna/toml. TOML is the standard config format for Rust (Cargo.toml), Python (pyproject.toml), and many other tools including Hugo, InfluxDB, and various CI/CD platforms.
Q: Is TOML better than INI for all use cases?
A: TOML is generally superior for modern applications due to its type system, formal specification, and richer feature set. However, INI may still be preferable for extremely simple configurations, legacy system compatibility, or when working with tools that specifically require INI format (e.g., php.ini, Windows registry exports). Choose TOML for new projects and when type safety matters.
Q: How does TOML compare to YAML and JSON for configuration?
A: TOML sits between INI and YAML in complexity. It is simpler than YAML (no indentation-based nesting, fewer gotchas) while being more feature-rich than INI. Compared to JSON, TOML allows comments, has a more human-friendly syntax, and supports date/time types natively. TOML is specifically designed for configuration files, making it an ideal choice for that purpose.