Formateador y Validador de YAML
Imprime en bonito, valida y reindenta YAML — archivos de múltiples documentos soportados.
Respuesta rápida: Formateador y Validador de YAML: mejora el formato, valida y vuelve a aplicar sangría a YAML; admite archivos con varios documentos. Funciona íntegramente en el navegador, gratis y sin registro.
Última actualización
Bueno saber
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.
Preguntas frecuentes
- ¿Qué versión de YAML soportas?
- YAML 1.2 a través de js-yaml, además de las peculiaridades de YAML 1.1 donde no entran en conflicto (por ejemplo, atajos booleanos). Los anclajes y los alias se preservan.
- ¿Sobrevivirán mis comentarios al formateo?
- No — js-yaml elimina los comentarios porque la especificación de YAML no los modela como parte de la estructura de datos. Si necesitas preservar comentarios, utiliza una herramienta de escritorio como prettier-plugin-yaml.
- ¿Cómo manejas archivos de múltiples documentos?
- Cada documento se analiza y se vuelve a emitir por separado, con separadores <code>---</code> entre ellos. La estructura de cada documento se preserva completamente.
- ¿Se han subido mis archivos?
- No — js-yaml se ejecuta completamente en tu navegador.
- ¿Por qué vuelve a citar algunas de mis cadenas?
- Las cadenas que contienen caracteres especiales (dos puntos, guiones iniciales, números similares a versiones) necesitan cita según la especificación de YAML — js-yaml agrega comillas solo donde es necesario para mantener el archivo válido.