Convert TOML to Properties
Max file size 100mb.
TOML vs Properties Format Comparison
| Aspect | TOML (Source Format) | Properties (Target Format) |
|---|---|---|
| Format Overview |
TOML
Tom's Obvious Minimal Language
A minimal configuration file format created by Tom Preston-Werner in 2013. Designed to be easy to read due to obvious semantics. Supports rich data types including strings, integers, floats, booleans, dates, arrays, and tables. Formally specified with a clear grammar. Modern Config Typed Values |
Properties
Java Properties File
A simple key-value configuration format used predominantly in the Java ecosystem. Each line contains a key=value pair. Supports comments with # or !. One of the oldest and simplest configuration formats still in widespread use. No native type system -- all values are strings. Java Standard Key-Value |
| Technical Specifications |
Structure: Hierarchical tables and key-value pairs
Encoding: UTF-8 required Data Types: String, Integer, Float, Boolean, DateTime, Array, Table Nesting: Tables and inline tables for hierarchy Extensions: .toml |
Structure: Flat key=value pairs
Encoding: ISO 8859-1 (with Unicode escapes) Data Types: Strings only (no type system) Nesting: Dot-notation convention only Extensions: .properties |
| Syntax Examples |
TOML uses clear, typed syntax: [database] host = "localhost" port = 5432 enabled = true max_connections = 100 [database.pool] min_idle = 5 max_idle = 20 |
Properties uses flat key=value lines: # Database configuration database.host=localhost database.port=5432 database.enabled=true database.max_connections=100 database.pool.min_idle=5 database.pool.max_idle=20 |
| 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: Active development, growing adoption |
Introduced: 1995 (Java 1.0)
Current Version: Part of Java SE standard Status: Stable, mature Evolution: Minimal changes, XML properties added in Java 5 |
| Software Support |
Cargo (Rust): Native support
Python: tomllib (3.11+), tomli, toml Go: BurntSushi/toml, pelletier/go-toml Other: Libraries for most languages |
Java: java.util.Properties (built-in)
Spring: application.properties native Python: configparser, jproperties Other: Widely supported across tools |
Why Convert TOML to Properties?
Converting TOML files to Java Properties format is essential when integrating modern configuration files with Java-based applications. Many Java frameworks such as Spring Boot, Apache Maven, and Gradle rely on .properties files as their primary configuration mechanism. If your project uses TOML for its primary configuration but needs to interface with Java tooling, converting to Properties format ensures seamless compatibility without modifying your Java application code.
TOML's hierarchical table structure maps naturally to the dot-notation convention used in Properties files. A TOML section like [database] with a key host = "localhost" becomes database.host=localhost in Properties format. This flattening process preserves the logical organization while conforming to the flat key-value structure that Java's java.util.Properties class expects. However, TOML features like arrays and complex nested tables require special handling during conversion since Properties has no native support for these constructs.
The Properties format has been a cornerstone of Java configuration since JDK 1.0 in 1995. It is universally understood by Java developers and tools. Spring Boot's application.properties, Maven's settings, and logging frameworks like Log4j all consume Properties files natively. By converting TOML to Properties, you can leverage decades of Java ecosystem tooling without requiring additional parsing libraries or configuration adapters.
One important consideration is that Properties files have no type system -- all values are stored as strings. TOML's typed values (integers, booleans, dates) will be serialized to their string representations. Your Java application must handle the parsing of these string values back into the appropriate types, which is standard practice in Java configuration management. Spring Boot, for example, automatically converts property strings to the required types using its built-in type conversion system.
Key Benefits of Converting TOML to Properties:
- Java Compatibility: Native support via java.util.Properties API
- Spring Boot Ready: Direct use as application.properties
- Build Tools: Compatible with Maven, Gradle, and Ant
- Simple Format: Easy to read, edit, and manage
- Universal Parsing: Every Java library supports Properties
- i18n Support: Standard format for resource bundles
- Zero Dependencies: No extra libraries needed in Java
Practical Examples
Example 1: Spring Boot Application Configuration
Input TOML file (config.toml):
[server] port = 8080 host = "0.0.0.0" context-path = "/api" [spring.datasource] url = "jdbc:postgresql://localhost:5432/mydb" username = "admin" password = "secret123" driver-class-name = "org.postgresql.Driver" [spring.jpa] show-sql = true hibernate.ddl-auto = "update"
Output Properties file (application.properties):
# Server configuration server.port=8080 server.host=0.0.0.0 server.context-path=/api # Spring Datasource spring.datasource.url=jdbc:postgresql://localhost:5432/mydb spring.datasource.username=admin spring.datasource.password=secret123 spring.datasource.driver-class-name=org.postgresql.Driver # Spring JPA spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=update
Example 2: Logging Configuration
Input TOML file (logging.toml):
[logging] level.root = "INFO" level.com.myapp = "DEBUG" level.org.springframework = "WARN" [logging.file] name = "app.log" max-size = "10MB" max-history = 30
Output Properties file (logging.properties):
# Logging levels logging.level.root=INFO logging.level.com.myapp=DEBUG logging.level.org.springframework=WARN # Log file settings logging.file.name=app.log logging.file.max-size=10MB logging.file.max-history=30
Example 3: Build Configuration Migration
Input TOML file (build.toml):
[project] name = "my-application" version = "2.1.0" description = "Enterprise REST API Service" [build] source-encoding = "UTF-8" java-version = "17" output-dir = "target/classes" [dependencies] spring-boot = "3.2.1" postgresql = "42.7.1"
Output Properties file (build.properties):
# Project metadata project.name=my-application project.version=2.1.0 project.description=Enterprise REST API Service # Build settings build.source-encoding=UTF-8 build.java-version=17 build.output-dir=target/classes # Dependencies dependencies.spring-boot=3.2.1 dependencies.postgresql=42.7.1
Frequently Asked Questions (FAQ)
Q: What happens to TOML's typed values during conversion?
A: All TOML values (integers, floats, booleans, dates) are converted to their string representations in the Properties file. For example, port = 8080 becomes port=8080 as a string. Your Java application should handle type conversion when reading these values, which frameworks like Spring Boot do automatically.
Q: How are TOML tables converted to Properties keys?
A: TOML table hierarchies are flattened using dot notation. A key host under [database.connection] becomes database.connection.host in the Properties file. This convention is standard in Java and understood by all major frameworks.
Q: Can TOML arrays be represented in Properties format?
A: Properties has no native array support. TOML arrays are typically converted using indexed keys (e.g., servers[0]=alpha, servers[1]=beta) or comma-separated values (servers=alpha,beta,gamma). The specific approach depends on what your consuming application expects.
Q: Will comments from my TOML file be preserved?
A: TOML comments (lines starting with #) are generally not preserved during conversion since they are not part of the data model. However, the converter may add section header comments to improve readability of the resulting Properties file.
Q: Is the resulting Properties file compatible with Spring Boot?
A: Yes. The output follows standard Spring Boot application.properties conventions with dot-separated keys. You can use it directly as application.properties in your Spring Boot project without modification.
Q: How are special characters handled in the conversion?
A: Properties files use ISO 8859-1 encoding by default. Non-ASCII characters from TOML are converted to Unicode escape sequences (\uXXXX) to ensure compatibility. Backslashes, colons, and equals signs in values are properly escaped.
Q: Can I convert Cargo.toml to Properties format?
A: Yes, any valid TOML file can be converted. Cargo.toml files will have their package metadata, dependencies, and build settings flattened into Properties format. However, Cargo-specific semantics (like dependency version constraints) will be treated as plain strings.
Q: What is the maximum file size supported for conversion?
A: Our converter supports TOML files up to several megabytes in size. Most configuration files are well within this limit. The conversion process is fast since both formats are text-based and lightweight to parse.