YAML to Properties Converter

Runs locally

Flatten application.yml into application.properties — dotted keys, [0] indexes, #--- documents.

YAML

Properties

2 documents

spring.application.name=orders
# Datasource — the placeholder is resolved by Spring at startup
spring.datasource.url=jdbc:postgresql://${DB_HOST:localhost}:5432/orders
spring.datasource.username=orders_app
server.port=8080
app.greeting=Caf\u00e9 ouvert
app.cors.allowed-origins[0]=https://app.example.com
app.cors.allowed-origins[1]=https://admin.example.com
#---
spring.config.activate.on-profile=prod
server.port=80
 
Guide

Flattening YAML the way Spring does

Spring Boot turns application.yml into flat keys before binding them, and this converter produces the same keys: each level of nesting becomes a dot, and each list item gets an index in brackets, so app.cors.allowed-origins becomes app.cors.allowed-origins[0] and [1]. Anchors, aliases and <<: merges are expanded first, because .properties has no way to share values. Full-line comments are carried across above the first key they describe; comments at the end of a line are dropped.

A multi-document YAML file — documents separated by --- — becomes a .properties file split with #---, which Spring Boot 2.4 and later reads as separate documents, each with its own spring.config.activate.on-profile. ${…} placeholders are copied as they are. Choose the separator style your team uses: key=value, key: value or key = value all mean the same to java.util.Properties.

Encoding is the part that bites. java.util.Properties and Spring Boot read .properties files as ISO-8859-1, so an é saved as UTF-8 is read as two garbage characters. By default the converter writes non-ASCII characters as \uXXXX escapes, which every reader decodes the same way. To check the result for duplicate or suspicious keys, paste it into the Properties Viewer; to see the YAML as data, convert it to JSON.

application.yml

app:
  # shown on the login page
  title: Café Élan
  ports: [8080, 8443]

application.properties

# shown on the login page
app.title=Caf\u00e9 \u00c9lan
app.ports[0]=8080
app.ports[1]=8443

The comment moves with the key it describes, and the accented letters are escaped so the file is safe as ISO-8859-1.

How each .properties construct maps to YAML, and back
.propertiesapplication.ymlNotes
server.port=8080server: port: 8080Each dot is one level of nesting
app.hosts[0]=a app.hosts[1]=bapp: hosts: - a - b[n] indexes become a list, in index order
app.servers[0].port=9000app: servers: - port: 9000Objects inside lists work the same way
#------Starts a new document (Spring Boot 2.4+)
spring.config.activate.on-profile=prodspring.config.activate.on-profile: prodActivates that document for a profile
url=${DB_HOST:localhost}url: ${DB_HOST:localhost}Placeholders are copied verbatim; Spring resolves them
name=Caf\u00e9name: CaféEscapes decoded to YAML; re-escaped for .properties
flag=onflag: 'on'Quoted: SnakeYAML would read on as true
# comment# commentKept above the key that follows it

Where people get caught

UTF-8 characters in .properties

Spring Boot reads .properties as ISO-8859-1. Keep \uXXXX escaping on unless you have configured your loader for UTF-8.

Map keys that contain dots

A YAML key such as "example.com": true inside a map becomes a longer dotted key. Spring needs [brackets] to keep the dot: app.hosts[example.com]=true.

Empty values

key: (null) and key: [] both become key= with an empty value. Spring binds that as an empty string, not as null.

Anchors are expanded

Shared blocks defined with & and reused with * or <<: are written out in full for every key that uses them, so the .properties file is longer than the YAML.

About converting YAML to .properties

How it works in 4 steps · 4 common use cases · 4 questions answered

How it works

  1. 1.Paste or drop an application.yml file.
  2. 2.Choose the separator, and whether to escape non-ASCII and keep comments.
  3. 3.Each YAML document becomes a #--- section.
  4. 4.Download application.properties or swap direction to convert back.

Common use cases

  • •Moving configuration from application.yml to .properties
  • •Getting the exact key names to set as environment variables or -D flags
  • •Flattening a YAML config for a tool that only reads properties
  • •Reviewing which keys a large YAML file actually sets

FAQ

How are YAML lists converted?

Each item gets an index: hosts: [a, b] becomes hosts[0]=a and hosts[1]=b. Lists of objects become keys like servers[0].port.

Why are accented characters written as \u00e9?

Spring Boot and java.util.Properties read .properties files as ISO-8859-1. \uXXXX escapes are read the same way everywhere. Untick the option to write the characters directly.

Are comments kept?

Full-line comments are, placed above the first key they describe. Comments at the end of a line are dropped.

Does it handle Spring profiles?

Yes. Each YAML document separated by --- becomes a #--- document, keeping its spring.config.activate.on-profile key.