YAML Formatter
Format and pretty-print YAML with the indent you choose. Free, and runs entirely in your browser — nothing you enter is uploaded or stored.
About Structure Formatter
One formatter for every document format here. Pick the format, paste the document, choose an indent: JSON, XML, YAML, TOML, TOON, INI, .env, .properties and HCL are each parsed properly and re-emitted, so what comes back is the same document with consistent whitespace rather than a regex's guess at one.
Because the document is parsed first, formatting doubles as a syntax check — a file that will not format is a file that will not load in whatever consumes it either. Sorting keys is the option worth knowing: it makes two copies of the same data print identically, which is what turns a noisy diff into a readable one.
Where it helps
- One tool and one habit for every structured document you handle.
- Parses before printing, so malformed input is reported rather than mangled.
- The indent is yours to set, matching whatever the project already uses.
- Sorting keys gives JSON and YAML a canonical order, so reordered files stop showing up as changes.
- Runs in the browser, so production payloads and internal manifests stay local.
Limits
- Comments survive in XML but not in JSON, which has none, or YAML, which is rebuilt from the parsed data.
- YAML is re-emitted in the common subset this app parses; anchors, aliases and tags are not preserved.
- XML is re-indented from the parsed document, so mixed content that relies on its own spacing can shift.
- Formatting normalises the text, so an unrelated diff can look larger than the change you made.
Frequently asked questions
How is this different from the HTML Formatter?
That one handles markup for the browser, alongside the CSS and JavaScript formatters. This one covers the data formats and shares its parser with the validator, tree viewer and comparison tools.
Why did my YAML comments disappear?
YAML output is rebuilt from the parsed data, and the data model has nowhere to keep a comment. Keep the original if the comments matter.
Can I format a document that has an error in it?
No. It has to parse first — use Structure Repair for a document you know is broken.
Why can I not sort keys in XML?
Because element order is part of an XML document's meaning, not its presentation. Reordering it would change the document rather than tidy it, so the option is offered for JSON and YAML only.
Which indent should I choose?
Two spaces is the common default, and it is what TOON is defined to use. Four is usual for XML in some ecosystems; match whatever the repository already has.
Related tools
- Structure Validator — Check JSON, XML, YAML, TOML, TOON or HCL and report structural problems
- Structure Minifier — Strip formatting from JSON, XML, YAML, TOML or TOON
- Structure Repair — Fix broken JSON, YAML, XML, TOML, TOON, INI, .env, .properties and HCL, listing every repair
- Tree Viewer — Explore JSON, XML, YAML, TOML, TOON or HCL as a collapsible tree
- Structure Converter — Convert between JSON, XML, YAML, TOML, TOON, HCL and CSV
- String Escaper — Escape a JSON, XML, YAML, TOML or TOON document for embedding, or read one back
More Structured Formats tools
- Structure Converter — Convert between JSON, XML, YAML, TOML, TOON, HCL and CSV
- String Escaper — Escape a JSON, XML, YAML, TOML or TOON document for embedding, or read one back
- Structure Formatter — Pretty-print JSON, XML, YAML, TOML, TOON or HCL with a chosen indent
- Structure Validator — Check JSON, XML, YAML, TOML, TOON or HCL and report structural problems
- Tree Viewer — Explore JSON, XML, YAML, TOML, TOON or HCL as a collapsible tree
- Code Generator — Turn a JSON, YAML, XML or other document into TypeScript, Go, C#, Python, Rust and more
- Schema Generator — Write a JSON Schema, XSD, Avro schema or .proto from a document you already have
- Schema Validator — Check a document against a JSON Schema, .proto, Avro schema, XSD or RELAX NG
- Table Viewer — Show the records in a JSON, XML, YAML, TOML or TOON document as a table
- Structure Compare — Diff two JSON, XML, YAML, TOML, TOON or HCL documents by path
- Structure Repair — Fix broken JSON, YAML, XML, TOML, TOON, INI, .env, .properties and HCL, listing every repair
- Structure Minifier — Strip formatting from JSON, XML, YAML, TOML or TOON
- Path Finder — Select nodes with JSONPath or XPath
- Protobuf & Avro Decoder — Read protobuf wire bytes and Avro container files without their schema
- Expression Evaluator — Reduce a JSONPath or XPath match to a single answer