JSON:
{
"database": {
"host": "localhost",
"port": 5432,
"name": "myapp"
}
}
YAML:
database:
host: localhost
port: 5432
name: myapp
JSON:
{
"servers": ["web1", "web2", "web3"]
}
YAML:
servers:
- web1
- web2
- web3
JSON:
{
"services": [
{
"name": "api",
"ports": [8080, 8443],
"env": {"NODE_ENV": "production"}
}
]
}
YAML:
services:
- name: api
ports:
- 8080
- 8443
env:
NODE_ENV: production
Konvertieren Sie sofort mit unserem JSON-zu-YAML-Konverter.
YAML unterstützt Kommentare; JSON nicht. Bei der Konvertierung von YAML zu JSON gehen alle Kommentare verloren:
# This comment will be lost in JSON
database:
host: localhost # Also lost
YAML hat eine leistungsfähige Mehrzeilen-Syntax, die JSON fehlt:
description: |
This is a multi-line
string that preserves
line breaks.
In JSON wird daraus:
{
"description": "This is a multi-line\nstring that preserves\nline breaks.\n"
}
Beide unterstützen null, aber die Syntax unterscheidet sich:
value: null # Explicit
value: ~ # YAML shorthand
value: # Empty value = null
{ "value": null }
# JSON to YAML
python3 -c "import json, yaml, sys; print(yaml.dump(json.load(sys.stdin), default_flow_style=False))" < input.json > output.yaml
# YAML to JSON
python3 -c "import json, yaml, sys; print(json.dumps(yaml.safe_load(sys.stdin), indent=2))" < input.yaml > output.json
YAML ist für Konfigurationsdateien besser lesbar als JSON, besonders bei tief verschachtelten Strukturen. Viele Tools wie Docker Compose, Kubernetes, Ansible und GitHub Actions verwenden YAML für ihre Konfigurationsdateien.
Ja. Zahlen, Booleans, Strings, Arrays und verschachtelte Objekte werden alle korrekt konvertiert. YAML unterstützt nativ die gleichen Datentypen wie JSON, sodass bei der Konvertierung keine Informationen verloren gehen.
Die Verarbeitung erfolgt im Browser. Speichern und Teilen sind optional, erfordern ein Konto und übertragen den gewählten Inhalt an unseren Dienst.
Einzeldatei-Upload: 100 MiB. Laufzeit und Speicherbedarf hängen vom Gerät und der Komplexität der Datei ab.
Sie können die Einrückungsgröße (2, 4 oder 8 Leerzeichen) anpassen und den Flow-Stil für kompakte Inline-Formatierung von Arrays und Objekten umschalten.