YAML Minifier

Minify YAML by removing comments and blank lines and compressing indentation.

  • Runs locally in your browser
  • No upload required

Try it

Paste YAML. Quotes and block scalars are preserved; indentation is compressed.

Minified YAML
a: 1 b: c: 2
Size
31 → 14 characters (17 saved)
a: 1
b:
  c: 2

Supported formats

Input
text, boolean
Output
text

Privacy

Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.

Processing
In your browser
Privacy level
Browser only

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

  1. Split the document into lines and, outside block scalars, strip comments that start at whitespace and trailing whitespace.
  2. Drop blank lines and compress indentation to a 2-space step while preserving the level of every line.
  3. Copy block-scalar bodies and quoted scalars byte-for-byte.

Usage

  1. Paste or type a YAML document.
  2. Choose whether to remove comments.
  3. 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

jsonSelect to copy
{
  "text": "# top\na: 1\n\nb:\n  c: 2  # inline",
  "removeComments": true
}

Block scalar preserved

jsonSelect to copy
{
  "text": "s: |\n  keep   # this\n  line",
  "removeComments": true
}

Wide indentation compressed

jsonSelect to copy
{
  "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

  1. YAML 1.2 Specification — YAML Language Development Team
  2. YAML — Comment — YAML Language Development Team