JSON

YAML Formatter & Validator

Format and check YAML syntax in your browser, keeping comments and structure.

Ctrl/Cmd+Enter to format

YAML input

Result

Paste or type some YAML to begin

Comments, anchors, block scalars and multi-document streams are preserved. Validation updates automatically after you stop typing.

YAML is checked and formatted locally in your browser. Input and output are not uploaded, saved to browser storage, or included in analytics events.

Your data stays private

This tool runs directly in your browser. The content you enter is processed locally and is not sent to TechFixGen servers. No account or signup is required.

YAML Formatter & Validator, explained

What does the YAML Formatter do?

YAML is a human-readable data format: it uses indentation instead of braces and commas, and it is what Kubernetes manifests, GitHub Actions workflows and Docker Compose files are written in. Because indentation is the structure, a stray space or tab can change what a file means.

This tool parses your YAML and prints it back out with consistent indentation. Validation runs live as you type, and Format rewrites the document on demand. Both happen entirely in your browser.

How to format YAML

  1. Paste or type the YAML you want to tidy up, or press Load sample.
  2. Choose an indentation width: 2 spaces or 4 spaces.
  3. Press Format (or Ctrl/Cmd + Enter) to rewrite it.
  4. Read the result in the output panel and press Copy.
  5. If the document is invalid, the error alert gives the exact line and column so you can jump straight to it.

What formatting preserves

The formatter re-prints the parsed document rather than round-tripping a plain JavaScript value, so the things that matter in a hand-written YAML file survive:

  • Comments, including full-line comments and comments that trail a value.
  • Key order as you wrote it — YAML mappings are ordered, so the file is not alphabetised.
  • Block scalars written with | or >, with their line breaks and trailing-newline style intact.
  • Anchors and aliases (&name and *name), which are kept as written and never expanded.
  • Explicit tags such as !Ref, kept verbatim.
  • Multi-document streams — every --- separated document is formatted, and the document count is reported.

Long values are never re-wrapped: line folding is disabled, so a long URL or message stays on the line you wrote it on.

What validation checks — and what it does not

Validation answers one question: does this parse as YAML? It reports the first problem with its line and column. It is a syntax check, not a schema check.

Two deliberate limits are worth knowing:

  • No merge keys. The YAML 1.2 core schema treats << as an ordinary key rather than expanding it, so it is printed exactly as written.
  • No schema validation. There is no JSON Schema, no Kubernetes schema check and no field-level verification.

Parsing uses the core schema, which has no JavaScript-specific tags, so nothing in your document can be turned into code and executed. Because aliases are never resolved, a document that would explode under naive expansion stays completely inert.

YAML 1.2 core schema and the yes/no trap

YAML 1.1 treated yes, no, on and off as booleans. YAML 1.2 core does not — they are strings. That difference is the cause of a whole family of “my config stopped working” bugs, so it is worth stating plainly:

  • yes, no, on, off stay strings.
  • Only true and false are booleans, and only null and ~ are null.
  • A date such as 2024-01-01 stays a string — the core schema has no timestamp type.
  • The core schema also has no octal or sexagesimal numbers, so 0o17 and 1:30 are plain strings rather than numbers.

This tool reads YAML 1.2 core. If your pipeline uses a YAML 1.1 parser, quote those values to be safe — the YAML to JSON converter shows exactly how the same file is interpreted.

Common YAML syntax errors

Almost all broken YAML fails for one of these reasons:

  • Tab characters used for indentation

    YAML forbids tab characters where indentation is expected. A tab may still appear inside a quoted or block scalar's content.

    Fix: Replace the leading tabs with spaces. Pick 2 or 4 spaces and use it consistently.

  • Duplicate mapping keys

    The same key appears twice in one mapping. Different tools disagree about which value wins, so the formatter refuses the document instead of guessing.

    Fix: Rename or delete one of the keys. If you meant to combine values, use a list or a YAML 1.1 merge key written out longhand.

  • Bad indentation

    A mapping, sequence or block scalar sits at a column that does not line up with its parent, or compact nested mapping is written on one line.

    Fix: Indent each level by a consistent number of spaces, and never indent a sequence entry less than the key it belongs to.

  • Unclosed quotes or brackets

    A quoted scalar or a flow collection such as [a, b] or {a: 1} is never closed.

    Fix: Close every quote, and make sure each [ has a ] and each { has a }.

  • Unexpected end of input

    A block scalar introduced with | or > never ends because the next line is indented at least as far.

    Fix: End the block scalar with a line that is less indented, or use |- or >- to strip the trailing newline.

Privacy

Parsing and formatting run locally in your browser. The YAML you paste is never uploaded to TechFixGen servers, is not written to browser storage, and is not included in analytics events — no account or signup is required.

Frequently asked questions

Does this upload my YAML?

No. Parsing, validation and formatting all run locally in your browser. Your YAML is never uploaded to TechFixGen servers, is not saved to browser storage, and is not included in analytics events.

Are my comments preserved?

Yes. Full-line comments, comments that trail a value, and comments that introduce a block are all printed back exactly where they were. Formatting re-prints the parsed document rather than rebuilding it from plain data, which is what keeps comments and key order intact.

Does formatting change what my data means?

No. Only whitespace and quoting style change. Values, key order, comments, anchors, aliases and block scalars are preserved. Long values are never re-wrapped because line folding is disabled, and the result always ends with exactly one newline.

Does it support multi-document YAML?

Yes. Every --- separated document in the stream is parsed and formatted, and the result reports how many documents were found. Document markers are kept where they were written.

Are anchors and aliases resolved?

No, and deliberately so. Anchors (&name) and aliases (*name) are preserved as written and never expanded. That means a document containing an alias bomb stays completely inert — there is no exponential expansion to exhaust memory.

What happens if the same key appears twice?

The document is rejected and the error names the line and column of the second occurrence. Different YAML tools disagree about which value wins, so the formatter refuses to guess. Rename one of the keys, or write the value out longhand instead of relying on a YAML 1.1 merge key.

Is yes a boolean?

Not in YAML 1.2 core, which is what this tool reads. yes, no, on and off are strings; only true and false are booleans. YAML 1.1 treated those four words as booleans, which is a common source of production bugs, so quote the value if a downstream 1.1 parser might read it.

Does this validate against a schema?

No. Validation is a syntax check: it confirms the document parses and reports the first error with its line and column. There is no JSON Schema check, no Kubernetes schema check and no field-level verification. If you need that, convert the file to JSON and validate it with a schema tool.

Which indentation width should I use?

Two spaces is the most common convention and keeps deeply nested files narrow. Four spaces matches the Python style guide and is easier to spot by eye. Pick one and use it consistently — mixed widths are what most indentation bugs come from.

Why did my comment-only file come back trimmed?

A file containing only comments has no YAML document in it, so there is nothing to re-indent. The tool returns your text unchanged apart from trimming leading and trailing blank lines. An empty file is valid YAML too, and formats to an empty result.

Can this fix my YAML automatically?

No. The validator explains the error and points at the line and column, but it never rewrites your data to make it parse. Correcting the input by hand is the safe, predictable way to resolve a syntax problem.