≣

YAML Formatter

Validate and format YAML, convert YAML to JSON, or convert JSON to YAML — all processed locally.

About this tool

Last updated:

Validate, format and convert YAML

This YAML formatter checks that your YAML is valid and rewrites it with clean, consistent indentation. It can also convert YAML to JSON and JSON to YAML. Everything is processed locally in your browser.

How to use it

  1. Choose a tab: Validate / Format, YAML → JSON or JSON → YAML. An example is filled in for each.
  2. Paste your own content into the input box.
  3. Click the button: Format YAML, Convert to JSON or Convert to YAML.
  4. Read the output and click Copy.

How it works

The tool parses your input with the js-yaml library. If parsing fails, the error message is shown in red. If it succeeds, the data is written out again, which is what produces the formatting.

TabOutput
Validate / FormatYAML with 2-space indentation and no line wrapping
YAML → JSONJSON indented with 2 spaces
JSON → YAMLYAML with 2-space indentation

Assumptions and limits

  • Comments are not kept. The tool re-creates the YAML from the data, so comments in the input are dropped.
  • Key order is kept, but quoting and list style may change to the library's defaults.
  • Several YAML documents separated by --- are supported. In YAML → JSON they become an array.
  • The indentation is fixed at 2 spaces. There is no option to change it.
  • Switching tabs replaces the input with that tab's example.

Frequently asked questions

Will formatting remove my comments?

Yes. Comments are not part of the parsed data, so they do not appear in the output. Copy them back by hand if you need them.

Does it work with multi-document YAML?

Yes. Format mode keeps the documents apart with ---. YAML → JSON returns a single value for one document, or an array for several.

What happens if my JSON is invalid?

In JSON → YAML mode you get an "Invalid JSON" message with the parser's reason, and no output.

More to explore

Related Developer Tools

Browse all tools from the same category.

Showing 1-2 of 49