YAML-Formatierer und -Validator
Schön drucken, validieren und neu einrücken von YAML — Multidokument-Dateien unterstützt.
Kurze Antwort: YAML-Formatierer und -Validator: YAML übersichtlich formatieren, prüfen und neu einrücken – Dateien mit mehreren Dokumenten werden unterstützt. Läuft vollständig im Browser, kostenlos und ohne Anmeldung.
Zuletzt aktualisiert
Gut zu wissen
YAML's whole appeal is human readability, and that hinges entirely on indentation — a single stray space can move a key into the wrong parent and change the meaning of a Kubernetes manifest or a CI workflow without any visible error. Running a file through this formatter re-emits it with consistent indentation and no trailing whitespace, so structural mistakes that were hiding in ragged spacing become obvious.
It validates as it goes: if the document can't be parsed, you have a real structural problem to fix before deploying, which is far cheaper to catch here than in a failed pipeline run. Multi-document files separated by --- are handled correctly, with each document parsed and re-emitted on its own — the common shape for Kubernetes bundles.
The trade-off to know about is comments. The standard JavaScript YAML parser treats data as data, and comments aren't part of the data model, so they are dropped on reformat. If your YAML relies on inline documentation, keep a commented master copy or use a comment-preserving desktop formatter for that file.
Don't be surprised when some strings come back quoted — values that look like booleans, versions, or that start with a dash need quoting to stay valid, and the emitter adds quotes only where the spec demands. To move the data into JSON, hand it to the JSON ↔ YAML converter.
Häufig gestellte Fragen
- Welche YAML-Version unterstützen Sie?
- YAML 1.2 über js-yaml, plus YAML 1.1 Besonderheiten, wo sie nicht in Konflikt stehen (z.B. Boolean-Kurzschreibweise). Anker und Aliase werden beibehalten.
- Werden meine Kommentare das Formatieren überstehen?
- Nein — js-yaml entfernt Kommentare, da die YAML-Spezifikation sie nicht als Teil der Datenstruktur modelliert. Wenn du Kommentare beibehalten möchtest, benutze ein Desktop-Tool wie prettier-plugin-yaml.
- Wie gehen Sie mit Mehrdokuments-Dateien um?
- Jedes Dokument wird separat analysiert und erneut ausgegeben, mit <code>---</code> Trennzeichen dazwischen. Die Struktur jedes Dokuments wird vollständig beibehalten.
- Wurden meine Dateien hochgeladen?
- Nein — js-yaml läuft vollständig in deinem Browser.
- Warum zitiert es einige meiner Strings neu?
- Strings, die Sonderzeichen (Doppelpunkt, führende Bindestriche, versionähnliche Zahlen) enthalten, müssen gemäß der YAML-Spezifikation in Anführungszeichen gesetzt werden — js-yaml fügt Anführungszeichen nur dort hinzu, wo es nötig ist, um die Datei gültig zu halten.