How to use the yaml to properties converter
- Paste your YAML text into the input area.
- The tool parses the YAML subset and flattens all nested structures automatically.
- Copy the resulting
.propertiesoutput for use in your Java or Spring application.
How the conversion works
A Java properties file stores configuration as flat key=value pairs. When you convert yaml to properties, nested YAML mappings are joined with dots. For example, a mapping server: containing host: localhost becomes server.host=localhost.
Sequences (lists) are indexed with brackets. A list under ports: with values 80 and 443 becomes ports[0]=80 and ports[1]=443. This matches the relaxed binding conventions used by frameworks like Spring Boot.
The algorithm walks the parsed tree recursively. At each node it appends the current key to a running prefix separated by a dot. When it reaches a leaf scalar, it emits the full prefix followed by an equals sign and the escaped value. Arrays insert a bracketed index instead of a dot before recursing further.
Supported YAML subset
The parser handles the most common YAML 1.2 features found in configuration files:
- Block mappings (nested key-value pairs indented with spaces)
- Block sequences (lines starting with
-) - Flow sequences
[a, b]and flow mappings{k: v} - Plain, single-quoted and double-quoted scalars
- Block scalars using literal
|and folded>indicators - Comments starting with
#
If you need to check whether your file uses valid syntax before converting, run it through a YAML validator first. The parser intentionally limits itself to these constructs because they cover the vast majority of application configuration without requiring a full graph resolver.
Unsupported features
To guarantee correct output rather than silently producing wrong data, several advanced YAML features are explicitly rejected. If your input contains any of these, the tool will return an error message instead of a partial result:
- Anchors (
&name) and aliases (*name) - Tags (
!!str,!custom) - Merge keys (
<<) - Multi-document streams separated by
---
These features require a full YAML graph resolver. Anchors and aliases allow nodes to reference each other, which means the final value depends on document order and pointer resolution. Tags can change how a scalar is interpreted. Rather than guess and produce incorrect properties, this converter fails fast. For simpler tasks like reformatting, consider a YAML formatter or YAML lint tool.
Escaping special characters
In the properties format, certain characters have special meaning and must be escaped in values. The converter automatically handles this:
| Character | Escaped form |
|---|---|
| Newline | \n |
| Carriage return | \r |
| Tab | \t |
| Backslash | \\ |
Keys rely on dot separation for hierarchy, so a YAML key that itself contains a dot cannot be told apart from nesting. Spaces, =, :, # and ! inside a key are backslash-escaped so Java reads the key correctly. Characters outside printable ASCII (accents, emoji) are written as backslash-u escapes with four hex digits, which is what java.util.Properties and Spring Boot expect for ISO-8859-1 files, a leading space in a value is escaped, and numbers are copied exactly as written. Leading and trailing whitespace in plain scalars is trimmed according to YAML rules. Double-quoted scalars process standard escape sequences like \n and \t during parsing, so the resulting string already contains real newlines which are then re-escaped for the properties output.
Common use cases
Converting yaml to properties is frequently needed when migrating configuration between ecosystems. Spring Boot applications accept both formats, but some legacy Java libraries only read .properties files. Developers often maintain a single source of truth in YAML and generate the properties file during the build step.
Another scenario involves container orchestration where environment variables are injected from a properties file generated at startup. Teams that share configurations across polyglot microservices may keep a master YAML file and derive language-specific formats from it. Other related conversions include transforming YAML into JSON for web APIs, or converting XML to YAML when modernizing older enterprise configurations. You can also minify YAML to reduce file size before processing.
Worked examples
| Example | Input | Result |
|---|---|---|
| Nested server config | YAML input: server: / host: localhost / port: 8080 / ssl: true | server.host=localhost / server.port=8080 / server.ssl=true |
| List of items | YAML input: fruits: / - apple / - banana / - cherry | fruits[0]=apple / fruits[1]=banana / fruits[2]=cherry |
| Flow collections | YAML input: tags: [web, api] / limits: {max: 100, min: 1} | tags[0]=web / tags[1]=api / limits.max=100 / limits.min=1 |
FAQ
Does this tool upload my configuration to a server?
No. The entire yaml to properties conversion runs locally in your browser using JavaScript. Your data never leaves your machine.
How are nested YAML keys represented in properties?
Nested keys are flattened using dot notation. A key 'database' containing 'host' becomes 'database.host' in the properties output.
How are YAML lists converted?
Lists are converted using zero-based bracket indices. A list named 'items' with two elements produces 'items[0]' and 'items[1]'.
Why does my YAML produce an error about anchors?
Anchors and aliases are not supported because resolving them requires a full document graph. The tool fails explicitly rather than returning incorrect properties.
Are multiline strings preserved?
Yes. Block scalars defined with '|' or '>' are parsed and newlines within them are escaped as '\n' in the properties value.
Can I convert properties back to YAML?
This tool only converts in one direction. To go from properties to YAML, you would need a separate reverse converter or write a script to parse the dot notation.