Skip to main content

Convert Properties Files to JSON Convert Java .properties files to structured JSON with nested key support.

Properties to JSON illustration
🔄

Properties to JSON

Convert Java .properties files to structured JSON with nested key support.

1

Paste .properties content

Paste your Java properties file content.

2

View JSON

Dotted keys become nested JSON objects automatically.

3

Copy JSON

Copy the structured JSON output.

Loading tool...

What Is Properties to JSON?

A Properties to JSON is a file-conversion tool that transforms Java-style .properties files into structured JSON format, making it easier to work with configuration data in JavaScript environments. Developers working on projects that involve Java application configuration, i18n message bundles, and Spring Boot settings use this type of converter to simplify their workflow, specifically when dealing with the problem of parsing complex properties files with nested structures. For instance, when a properties file contains dotted keys like db.host=localhost, it can be challenging to parse and convert them into a usable JSON format.

The tool solves this specific problem by supporting dotted keys, which are expanded into nested JSON objects, allowing for easier data access and manipulation. It also handles # and ! comment styles, escape sequences (\n, \t), and both = and : separators, making it a reliable choice for converting properties files to JSON. What makes Properties to JSON different is its ability to unescape common Java properties escapes, such as \\n and \\t, and build nested structures from dotted keys, resulting in a clean and organized JSON output.

It uses the `JSON.stringify` method with an indentation of 2 spaces to format the output, making it more readable and easier to work with. As a java properties converter, it can be used to convert properties files to json, and its support for properties file parser functionality allows it to handle complex configuration files with ease, ultimately helping developers to easily convert .properties to JSON and integrate them into their projects.

Why Use Properties to JSON?

  • Dotted keys automatically expanded into nested JSON objects.
  • Supports both = and : key-value separators.
  • Handles Java escape sequences (\n, \t, \\).
  • Supports # and ! comment styles.

Common Use Cases

Spring Boot Migration

Convert application.properties to JSON for use with other frameworks.

i18n Processing

Transform Java message bundle .properties files into JSON for JavaScript i18n libraries.

Configuration Analysis

Convert properties files to JSON for programmatic processing and analysis.

DevOps

Parse application configuration into JSON for infrastructure automation.

Technical Guide

The parser processes the properties file line by line. Lines starting with # or ! are treated as comments and skipped. Empty lines are ignored.

Key-value separation supports both = and : delimiters. The parser finds the first occurrence of either delimiter and splits the line there. Both key and value are trimmed of whitespace.

Dotted key expansion: keys containing periods (e.g., db.connection.host) are split and create nested JSON objects. The parser walks the key parts, creating intermediate objects as needed, and sets the value at the deepest level.

Escape sequences are processed: \n becomes newline, \t becomes tab, \\ becomes backslash. This matches Java's standard escape handling.

Tips & Best Practices

  • 1
    Dotted keys (a.b.c) create nested JSON: {"a":{"b":{"c":"value"}}}.
  • 2
    Both = and : separators are supported for key-value pairs.
  • 3
    Comments with # or ! are ignored during parsing.
  • 4
    Java escape sequences (\n, \t) are properly unescaped.

Related Tools

Frequently Asked Questions

Q How are dotted keys handled?
Keys with dots are expanded into nested JSON objects. For example, db.host=localhost becomes {"db":{"host":"localhost"}}.
Q Which separators are supported?
Both = and : are supported as key-value separators.
Q Are escape sequences processed?
Yes, standard Java escape sequences (\n, \t, \\) are unescaped.
Q What about multi-line values?
Standard line continuation with trailing backslash is not supported. Each key-value pair should be on one line.
Q Are Unicode escapes handled?
Java \uXXXX Unicode escapes are not currently processed. Values are treated as UTF-8 text.

About This Tool

Properties to JSON is a free online tool by FreeToolkit.ai. All processing happens directly in your browser — your data never leaves your device. No registration or installation required.