We use cookies

We use cookies and similar technologies to enhance your browsing experience, analyze site traffic, and personalize content and ads. By clicking "Accept", you consent to our use of cookies. Learn more in our Privacy Policy.

YAML

YAML Formatter

by Cosmovex

Indent:
YAML Input
YAML Output
Output will appear here

Free YAML Formatter, Validator & Converter

Format and beautify YAML, validate YAML syntax, convert YAML to JSON and JSON to YAML. No signup required. Works entirely in your browser.

  • YAML formatter and beautifier
  • YAML syntax validator
  • YAML to JSON converter
  • JSON to YAML converter
  • Configurable indentation (2 or 4 spaces)

More Developer Tools

View all tools →
{ }
JSON Formatter
Format, validate & explore JSON
</>
XML Formatter
Beautify & validate XML
CSV Formatter
View & format CSV tables
SQL Formatter
Format & highlight SQL queries
M↓
Markdown Preview
Live Markdown rendering
64
Base64
Encode & decode Base64 strings
JWT
JWT Decoder
Decode & inspect JWT tokens
%20
URL Encoder
Encode & decode URLs

This is a free, in-browser YAML formatter and validator. Paste a YAML document and it parses the text, reports syntax errors with the line and column where they occur, and re-emits clean, consistently indented output. It also converts between YAML and JSON in both directions, so you can paste a config in one format and get the other back.

Everything runs in your browser. The YAML you paste is parsed and formatted locally on your machine, and nothing is sent to a server or stored anywhere. That matters for YAML specifically, because so many YAML files hold things you don't want leaving your laptop: Kubernetes manifests, CI pipeline definitions, Ansible playbooks, application config with hostnames and connection details. You can validate a production manifest or a secrets-adjacent config file without it ever touching the network.

How it works

Paste or type YAML into the editor and the tool parses it on every change. There are three things it gives you:

  • Validation — if the document can't be parsed, you get the error message plus the line and column. YAML failures are usually about indentation or an unexpected character, and the position pointer is what makes them quick to fix.
  • Formatting — valid input is re-serialized with uniform two-space indentation, normalized list and key spacing, and trailing whitespace removed. This is useful for cleaning up files that several people have edited by hand.
  • Conversion — switch the output to JSON to get the equivalent JSON document, or paste JSON and get YAML back. Round-tripping a config between the two formats is a fast way to sanity-check its structure.

The parser follows standard YAML rules: it understands mappings, sequences, scalars, multi-line block strings, anchors and aliases, and explicit type tags. No part of this requires an account or a network connection.

A worked example

Say you have this fragment and the formatter reports an error:

server:
  host: localhost
   port: 8080
  tags: [web, api]

The message points at the port line: it's indented one space deeper than host, and YAML treats inconsistent indentation under the same mapping as a structural error. Line up port with host and it parses. Formatted output comes back as:

server:
  host: localhost
  port: 8080
  tags:
    - web
    - api

Note two things the formatter did. It kept 8080 as a number, not a quoted string, because unquoted numeric scalars are numbers in YAML. And it expanded the inline [web, api] flow sequence into block style, which is the more readable form most config files use. If you'd rather keep values as strings (for example a ZIP code or a version like 1.10), quote them explicitly: version: "1.10".

Common use cases

YAML is the config language for a lot of infrastructure tooling, and most editing of it still happens by hand, so a quick validate-and-format pass catches a lot of mistakes before they reach a pipeline:

  • Kubernetes and Helm — check a manifest's indentation before kubectl apply, where a misplaced key silently lands a field in the wrong block.
  • CI/CD pipelines — validate GitHub Actions, GitLab CI, or CircleCI files locally instead of pushing a commit just to find out the YAML was malformed.
  • Ansible and Docker Compose — confirm playbooks and compose files parse before a run.
  • Format conversion — turn an API's JSON response into readable YAML, or convert a YAML config into JSON for a tool that only accepts JSON.
  • Cleanup — normalize indentation across a file that's been edited by several people with different editor settings.

Because it's all local, you can run a real production config through it without worrying about where the text goes.

Gotchas worth knowing

Most YAML pain comes from a handful of recurring traps:

  • The Norway problem — unquoted no, yes, on, off, true, and false are booleans. A country list with NO (Norway) becomes false. Quote any string value that could be read as a boolean.
  • Tabs are illegal for indentation — YAML requires spaces. A single tab gives a parse error. Set your editor to insert spaces.
  • Numeric-looking strings08 is invalid (looks like a malformed octal), and 1.20 loses its trailing zero. Quote version numbers, ZIP codes, and IDs with leading zeros.
  • Indentation defines structure — there are no braces. A key indented to the wrong depth quietly attaches to a different parent, which often parses fine but means something you didn't intend.
  • Colons in valuestime: 10:30 can confuse the parser. Quote it: time: "10:30".

When the validator flags a line, check indentation and quoting first; that's where the answer usually is.

Anchors, aliases, and why YAML has them

YAML lets you define a block once and reuse it, which JSON can't do. You mark a node with an anchor (&name) and reference it later with an alias (*name). The << merge key folds an anchored mapping's keys into another mapping:

defaults: &defaults
  retries: 3
  timeout: 30

production:
  <<: *defaults
  timeout: 60

Here production inherits retries: 3 from defaults and overrides timeout to 60. This keeps shared config in one place instead of copy-pasting it across environments.

When you convert this to JSON, the aliases are resolved and expanded into full literal values, because JSON has no concept of references. So the JSON production block will contain both retries and timeout written out in full. That expansion is expected, and it's a good way to see exactly what your anchors resolve to.

Tips

  • Quote any value that could be misread as a boolean, number, or date: `country: "NO"`, `zip: "08544"`, `version: "1.20"`.
  • Use spaces for indentation, never tabs. Set your editor to convert tabs to spaces in `.yml`/`.yaml` files.
  • When you get a parse error, read the line and column first. It's almost always indentation or an unquoted special character.
  • Convert a confusing YAML block to JSON to see its real structure flattened, then convert back once you understand it.
  • Use anchors and merge keys (`&`, `*`, `<<`) to share config across environments instead of duplicating blocks.
  • For long text values, use block scalars: `|` preserves newlines, `>` folds lines into a single paragraph.

How to use YAML Formatter & Validator

  1. 1Paste your YAML configuration or document.
  2. 2It's parsed and validated as you type, flagging indentation and syntax errors.
  3. 3Format it cleanly or convert to JSON.
  4. 4Copy or download the result — everything stays on your device.

Frequently asked questions

Why does YAML turn my value into true or false?

Unquoted `yes`, `no`, `on`, `off`, `true`, and `false` are interpreted as booleans. Wrap the value in quotes (for example `"no"`) to keep it as a string.

Can I use tabs to indent YAML?

No. The YAML spec forbids tabs for indentation; you must use spaces. A tab anywhere in the structural indentation produces a parse error.

Is the YAML I paste sent anywhere?

No. Parsing, validation, formatting, and conversion all run in your browser. The text never leaves your machine, which is why it's safe to check production manifests and config files here.

What's the difference between YAML and JSON, and can I convert between them?

YAML is a superset of JSON aimed at human-edited config, with indentation-based structure, comments, and anchors. This tool converts in both directions. Note that comments and anchors don't survive a round-trip to JSON, since JSON has neither.

Why did my version number 1.20 become 1.2?

Unquoted `1.20` is parsed as a floating-point number, which drops the trailing zero. Quote it as `"1.20"` to keep it exactly as written.

How do I write a multi-line string in YAML?

Use a block scalar. `|` keeps line breaks literally; `>` folds wrapped lines into spaces. Both are followed by an indented block of text, for example `description: |` on one line and the indented content below it.

The validator says my indentation is wrong but it looks fine. What's going on?

Check for a mix of tabs and spaces, or a key indented a different number of spaces than its siblings under the same parent. YAML structure is defined entirely by indentation, so even one extra space changes meaning.

Does it support multiple YAML documents in one file?

Yes. YAML files can hold several documents separated by `---`, which is common in Kubernetes manifests. The parser reads each document in the stream.

← All toolsRead our guides →