What you can convert here
| Button | From → To |
|---|---|
| Convert to YAML | JSON or XML → YAML |
| Property to YAML | key=value lines from a .properties file → nested YAML |
| YAML to Property | Nested YAML → flat key=value lines |
Spring Boot: application.properties to application.yml
Spring Boot reads both files the same way. Dotted keys in a properties file turn into nested blocks in YAML:
server.port=8080
spring.datasource.url=jdbc:postgresql://localhost/app
spring.datasource.username=app
becomes
spring:
datasource:
username: app
url: jdbc:postgresql://localhost/app
server:
port: 8080
The order of keys can change along the way. Spring doesn't care about order, but reorder by hand if you want the file to read top-down. Comments in the properties file are not carried over.
Going the other way, lists become numbered keys: a YAML list under hosts: turns into hosts[0]=… and hosts[1]=…, which is the form Spring expects in a properties file.
Why some keys get quotes
Convert {"country": "no", "y": 2, "on": true} and you'll get:
country: "no"
"y": 2
"on": true
The quotes are deliberate. Older YAML parsers read words like y, n, yes, no, on and off as true or false. Without the quotes, the country code for Norway would turn into false. Quoting keeps them as plain text in every parser.
YAML indentation in short
- Indent with spaces, never tabs.
- Children are indented further than their parent. Two spaces is the usual choice.
- A list item starts with a dash and a space:
- item. - Strings rarely need quotes, except when they contain
:, start with a character like*,&or#, or look like a number or boolean.
Frequently asked questions
Is JSON valid YAML?
Yes. YAML 1.2 is a superset of JSON, so any JSON document is also valid YAML. That is also why converting JSON to YAML never loses data. The reverse isn't true: YAML has comments, anchors and multiple documents per file, which JSON can't express.
Should I use application.properties or application.yml?
Both behave the same at runtime. YAML is easier to read when many settings share a prefix. Properties files are easier to override one line at a time and to search with grep.
Does the converter keep comments?
No. JSON has no comments to begin with, and comments in a properties file are dropped during conversion. Add them back to the YAML by hand if you need them.