TFT

Convert TOML to Java Properties

Generate Java .properties files from TOML configurations. This converter flattens nested tables into dot-notation keys, making TOML data usable in Java apps.

TOML to Properties Converter

How the TOML to Properties Converter Works

This tool converts TOML configuration files into Java .properties file format. Paste your TOML content and get flat KEY=value pairs compatible with Java's Properties class, Spring Boot, and other Java frameworks.

The converter flattens TOML's hierarchical structure into dot-notation keys. A TOML table [database] with key "host" becomes database.host in properties format. Nested tables create deeper key hierarchies.

Output follows Java properties syntax: key=value pairs, one per line. Special characters are escaped properly. Comments from TOML are preserved as Java comments. Copy into application.properties or load with Properties.load().

When You'd Actually Use This

Creating Spring Boot properties files

Your Spring Boot app needs application.properties. Define config in TOML, convert to properties format. Spring Boot handles dot-notation automatically.

Migrating to legacy Java systems

Older Java apps require .properties files. Modernize your workflow: edit in TOML, convert to properties for deployment. Best of both worlds.

Creating Java resource bundles

Store localized strings in TOML, convert to properties files for Java i18n. One TOML per language, generate messages_en.properties, messages_de.properties, etc.

Building JDBC connection configs

Database connection properties work well in .properties format. Define in TOML, convert for JDBC or connection pool configuration like HikariCP.

Generating build configuration

Build tools like Gradle use properties files. Define build settings in TOML, convert to gradle.properties. Better organization than raw properties.

Standardizing config across projects

Your organization uses TOML for new projects but has legacy .properties files. Convert between formats as needed during migration periods.

What to Know Before Using

Properties files are flat.Java .properties has no nested structure. TOML tables become dot-separated keys. [db.connection] host becomes db.connection.host.

Special characters need escaping.Properties files escape colons, equals signs, and backslashes. The converter handles this. Unicode can use \uXXXX notation.

Arrays become indexed keys.TOML arrays convert to keys like myarray.0, myarray.1, myarray.2. Your Java code needs to iterate over indexed keys to reconstruct arrays.

Type information is lost.Properties files store everything as strings. "42" and "forty-two" both become strings. Your Java code parses types as needed.

Pro tip: For Spring Boot, consider keeping TOML and using a custom loader, or convert to YAML. Spring Boot supports YAML natively and preserves structure better than flat properties files.

Common Questions

How do I load properties in Java?

Use Properties props = new Properties(); props.load(inputStream);. Then access with props.getProperty("key"). Spring injects @Value("${key}").

Can I convert back from properties to TOML?

This tool does TOML to properties. For properties to TOML, parse dot-notation keys and reconstruct nested structure. Dedicated tools exist for this.

What about boolean and number types?

Properties stores everything as strings. "true", "42", "3.14" are all strings. Java code parses them: Boolean.parseBoolean(), Integer.parseInt(), etc.

How do I handle lists in properties?

Spring Boot supports comma-separated: key=item1,item2,item3. Or indexed: key[0]=a, key[1]=b. The converter uses indexed format for clarity.

Can I use UTF-8 in properties files?

Traditional properties use ISO-8859-1 with \u escapes. Java 6+ supports XML properties with UTF-8. Modern Java often uses UTF-8 directly.

What's the properties file encoding?

Default is ISO-8859-1 (Latin-1). For Unicode, use \uXXXX escapes or XML properties format. Modern Java applications often use UTF-8 directly.

How do I comment properties files?

Lines starting with # or ! are comments. The converter preserves TOML comments as Java comments. Use comments to document configuration options.