Java Properties to YAML Converter

Convert a Java .properties or .env file to YAML or JSON and back, turning dotted keys into real nesting and quoting the values YAML would otherwise change.

Loading tool…

Everything is parsed and written by JavaScript in your browser. Nothing is uploaded, which matters for a config file: these usually hold database passwords and API keys.

What the Java Properties to YAML Converter does

The java properties to YAML converter on this page will convert a Java .properties or .env file to YAML or JSON and back, turning dotted keys into real nesting and quoting the values YAML would otherwise change. Everything runs inside this page, so the work happens on your own device rather than on a server. It is most often used for migrating a Spring Boot application.properties to application.yml. For a second version of this java properties to YAML converter, see FreeToolsWorld.org.

How to use it

  1. Paste your .properties, .env, YAML or JSON configuration.
  2. The format is detected automatically; override it if the guess is wrong.
  3. Pick what you want out, and change the key separator if yours is not a dot.
  4. Check the result, then copy or download it — or press the swap button to convert it straight back and see whether anything was lost.

How it works

These four formats describe the same thing and disagree about its shape. A .properties or .env file is a flat list of keys that fakes nesting with dots, while YAML and JSON nest for real. So the useful conversion is not a transliteration but a reshaping: db.host and db.port become one db mapping with two children, and flattening goes the other way. That is the whole job, and the part that makes a hand conversion of a large Spring Boot properties file tedious enough to get wrong.

Java .properties has more syntax than it looks like it has. The separator is the first unescaped =, : or run of whitespace, so url=http://host:8080/a=b has one key and a value containing both a colon and an equals sign. A key can contain either character if it is escaped — a\:b is the single key "a:b". A trailing backslash continues onto the next line with that line’s indentation stripped, so a long value can be wrapped. Both # and ! start a comment, but only at the beginning of a line. And because the format historically assumed ISO-8859-1, anything beyond Latin-1 is written as \uXXXX, which is why an accented character arrives looking like an escape. All of that is read here, and written back out when you convert in the other direction.

The YAML side has one trap that matters more than all the parsing: quoting. YAML readers turn an unquoted no into the boolean false, an unquoted 1.10 into the number 1.1, an unquoted 007 into 7, and an unquoted 12:30 into a sexagesimal number. A feature flag that said "no" becomes a boolean; a version pinned at 1.10 becomes 1.1, which is a different version; a PIN or a zero-padded port loses its zeros. Every value that would change meaning is quoted on output, and values that are safe bare are left bare so the file stays readable.

Lists are the other reshaping. A flat file writes an array as servers.0.host and servers.1.host, and leaving those as a mapping keyed "0" and "1" produces YAML that no reader treats as a sequence. A complete run of numeric keys starting at zero therefore becomes a real list; a run with a gap, or one starting at 1, is left as a mapping, because those keys are identifiers rather than indices. Going to .env, a list has to become numbered keys again, since the format has no notion of a list at all — and the page says so, because most .env libraries will not reassemble them.

One case cannot be converted and is reported instead of resolved. If a file contains both server=on and server.port=8080, it is asking for server to be a value and a parent at the same time, and no nested structure can be both. Either resolution silently discards one of the two settings, so the conflict is listed and you are asked to rename one. Round-tripping with the swap button is the quickest way to find anything else a conversion changed: convert, swap, convert back, and compare.

When to use it

  • Migrating a Spring Boot application.properties to application.yml.
  • Turning a .env file into the YAML a Docker Compose or Kubernetes manifest wants.
  • Flattening a YAML config back to .properties for a system that only reads those.
  • Converting a config to JSON to inspect or process it in a script.
  • Checking whether a conversion lost anything, by converting back and comparing.

Common mistakes to avoid

  • Leaving a value like no, yes, off or 1.10 unquoted in YAML, where it stops being a string.
  • Splitting a .properties line on the first = without allowing for escaped separators.
  • Losing a wrapped value by ignoring a trailing backslash continuation.
  • Leaving numeric keys as a mapping, so what should be a YAML list is not one.
  • Having a key that is both a value and a prefix, which no nested format can represent.
  • Assuming an .env file can hold a list. It cannot, and numbered keys are not a substitute.

Frequently asked questions

How do dotted properties keys become YAML nesting?

Each dot starts a new level. db.host and db.port become a single db mapping containing host and port. Converting back flattens the nesting into dotted keys again, so the round trip returns the file you started with.

Why are some values quoted in the YAML output?

Because YAML would otherwise change them. An unquoted no is the boolean false, 1.10 is the number 1.1, 007 is 7 and 12:30 is a sexagesimal number. Values whose meaning would change are quoted; values that are safe bare are left bare.

Does it handle escaped separators and line continuations in .properties?

Yes. a\:b is a single key containing a colon, the first unescaped separator is the one that splits the line, and a trailing backslash continues onto the next line with its indentation dropped. \uXXXX escapes are decoded on the way in and re-created on the way out.

What happens to a list?

A complete run of numeric keys from zero — servers.0, servers.1 — becomes a real YAML or JSON list. A run with a gap, or one starting at one, is treated as a mapping, because those keys are identifiers rather than indices. Converting a list to .env produces numbered keys, which most .env readers will not reassemble.

Why does it refuse a key that is used twice?

A file containing both server=on and server.port=8080 needs server to be a value and a parent at once, and no nested format can express that. Rather than silently dropping one setting, the conflict is listed so you can rename one of them.

Is my config uploaded anywhere?

No. All the parsing and writing is JavaScript running in your browser, and nothing is sent to a server. That matters here more than on most tools, because configuration files routinely contain database passwords and API keys.

Related tools

See all developer tools →