YAML Formatter & Validator
Validate and format YAML, keep comments, convert to JSON. Runs in your browser.
About this yaml formatter & validator
This YAML formatter validates YAML and re-indents it without losing your comments. It also converts YAML to JSON and JSON to YAML, and it handles files with several documents separated by ---, like Kubernetes manifests and Helm output.
Errors come with a line, a column and a snippet, so a tab hiding in your indentation or a key at the wrong depth is quick to find. A second pass warns about values like on, no or 1:30 that YAML 1.1 tools read differently from YAML 1.2.
Everything runs in your browser. Config files often hold hostnames, tokens and database passwords, and none of that is sent anywhere.
Features
Format keeps comments
Format mode uses Prettier's YAML printer, which fixes indentation and spacing while keeping comments, anchors, aliases, quotes and document markers where you put them.
Normalize rewrites from the data
Normalize parses the YAML and writes it out fresh with js-yaml. You can sort keys A to Z, choose single or double quotes, quote every string, fold long strings and keep lists flush with their key. Comments do not survive this mode, and the page says so.
YAML to JSON and back
Several documents become a JSON array, JSON Lines (one document per line) or just the first document. Going the other way, a top-level JSON array can become separate YAML documents.
Errors you can act on
Duplicate keys, tabs in indentation, bad indentation and unclosed brackets each get a plain message, the line and column, and a snippet with a pointer. Go to error selects the spot in the input.
YAML 1.1 gotcha warnings
Unquoted yes, no, on and off are strings in YAML 1.2 but booleans in YAML 1.1. Values like 1:30 become base-60 numbers and 0755 becomes octal in 1.1. The tool flags the first few so you can quote them.
How to use the yaml formatter & validator
- 1Paste YAML or JSON, or open a file.
- 2Pick Format, Normalize, YAML → JSON or JSON → YAML and set the indent.
- 3Fix any error it points to, then copy or download the output.
When to use it
Fixing a Kubernetes manifest before kubectl apply
Paste a multi-document file, see the document count, and fix the line where a container's env block slipped two spaces.
Tidying a GitHub Actions or GitLab CI file
CI configs grow by copy and paste. Format evens out the indentation and keeps every comment that explains why a step exists.
Turning an API response into a config file
Switch to JSON → YAML, paste the JSON, and copy readable YAML. If you need other shapes such as CSV or XML, the JSON converter covers them.
Comparing two environments
Normalize both files with Sort keys on, then put them side by side in a text diff so only real changes show.
How do I validate YAML?
Paste it in. The parser follows the YAML 1.2 core schema, the current version of the spec, and stops at the first error. These cause most of the failures people search for:
- Tabs in indentation. YAML forbids tab characters for indentation, so an editor that inserts tabs breaks the file. Use spaces.
- A key indented differently from its siblings. Every key in one mapping must start in the same column.
- A colon inside an unquoted value, such as title: Note: read me. Quote the value.
- The same key twice in one mapping. Many parsers silently keep the last one; this tool reports it.
- An unclosed [ or { in a flow collection, often from a pasted JSON fragment.
What is the YAML Norway problem?
In YAML 1.1, plain values like yes, no, on, off, y and n are booleans. A list of country codes containing NO (Norway) turned into false, which gave the bug its name. YAML 1.2, published in 2009, dropped those words from the boolean set, so they are plain strings.
The trouble is that both versions are still in use. PyYAML and many older tools follow 1.1. js-yaml, which this page uses, follows 1.2. A value that reads as the string on here can arrive as true in a Python service. Quoting it, as value: "on", makes it a string everywhere.
YAML vs JSON: which should I use?
They describe the same kinds of data: maps, lists, strings, numbers, booleans and null. YAML adds comments, multi-line strings, anchors for reuse and several documents in one file, which is why people pick it for hand-edited config. JSON is stricter and faster to parse, which suits APIs.
YAML 1.2 is designed so that almost any JSON document is also valid YAML. You can paste JSON into the Format box and it validates. Going from YAML to JSON loses comments and anchors, because JSON has no way to express them.
Why use Mavros
| Mavros | Typical upload sites | |
|---|---|---|
| Comments when formatting | Kept | Often dropped by a parse and dump |
| Multi-document files | Counted, converted to array or JSON Lines | Only the first document, or an error |
| Errors | Line, column, snippet, jump to error | A raw parser message |
| YAML 1.1 vs 1.2 warnings | Flags on, no, 1:30 and octal-looking values | Not mentioned |
| Where your config goes | Stays in your browser | Often sent to a server |
Tips
- Kubernetes and Helm files usually indent lists under their key. If your team's files keep the dash flush with the key, tick Lists flush with their key in Normalize.
- A file with --- at the top and nothing after it counts as one empty document, which becomes null in JSON.
- Use Normalize with Sort keys before committing generated YAML, so diffs in review only show real changes.
- Checking a schedule in a CI file? Paste the cron string into the cron expression parser to read it in plain English.
Questions
How do I format YAML online?
Paste your YAML into the input and the formatted version appears on the right. Format mode keeps comments; Normalize rewrites the file from the parsed data with options such as sorted keys.
Can YAML use tabs?
No. The YAML spec forbids tab characters in indentation, and parsers reject them. Tabs are allowed inside values and quoted strings, just not as the spaces that set nesting.
Is JSON valid YAML?
Almost always, yes. YAML 1.2 was designed as a superset of JSON, so a normal JSON file parses as YAML with the same data. Rare edge cases involve very unusual escape sequences.
How do I convert YAML to JSON?
Choose YAML → JSON, paste your YAML and copy the JSON. If the file has several documents, pick whether they become one array, JSON Lines, or only the first document.
Why did my comments disappear?
You are probably in Normalize or a conversion mode. Those rebuild the file from parsed data, and parsed data has no comments. Switch to Format to keep them.
What does --- mean in YAML?
It starts a new document in the same file. Kubernetes uses it to put a Deployment and a Service in one manifest. A line with ... ends a document, though most files never use it.
Why does yes or on turn into true in my app?
Your app's parser follows YAML 1.1, where those words are booleans. This tool follows YAML 1.2 and flags them. Put the value in quotes and every parser reads it as a string.
Is my YAML uploaded?
No. Validation, formatting and conversion run in your browser tab, and the address bar keeps only your mode and indent, never the file.