YAML Formatter: Format and Normalize YAML Documents
Pretty-print, minify to flow style, and dump JSON-compatible YAML in the browser. This page implements a documented YAML 1.2 subset (maps, lists, plain/single/double scalars, nested indent, comments). Tags, anchors, aliases, and merge keys are refused with a line and column. Nothing leaves this page.
Drop a .yaml or .yml file here. Client-only FileReader. Nothing is uploaded.
No document.
Supported YAML 1.2 subset
This formatter parses YAML itself. It does not load js-yaml or any other library. Supported: block and flow maps; block and flow lists; plain, single-quoted, and double-quoted scalars; literal | and folded > block scalars; nested indentation; line and trailing comments on pretty YAML; multi-document streams with ---; JSON documents (JSON is valid YAML 1.2); Core schema types null, bool, int, float, and str. yes, no, on, off, and NO stay strings (YAML 1.2 Core, not YAML 1.1).
Refused with an error (never silently dropped): tags (!, !!, !<uri>), anchors (&name), aliases (*name), merge keys (<<), explicit complex keys (?), and %TAG directives. Tabs in indentation are errors. Duplicate keys are errors. The parser only builds JSON-safe maps, lists, strings, numbers, booleans, and null — it never constructs host objects.
How to read results
- Pretty YAML rewrites whitespace to 2 or 4 spaces. Comments are kept when they sit on their own line or trail a value.
- Compact flow YAML is one JSON-like line per document. Comments cannot be represented and are omitted, with a status note.
- JSON dump uses JSON.stringify after Core-schema resolution. .inf and .nan cannot be JSON and return an error. Quote them if you need strings.
- A parse error names line and column. key:value without a space is a plain string, not a mapping. Use key: value.
- Status uses an “OK:” or “Error:” prefix plus color, so success is not color-only.
Privacy
Formatting runs locally in this page. There is no network request, no account, and no persistent browser storage. File load uses FileReader in the browser. Reset clears the editors and options.