YAML Formatter
Paste YAML to validate its structure and format it for review. Processing stays local in your browser, with errors kept next to the input so you can fix the exact line.
service:
name: gizmobench
port: 8080
debug: "yes"
tags:
- b
- a
retries: 3
Valid: no problems, 1 document, read as YAML 1.2 core.
The data this document resolves to
The data this document resolves to under the YAML 1.2 core schema, printed as JSON.
{
"service": {
"name": "gizmobench",
"port": 8080,
"debug": "yes",
"tags": [
"b",
"a"
]
},
"retries": 3
}- error at 4:1, first at 2:1
- debug is the string "yes"
- stopped at 5:8, nothing parsed
The YAML this page reads
The reader here was written for this page rather than taken from a library, so the honest thing is to publish what it handles. The first list is what it reads. The second is what it reports by name instead of guessing at, which is the part a validator usually leaves you to find out.
Read
- Block mappings and block sequences, nested to any depth this page reads
- Compact sequence items (a mapping that starts on the dash line)
- Flow collections: [1, 2] and {a: 1}, including empty and multi-line ones
- Plain, single-quoted and double-quoted scalars, with the double-quoted escapes
- Block scalars: | and >, with the - and + chomping indicators
- Anchors, aliases and a counted expansion budget
- Several documents in one file, separated by --- and ...
- Comments, counted and kept out of the data
- The core schema tags !!str, !!int, !!float, !!bool, !!null, !!map and !!seq
- An explicit !!bool accepts the older yes, no, on and off spellings
Reported, not read
- Merge keys: << is reported as a warning and left as an ordinary key, not merged
- The explicit key form: a line that starts with ? is reported, not read
- A quoted scalar spread over several lines: use a block scalar instead
- Custom and language tags, including !!binary: reported by name, never resolved
- %TAG directives and tag shorthands beyond the core set
- Comments in format mode: the formatter re-prints the parsed data, so comments are counted and dropped
- Timestamps, sexagesimals and the other YAML 1.1 types: they stay strings, which is what YAML 1.2 core says
Every problem this page can report
All 17 of them, each with the line and the column of what it found. A warning is a note about how something resolved and leaves the document valid; an error does not.
| Code | Kind | What it means |
|---|---|---|
| tab-indent | error | A tab is used to indent a line. YAML never allows one. |
| bad-indent | error | A line does not line up with the block it is in. |
| bad-value | error | A line is not a key and a value, or there is more after the value ends. |
| duplicate-key | error | The same key appears twice in one mapping. Both lines are named. |
| unclosed-quote | error | A quoted scalar is not closed on its line. |
| bad-escape | error | A double-quoted scalar carries an escape YAML does not define. |
| unclosed-flow | error | A [ or { is never closed. |
| flow-syntax | error | A flow collection is missing a comma or a closing bracket. |
| explicit-key | error | The explicit key form, a line starting with ?, is not read here. |
| undefined-alias | error | An alias names an anchor that was never defined above it. |
| alias-budget | error | Alias expansion passed the node budget, so nothing was parsed. |
| unsupported-tag | error | A tag outside the core schema is refused by name and never resolved. |
| tag-mismatch | error | A core tag does not fit its value, such as !!int on a word. |
| depth | error | Nesting goes deeper than this page reads. |
| merge-key | warning | The merge key << is a YAML 1.1 extension and stays an ordinary key here. |
| directive | warning | A directive line is noted; only %YAML is understood. |
| stopped | error | The reader stopped early because it could not make progress. |
Up to 500,000 characters in one pass, read here in your browser with nothing uploaded and no account. Nothing in the document is ever run or fetched: a tag is a string to the reader, a URL is a string, and alias expansion stops after 10,000 copied nodes. Nesting is read 100 levels deep, and the data panel prints the first 20,000 characters of the result. The mode, the two format options and the draft are kept in this browser alone, drafts up to 100,000 characters, and the Start over control above the tool forgets them.
Common questions
- Can I format YAML without uploading it?
- Yes. Parsing and formatting happen locally in the browser.
Read by a YAML 1.2 core-schema parser written for this page, so yes and no are strings, only true and false are booleans, and every problem carries a line and a column. Alias expansion stops at a fixed budget rather than hanging the page, a tag outside the core set is refused by name, and the subset this parser reads is listed under the tool. Your document is read in this browser and nothing it names is ever fetched.