Convert Java .properties files to JSON
Java .properties files use key=value pairs with dot-notation for nesting. Convert to JSON for use in JavaScript environments and structured access.
- 1
Java .properties files use KEY=VALUE or KEY:VALUE pairs, with dot-notation for hierarchical keys (e.g., app.database.host=localhost). Comments start with # or !. They are common in Java applications for configuration and internationalization (i18n) messages.
- 2 TOML Converter →
Parse the .properties file and convert to JSON. Dot-notation keys are expanded into nested objects: app.database.host becomes {app: {database: {host: ...}}}. This makes the structure explicit and navigable.
- 3 JSON Formatter →
Format the converted JSON. Verify that dot-notation keys were correctly nested. Properties files often use inconsistent key naming — formatting normalizes the output and makes structural issues visible.
- 4
For i18n message bundles, the conversion produces a JSON object that JavaScript i18n libraries (i18next, FormatJS) can consume directly. Map Java message format ({0}, {1}) to ICU MessageFormat ({name}, {count, plural, ...}) during conversion if needed.
Frequently asked questions
- How are special characters handled in .properties?
- Backslash escapes: \n (newline), \t (tab), \= (literal =), \: (literal :), \\ (literal backslash). Unicode: \uXXXX. The conversion tool should handle these escapes and produce the correct characters in JSON.
- Can I convert JSON back to .properties?
- Yes, but only for flat or shallowly nested JSON. Deep nesting and arrays do not map cleanly to .properties dot-notation. If you need round-trip conversion, keep the JSON flat or use a format that supports nesting natively (YAML, TOML).
Workflows that solve this
Learn more
Want to understand why?