YAML Minifier
Minify YAML by removing comments and blank lines and compressing indentation.
- 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.
Reduced 31 to 14 characters of YAML.
How it works
- Removed comments outside quoted scalars.
- Removed blank lines and trailing whitespace.
- Compressed indentation to a 2-space step.
- Preserved quoted scalars and block-scalar bodies.
- Indentation levels are preserved, so the document's structure is unchanged.
- A `#` inside a quoted scalar or a block scalar is preserved verbatim.
- Output is 14 character(s); minifying it again changes nothing.
Methodology
- Split the document into lines and, outside block scalars, strip comments that start at whitespace and trailing whitespace.
- Drop blank lines and compress indentation to a 2-space step while preserving the level of every line.
- Copy block-scalar bodies and quoted scalars byte-for-byte.
Usage
- Paste or type a YAML document.
- Choose whether to remove comments.
- Run the minifier and copy the compact result.
Examples
These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.
Comments and blanks removed
{
"text": "# top\na: 1\n\nb:\n c: 2 # inline",
"removeComments": true
}Block scalar preserved
{
"text": "s: |\n keep # this\n line",
"removeComments": true
}Wide indentation compressed
{
"text": "a:\n b:\n c: 1",
"removeComments": false
}Limitations
What can be removed from YAML
Comments and blank lines carry no data, so they are always safe to remove. Indentation cannot be removed — only compressed — because it encodes the structure.
The minifier keeps every structural level, so the parsed document is identical to the input's.
Frequently asked questions
- Does minifying change my YAML?
- No. Comments (when selected), blank lines and redundant trailing whitespace are removed and indentation is compressed; keys, values and structure are preserved.
- Why keep indentation instead of making it one line?
- YAML is indentation-significant, so a single line would change the document's meaning. The minifier only removes what it can prove is redundant.
- Is my YAML uploaded?
- No. All processing happens in your browser and nothing is sent anywhere.
Sources
- YAML 1.2 Specification — YAML Language Development Team
- YAML — Comment — YAML Language Development Team
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.