Saved

Press the star next to a tool's name to save it.

All my tools

JSON to Properties Converter

This JSON to properties converter turns a JSON object into a Java .properties file, with nested keys joined by dots, arrays indexed and characters escaped.

Nested objects become dot-separated keys such as server.port. Keys and values are escaped the way Java's Properties class reads them.

Your JSON is converted in your browser. Nothing is uploaded.

Your .properties file

Paste JSON and press Convert to .properties.

A JSON to properties converter turns a JSON object into a Java .properties file, the key=value format used for application settings and translation bundles. Paste your JSON, press Convert, and this JSON to properties converter writes one line for every value, with nested objects joined into dot-separated keys such as server.port. Special characters are escaped the way Java reads them, and accented or non-Latin letters can be written as \u escapes so the file works with every Java version.

How to use the JSON to properties converter

  1. Paste a JSON object into the box. The top level must be an object, because every line in a .properties file needs a key.
  2. Choose how arrays are written: as indexed keys such as tags[0] and tags[1], or as one comma-separated value.
  3. Pick a separator: key=value, key = value or key: value. All three are read the same way.
  4. Leave the \uXXXX option on unless you know the file will be read as UTF-8.
  5. Press Convert, then copy the result or download it as application.properties.

What a .properties file is

A .properties file stores the settings of an application, mainly in Java-related technologies, as pairs of strings: a key, and the value for that key. The same format is used for translated text, where the files are called property resource bundles. Each line normally holds one property, and a line that starts with # or ! is a comment. There is no RFC for the format, so this converter follows the behavior of Java's own Properties class, which reads these files at runtime.

Worked example

This JSON:

{"server": {"port": 8080, "host": "localhost"}, "app": {"name": "Café", "tags": ["web", "api"]}}

becomes five properties:

  • server.port=8080
  • server.host=localhost
  • app.name=Caf\u00E9
  • app.tags[0]=web
  • app.tags[1]=api

The é in Café is written as \u00E9, so the file is pure ASCII. Choose One comma-separated value for arrays and the last two lines become app.tags=web,api instead.

How JSON maps to properties

  • Nested objects become dot paths: {"db": {"pool": {"size": 10}}} gives db.pool.size=10. Spring Boot and many other frameworks read settings in exactly this shape.
  • Arrays become indexed keys, or one comma-separated value when every item is a simple value. Arrays of objects always use indexes, such as servers[0].host.
  • Numbers and true or false are written as they are. A .properties file stores everything as text, so the program reading it decides how to treat them.
  • null becomes an empty value, and so do empty objects and empty arrays.

Escaping rules

The format uses a few characters for its own purposes, so the converter escapes them with a backslash:

  • In keys: the delimiters =, : and spaces, and the comment marks # and !, are escaped, because a key ends at the first unescaped delimiter.
  • In values: delimiters don't need escaping, but a space at the very start does, or it would be ignored.
  • Everywhere: a backslash becomes \\, and line breaks, carriage returns and tabs become \n, \r and \t, so every property stays on one line.

Unicode and \uXXXX escapes

Before Java 9, a .properties file is read as ISO-8859-1, also called Latin-1, so every non-ASCII character must be written as a Unicode escape, \u followed by four hexadecimal digits. With the escape option on, the converter does that for every character outside plain ASCII, including emoji, which become two escapes each. Newer setups that read UTF-8 can show the characters directly, so turn the option off if you'd rather keep the file readable and you're sure of the encoding.

Separators and spacing

Java accepts =, : or plain whitespace between a key and its value, and spaces around the separator are ignored. So hello=hello and hello = hello mean the same thing. Pick whichever matches the style of your existing files. The converter never adds a space at the end of a value, because trailing spaces are kept by the reader.

Duplicate keys

When the same key appears twice in a .properties file, the last one wins. JSON objects shouldn't contain duplicate names either, and when they do, JSON.parse keeps the last value, so the converted file behaves the same way the JSON did.

Your privacy

Configuration files often hold host names, user names and even passwords. Everything here runs in your browser, and nothing you paste is uploaded or stored.

Reading the file back

A Java program loads the file with the Properties class or, in Spring Boot, picks up application.properties automatically. Keys keep the exact dot-separated names shown here, so a setting that was server.port in JSON is read as server.port from the file.

Common mistakes

  • Pasting an array at the top level. Wrap it in an object with a name.
  • Turning off escapes for an old Java app. Accented letters will come out garbled under ISO-8859-1.
  • Expecting typed values. Every value in a .properties file is text.
  • Leaving secrets in the file. Keep passwords out of files you share or commit.

What next

Use this often? Add JSON to Prop to your Home screen.

Frequently asked questions

What does the JSON to properties converter do?

It turns a JSON object into a Java .properties file, with nested objects as dot-separated keys and special characters escaped the way Java reads them.

How are nested JSON objects converted?

Each level is joined with a dot, so {"server": {"port": 8080}} becomes server.port=8080.

How are arrays written?

As indexed keys such as tags[0]=web and tags[1]=api, or, if you choose, as one comma-separated value like tags=web,api.

Why are accented letters written as \u00E9?

Before Java 9, .properties files are read as ISO-8859-1, so non-ASCII characters must be \u escapes. Turn the option off for UTF-8 files.

Is my JSON uploaded?

No. The conversion happens in your browser, and nothing is sent or stored.

What went wrong?

We only receive the reason you pick, never what you typed into the tool.

Thanks for your feedback.

More Developer Tools