YAML Formatter
Normalise YAML indentation and trailing whitespace.
- Runs locally in your browser
- No upload required
Try it
Supported formats
Privacy
Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.
Normalised 4 line(s) of YAML at 2-space depth.
How it works
- Rejected tab indentation, which YAML forbids.
- Mapped the document's existing indent unit onto the chosen width.
- Removed trailing whitespace and preserved block-scalar content relative to its key.
- Keys, values and comments are preserved; only indentation and trailing spaces change.
- Output is 3 line(s); formatting it again changes nothing.
Methodology
- Check every line for tab indentation and reject it with a line/column.
- Derive the document's indent unit from its existing leading spaces.
- Re-emit each line at a level-based indent, preserving block-scalar content relative to its key.
Usage
- Paste or type a YAML document.
- Choose a 2- or 4-space indent.
- Run the formatter and copy the normalised result.
Examples
These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.
Mapping indentation
{
"text": "a:\n b: 1\n c: 2\n",
"indentSize": 2
}Sequence under a key
{
"text": "items:\n - one\n - two\n",
"indentSize": 4
}Block scalar preserved
{
"text": "text: |\n line one\n line two\n",
"indentSize": 2
}Limitations
Indentation is structure in YAML
YAML uses indentation instead of braces, so a formatter must preserve relative depth. This tool normalises the width of indentation without changing the nesting it represents.
Frequently asked questions
- Will my block scalar content change?
- No. Block scalar bodies keep their content and their indentation relative to the key line is preserved.
- Why was my YAML rejected?
- The only structural error this formatter reports is tab indentation, which the YAML specification forbids.
- Is my YAML uploaded?
- No. The document is processed entirely in your browser.
Sources
Send feedback
Tell us if this tool helped, report a problem, or suggest a tool. Only the message you type is sent — never the input you used in the tool.
Was this tool useful?
Prefer to write to us directly? See the contact page.