Skip to content
OddsockLocal
Local
Source text

Formatting

4 wordsRuns in this browser. Nothing is uploaded.

How to use

  1. Paste YAML.
  2. Read the reprinted document.
  3. If the parser names an error, the indent or the quoting is illegal. The page does not guess.
  4. Use YAML and JSON when you need the object form or the reverse.

What is YAML formatter?

YAML formatter parses the document and prints it again, which normalizes indentation and quoting without changing the values. color: red and count: 2 come back as color: red and count: 2, a two-key mapping. A list that was written with uneven spaces is reprinted in the library’s usual style. The page is doing a parse, so a tab in the wrong place or a broken indent fails with the parser’s message instead of a half-formatted file.

Read more

Anchors and aliases are allowed up to a limit of 100 expansions, which stops a malicious alias loop from hanging the tab. The reprint is one document’s text. This page does not convert to JSON. The YAML and JSON page does that, in both directions, and its to-json result for the same mapping is an object with color and count.

A plain sentence such as Odd socks in the dryer. is valid YAML: it is a single string, and the reprint is that string. If you meant a mapping, the sentence is the wrong shape, not a broken parser.

Use cases

  • A config was edited by three people and the indent should be rewritten before a diff.
  • You want a parse error for a bad indent rather than a file that looks formatted and is not valid.
  • A mapping of color and count should survive a round trip as those two keys.
  • You need the YAML, not the JSON object. Conversion is the other page.

A two-key mapping, reprinted

color: red\ncount: 2

color: red\ncount: 2

Why use Oddsock

Reprinting from the parse tree drops insignificant indent differences and still fails closed on YAML the parser will not accept.

Related tools

Using this tool

A plain scalar is valid YAML. Odd socks in the dryer. reprints as that string. It is not a mapping, and it is not an error.