Home/JSON & Markup Tools/YAML formatter / validator

YAML formatter / validator

YAML Formatter and Validator

Supports YAML 1.2 (and JSON), keeps structure readable, and flags errors instantly.

0 → 0 bytes Waiting
InputPaste YAML or JSON
Output
Format live; choose output
Validates YAML 1.2 syntax Live formatting + JSON output Optimized for long payloads

How it works

Parses YAML (or JSON) and re-serializes it with your chosen layout. Pretty keeps 2-space indentation and wraps long lines; Compact removes most line breaks. Switch output mode to emit equivalent JSON when you need interoperable payloads.

  • Pretty uses 80-character line width; compact sets lineWidth to 0 for dense blocks.
  • Comments are not retained because the YAML parser drops them during parse.

Quick examples

Pretty YAML
name: api
ports: [80, 443]
name: api
ports:
  - 80
  - 443
YAML to JSON
env:
  region: us-east-1
  replicas: 2
{"env":{"region":"us-east-1","replicas":2}}

You can paste JSON directly; YAML 1.2 treats JSON as a valid subset.

Mini FAQ

Does it preserve key order?

Yes, parsed key order is kept when re-serializing to YAML or JSON.

Can I format multi-document YAML?

This tool handles a single document; split multi-doc files before pasting.

Why did comments disappear?

YAML comments are dropped by the parser, so they cannot be restored in output.