Convert JSON to Properties
Max file size 100mb.
JSON vs Properties Format Comparison
| Aspect | JSON (Source Format) | Properties (Target Format) |
|---|---|---|
| Format Overview |
JSON
JavaScript Object Notation
Lightweight data interchange format that is easy for humans to read and write and easy for machines to parse and generate. Based on a subset of JavaScript, JSON has become the universal standard for web APIs, configuration files, and data storage. Data Format Universal Standard |
Properties
Java Properties File
Simple key-value configuration format used extensively in Java and Spring Boot applications. Each line contains a key=value or key:value pair. Nested keys use dot notation (app.server.port=8080). Properties files are the standard configuration mechanism for the entire JVM ecosystem. Configuration Java Standard |
| Technical Specifications |
Standard: RFC 8259 / ECMA-404
Encoding: UTF-8 (mandatory) Format: Text-based with strict syntax Data Types: String, Number, Boolean, Array, Object, null Extension: .json |
Standard: Java SE specification (java.util.Properties)
Encoding: ISO 8859-1 (Latin-1), Unicode escapes (\uXXXX) Format: Line-based key=value or key:value pairs Data Types: Strings only (all values are text) Extension: .properties |
| Syntax Examples |
JSON uses braces and brackets: {
"name": "My Project",
"version": "2.0",
"features": ["fast", "free"],
"database": {
"host": "localhost",
"port": 5432
}
}
|
Properties uses dot-separated keys: # Application configuration name=My Project version=2.0 features[0]=fast features[1]=free database.host=localhost database.port=5432 |
| Content Support |
|
|
| Advantages |
|
|
| Disadvantages |
|
|
| Common Uses |
|
|
| Best For |
|
|
| Version History |
Introduced: 2001 (Douglas Crockford)
Standard: RFC 8259 (2017), ECMA-404 (2013) Status: Universal standard Evolution: JS subset → RFC 4627 → RFC 7159 → RFC 8259 |
Introduced: 1995 (Java 1.0, java.util.Properties)
Major Update: Java 1.6 added XML properties support Status: Standard in Java ecosystem, stable Evolution: Java 1.0 Properties → Spring relaxed binding → Spring Boot profiles |
| Software Support |
JavaScript: JSON.parse() / JSON.stringify() (built-in)
Python: json module (built-in) Databases: MongoDB, PostgreSQL JSONB, MySQL JSON Other: Every modern language has native JSON support |
Java: java.util.Properties (built-in since JDK 1.0)
Spring: @Value, @ConfigurationProperties, Environment Python: jproperties, configparser (similar) Other: Apache Commons Configuration, Eclipse IDE, IntelliJ IDEA |
Why Convert JSON to Properties?
Converting JSON files to Java Properties format is a common requirement when migrating configuration between modern web applications and the Java ecosystem. Spring Boot applications, for instance, use application.properties as their primary configuration file. If you have configuration data stored in JSON from a Node.js service, a REST API, or a cloud provider, converting it to .properties format lets you plug it directly into your Java or Spring Boot project.
Properties files use a flat key=value structure with dot notation for hierarchy. A JSON path like {"database": {"host": "localhost"}} becomes database.host=localhost in Properties format. This dot-separated convention is natively understood by Spring Boot's @ConfigurationProperties annotation, making it trivial to bind configuration values to Java beans. The format also supports comments (#) for documentation, something JSON cannot provide.
Our converter handles the flattening of nested JSON structures automatically. Each nested key path is joined with dots, arrays use indexed notation (items[0], items[1]), and all values are serialized as strings. The resulting .properties file is ready to use in any Java application, Spring Boot project, or build tool (Maven, Gradle) that reads this format.
Key Benefits of Converting JSON to Properties:
- Spring Boot Ready: Output is directly usable as application.properties with auto-binding support
- Flat Structure: Nested JSON objects are flattened to dot-notation keys (server.port=8080)
- i18n Support: Perfect for generating localization resource bundles (messages_en.properties)
- Build Tool Compatible: Works with Maven, Gradle, and Ant property files
- Comment Support: Add # comments to document configuration values after conversion
- Environment Override: Properties map directly to environment variable overrides in Spring Boot
Practical Examples
Example 1: Spring Boot Application Configuration
Input JSON file (config.json):
{
"server": {
"port": 8080,
"servlet": {
"context-path": "/api"
}
},
"spring": {
"datasource": {
"url": "jdbc:mysql://localhost:3306/mydb",
"username": "root",
"password": "secret"
}
}
}
Output Properties file (application.properties):
# Server configuration server.port=8080 server.servlet.context-path=/api # Spring datasource configuration spring.datasource.url=jdbc:mysql://localhost:3306/mydb spring.datasource.username=root spring.datasource.password=secret
Example 2: Internationalization Resource Bundle
Input JSON file (messages.json):
{
"app": {
"title": "My Application",
"welcome": "Welcome, {0}!",
"error": {
"not_found": "Page not found",
"forbidden": "Access denied",
"server": "Internal server error"
}
}
}
Output Properties file (messages.properties):
app.title=My Application
app.welcome=Welcome, {0}!
app.error.not_found=Page not found
app.error.forbidden=Access denied
app.error.server=Internal server error
Example 3: Logging Configuration
Input JSON file (logging.json):
{
"logging": {
"level": {
"root": "WARN",
"com.myapp": "DEBUG",
"org.springframework": "INFO"
},
"file": {
"name": "app.log",
"max-size": "10MB"
}
}
}
Output Properties file (application.properties):
logging.level.root=WARN logging.level.com.myapp=DEBUG logging.level.org.springframework=INFO logging.file.name=app.log logging.file.max-size=10MB
Frequently Asked Questions (FAQ)
Q: What is JSON format?
A: JSON (JavaScript Object Notation) is a lightweight data interchange format standardized as RFC 8259 and ECMA-404. It uses key-value pairs in objects (curly braces), ordered lists in arrays (square brackets), and supports strings, numbers, booleans, and null. JSON is the dominant format for web APIs, configuration files (package.json, tsconfig.json), and NoSQL databases like MongoDB.
Q: What is Java Properties format?
A: Java Properties (.properties) is a line-based key=value configuration format native to the Java ecosystem. It is loaded by java.util.Properties and used extensively in Spring Boot (application.properties), resource bundles for internationalization, and build tools like Maven and Gradle. All values are stored as strings, and nested keys use dot notation (parent.child.key=value).
Q: How are nested JSON objects handled?
A: Nested JSON objects are flattened using dot notation. For example, {"server": {"port": 8080}} becomes server.port=8080. This dot-separated format is the standard convention in Spring Boot and other Java frameworks, so the output is immediately usable without any additional transformation.
Q: How are JSON arrays converted?
A: JSON arrays are converted using indexed notation. For example, {"colors": ["red", "green", "blue"]} becomes colors[0]=red, colors[1]=green, colors[2]=blue. This is the same convention Spring Boot uses for list-type properties, so the output binds correctly to List fields in @ConfigurationProperties classes.
Q: What about special characters and Unicode?
A: Java Properties files use ISO 8859-1 encoding by default. Characters outside this range are represented as Unicode escape sequences (e.g., \u00E9 for e with acute accent). Our converter automatically handles this encoding, ensuring that international characters from your JSON data are correctly represented in the output.
Q: Can I use the output directly in Spring Boot?
A: Yes, the generated .properties file follows Spring Boot conventions and can be used directly as application.properties or application-{profile}.properties. The dot-notation keys, array indexing, and string values all match what Spring Boot expects for auto-configuration and @ConfigurationProperties binding.
Q: What happens if my JSON file has syntax errors?
A: If the JSON file contains syntax errors and cannot be parsed, the converter will treat the content as plain text and include it as commented-out lines in the .properties file. This ensures you always get output, even if the JSON is malformed, and you can then fix the original data and re-convert.