ETEvoraTools
XML & YAML Tools

YAML Formatter

YAML Formatter loads the document with js-yaml and re-emits its data with two-space indentation, line width 100, and noRefs enabled. Comments, anchors/aliases as authored, tag/style choices, quoting, directives, and original key layout are not preserved; aliases can be expanded as repeated data. Parsing follows the library schema rather than application-specific types, so formatting is a data round trip, not a source-preserving beautifier.

Runs locally — files stay on your device
Quick answer

Are YAML comments preserved?

No.

YAML formatting reparses and reserializes data

YAML has multiple equivalent styles plus comments, anchors, tags, and scalar typing rules. A data loader discards much of that source representation.

How it works

yaml.load creates JavaScript data; yaml.dump writes it with fixed indentation/line-width settings and references disabled.

Key concepts

Comments disappear

They are not part of the loaded data value.

Aliases can expand

noRefs prevents re-emitting shared references.

When to use it

  • Normalize a small configuration after accepting source loss.
  • Inspect a compact YAML data structure.
  • Produce consistent basic indentation.

When not to use it

  • Do not format files where comments or anchors must remain.
  • Do not assume application schema validation.
  • Do not process unsafe/untrusted custom semantics without review.

Worked examples

Mapping

Input
a: 1\nb:\n - x
Expected output
Two-space normalized YAML

Style is rewritten.

Comment

Input
# note\na: 1
Expected output
a: 1

Comment is lost.

Anchor

Input
Defaults reused by alias
Expected output
Possibly duplicated content

Original reference syntax is not retained.

Common mistakes

Overwriting commented config

Human guidance disappears. Correction: Keep source or use a CST-preserving formatter.

Expecting lint only

Output is regenerated. Correction: Use a validator when no rewrite is wanted.

Ignoring typed scalars

Library schema interprets values. Correction: Test application semantics.

Best practices

  • Use version control.
  • Review a semantic diff and comments before replacement.
  • Validate with the target application.

Related operations and differences

JSON Beautifier

Choose JSON Beautifier when you need to format JSON with readable indentation.; use YAML Formatter specifically for yaml format.

XML Formatter

Choose XML Formatter when you need to indent XML markup for readability.; use YAML Formatter specifically for yaml format.

CSV Formatter

Choose CSV Formatter when you need to normalize CSV quoting and row structure.; use YAML Formatter specifically for yaml format.

JSON to YAML

Choose JSON to YAML when you need to convert JSON data into readable YAML.; use YAML Formatter specifically for yaml format.

YAML to JSON

Choose YAML to JSON when you need to convert YAML data into formatted JSON.; use YAML Formatter specifically for yaml format.

YAML Validator

Choose YAML Validator when you need to validate YAML syntax locally.; use YAML Formatter specifically for yaml format.

Limitations and privacy

  • No comment/style/directive/anchor preservation.
  • Fixed dump settings; no application schema, multi-document workflow, CST, custom tag policy, or source mapping.

The pasted data is parsed and transformed locally in this browser.

Frequently asked questions

Are comments retained?

No.

Is indentation fixed?

Two spaces.

Are anchors retained?

Not as authored; noRefs disables reference emission.

Does valid YAML guarantee valid configuration?

No.

References