YAML Formatter / Validator
Format, validate YAML files, and convert YAML ↔ JSON. Powered by js-yaml: handles nesting, anchors, multiline strings.
Why your YAML indentation breaks
YAML uses indentation to express structure, and it forbids tab characters for that indentation entirely. An editor configured to insert tabs produces a file that looks correctly aligned and fails to parse with a message about an unexpected character. Paste the file above and the parser points at the offending line.
The second common cause is inconsistent depth. YAML does not require a specific number of spaces, but it requires that siblings agree. Two keys at what looks like the same level but sit at three and four spaces are parent and child, not siblings, which is how a CI job silently becomes a property of the job above it and never runs.
The YAML values that are not what they look like
YAML infers types, and its inference surprises people. Converting the document to JSON is the fastest way to see what a parser actually produced rather than what you meant.
| You wrote | A parser may read | Fix |
|---|---|---|
country: NO | boolean false: the Norway problem | Quote it: "NO" |
version: 1.10 | the number 1.1 | Quote it: "1.10" |
code: 012 | octal in YAML 1.1 parsers | Quote it |
time: 12:30 | a sexagesimal number in older parsers | Quote it |
value: yes | boolean true | Quote it if you meant the word |
id: 0x1F | the number 31 | Quote it |
| Empty value | null, not an empty string | Write "" if you meant empty |
Each of these has caused a real production incident somewhere. When a config value behaves oddly, convert the YAML to JSON before assuming the application is at fault.
Converting YAML to JSON for tests and tooling
YAML is a superset of JSON in practice, so any YAML document that uses only supported constructs converts cleanly. This is useful in three testing situations: turning a docker-compose or GitHub Actions file into JSON so you can query it with a JSON path expression, converting a hand-written YAML fixture into the JSON body an API actually expects, and comparing a YAML config against a JSON config from another environment by putting both in the same format first.
Anchors and aliases are the one construct that does not survive the trip unchanged. A reference is expanded into a full copy of the referenced value, so the JSON output is larger and the deliberate sharing is gone. That is correct behaviour and usually what you want for inspection, but do not convert back and expect the original file.
Validating a CI configuration before you push it
- Paste the workflow or pipeline file and confirm it parses. A syntax error here costs a full push-and-wait cycle to discover.
- Convert to JSON and check the nesting is what you intended: that every job really is a sibling of every other job.
- Look for unquoted values from the table above, especially version numbers and anything that could read as a boolean.
- Check multi-line strings. A block scalar written with the wrong indicator silently changes whether trailing newlines are kept, which matters for scripts.
Parsing happens in your browser. CI configuration frequently contains internal hostnames, account identifiers and the names of unreleased services, so nothing here is uploaded.
What a syntax check does not cover
Valid YAML is not a valid configuration. A GitHub Actions file can parse perfectly while naming a step that does not exist; a Kubernetes manifest can parse while failing schema validation on a field name. Syntax validation is the first gate, and schema validation against the tool that consumes the file is the second. Passing the first tells you only that the document is well-formed.
Frequently asked questions
Can YAML use tabs for indentation?
No. The specification forbids tab characters in indentation. Configure your editor to insert spaces for YAML files, two spaces is the common convention, and enable a setting that makes whitespace visible.
What is the Norway problem in YAML?
Older YAML parsers read the unquoted value NO as the boolean false, so a list of country codes turns Norway into false. The same applies to ON, OFF, YES and Y. Quoting any value that must stay a string avoids the whole family of problems.
Is YAML valid JSON?
The other way round: JSON is essentially a subset of YAML, so most JSON parses as YAML. YAML is not valid JSON, because JSON has no comments, no anchors and no indentation-based structure.
Why did my version number change after parsing?
Because an unquoted 1.10 is a number, and the number one-point-one-zero equals one-point-one. Pin versions as quoted strings in every configuration file to avoid a dependency resolving to the wrong release.
How do I write a multi-line string in YAML?
Use a block scalar: the pipe character keeps newlines, the greater-than character folds them into spaces. Adding a minus after either strips the trailing newline, and a plus keeps all of them. For shell scripts in CI files the pipe form is almost always what you want.
Is it safe to paste a config file into an online YAML tool?
Only when the tool does not transmit it, because configuration files are a common place for internal hostnames and credentials. This one parses in the browser and sends nothing. As a habit, strip secrets before pasting a config anywhere regardless of the tool.