How to convert properties to JSON
A .properties file is a flat list of key=value lines, and JSON holds the same settings as nested objects. To convert properties to json, the tool splits each key at its dots and builds the groups, so server.port=8080 becomes a server object with a port inside it.
Take these lines:
server.port=8080
server.ssl.enabled=true
app.cors.origins[0]=https://example.com
app.cors.origins[1]=https://admin.example.com
build.number=007They become this JSON. The port is a number, the flag is a boolean, the two origins are an array, and 007 stays text because turning it into 7 would change it:
{
"server": {
"port": 8080,
"ssl": {
"enabled": true
}
},
"app": {
"cors": {
"origins": [
"https://example.com",
"https://admin.example.com"
]
}
},
"build": {
"number": "007"
}
}The conversion runs in your browser, so configuration with passwords is not uploaded. See the Privacy Policy.
Convert application.properties to JSON
To convert application.properties to json for a Spring Boot or other Java project, paste the file and keep the defaults. Keys with [0] and [1] indexes become arrays, which is how Spring reads a list. A value such as health,info stays one string, because a comma in a properties file does not always mean a list.
If you need the file as YAML instead, Properties to YAML does that. To go from JSON back to a flat file, use JSON to Properties.
Escapes, comments and long lines
Java properties have their own escapes. A \u00e9 becomes the real character é, \n becomes a line break inside the string, an escaped colon or equals sign becomes the plain character, and a line that ends in a backslash is joined with the next one, with the leading spaces of the next line removed.
Lines that start with # or ! are comments. JSON has no comments, so they are dropped, and the notes say so. Duplicate keys are not an error in Java: the last one wins, and the tool does the same and lists each repeat with its line number.
Nested objects or flat keys
Nested objects are the right choice for configuration that a program reads as a tree. Choose Flat keys when you only want the file as JSON, for example to load it in a script or an i18n tool. Each line then becomes one entry in a single object, so server.port stays a key named server.port.
Flat output never has clashes, because no key is split. Nested output can, and that is the next part.
When keys clash
A properties file can hold both db.url=x and db.url.timeout=30. In a tree, db.url cannot be a value and a group of keys at once. The tool keeps the line that came first, leaves the other out, and lists it with both line numbers under Conflicts and repeats. The same goes for a key that is used as a list and as an object.
A list with a gap, such as items[0] and items[2], is written in index order with no hole, and the notes mention it.
Limits and related tools
Numbers are detected only when they are plain and exact: 8080 and 2.5 become numbers, while 007, 1e5 and numbers with more than 15 digits stay text. Choose Keep everything as text if you want strings throughout. To work with the result further, YAML to JSON and Sort JSON Keys are next to this tool.