Skip to main content
L
Loopaloo
Buy Us a Coffee
All ToolsImage ProcessingAudio ProcessingVideo ProcessingDocument & TextPDF ToolsCSV & Data AnalysisConverters & EncodersWeb ToolsMath & ScienceGames
Guides & BlogAboutContact
Buy Us a Coffee
L
Loopaloo

Free online tools for developers, designers, and content creators. All processing happens entirely in your browser - your files never leave your device. No uploads, no accounts, complete privacy.

support@loopaloo.com

Tool Categories

  • Image Tools
  • Audio Tools
  • Video Tools
  • Document & Text
  • PDF Tools
  • CSV & Data
  • Converters
  • Web Tools
  • Math & Science
  • Games

Company

  • About Us
  • Contact
  • Blog
  • FAQ

Legal

  • Privacy Policy
  • Terms of Service
  • Disclaimer

Support

Buy Us a Coffee

© 2026 Loopaloo. All rights reserved. Built with privacy in mind.

Privacy|Terms|Disclaimer
  1. Home
  2. Document & Text
  3. YAML Formatter & Converter
Add to favorites

YAML Formatter & Converter

Format, validate, and convert between YAML and JSON formats. Live validation, syntax highlighting, and bidirectional conversion.

Paste messy or minified YAML and get a cleanly indented, validated version. The formatter checks for common YAML pitfalls, incorrect indentation, tab characters, duplicate keys, and highlights errors with clear messages.

Text processed locallyMore document & textJump to full guide

Initializing in your browser…

You might also like

JSON Formatter & Validator

Format, validate, minify JSON with JSONPath queries, tree view explorer, schema validation, diff comparison, and sort keys. Multiple indent styles

XML Formatter & Tools

Format, validate XML with XPath queries, interactive tree view, XML-to-JSON conversion, and multiple color themes

Image Format Converter

Convert images between PNG, JPG, WebP, AVIF, BMP formats. Features quality control, transparency support, and batch conversion for efficient workflow.

YAML Formatter & Converter: a worked example

A CI pipeline fails with a vague YAML error and you suspect an indentation or tab problem in the config.

Input

jobs:
  build:
   steps:
      - run: make
YAML Formatter & Converter produces

Result

⚠ Inconsistent indentation at line 3 (3 spaces, expected 2)
Reformatted with uniform 2-space indent · ✓ now valid
JSON equivalent available

YAML is whitespace-significant and forbids tabs, so a single misaligned line breaks the whole file with an unhelpful message. The tool pinpoints the offending line, normalises indentation, and can show the equivalent JSON so you can confirm the structure parses the way you intended.

What this converter does

Paste messy or minified YAML and get a cleanly indented, validated version. The formatter checks for common YAML pitfalls, incorrect indentation, tab characters, duplicate keys, and highlights errors with clear messages.

How it works

This formatter converts in both directions between YAML and JSON only, using the `yaml` npm library (a separate selector for input and output format, plus a swap button that feeds the current output back into the input box). Despite the file being named YamlTomlFormatter, TOML is not supported anywhere in the code: the only two options are YAML and JSON. Parsing runs through `YAML.parse()` for YAML input and the browser's native `JSON.parse()` for JSON, and re-serialization uses `YAML.stringify()` or `JSON.stringify()`. The indent control is limited to exactly two choices, 2 or 4 spaces, and that value is applied to whichever output format you pick. Because YAML is a superset of JSON, the JSON-to-YAML direction is clean, but converting YAML back to JSON collapses everything to the parsed data model, so comments (lines beginning with #) and any anchor/alias structure in the source are not preserved in the JSON output.

Errors are surfaced with precise positioning rather than a generic failure. When `YAML.parse()` throws a `YAML.YAMLParseError`, the tool reads `linePos[0]` to show the exact line and column, renders a 'Line N, Col N' badge, and paints a red highlight bar over the offending line in the input editor (both panes carry a gutter of line numbers). For JSON input it falls back to parsing the native `SyntaxError`, regex-extracting the character offset from the 'position N' message and counting newlines up to that point to report a line number. While the input parses cleanly a green 'Valid YAML to JSON' style banner is shown reflecting the active conversion direction.

A 'Try Auto-Fix' button appears only when the input format is YAML and a parse error is present; it runs a fixed sequence of nine string-level repairs aimed at YAML's most common syntax traps. It converts tabs to two spaces (YAML forbids tabs for indentation outright), inserts the missing space after a colon in key: value pairs and after a list dash, strips trailing whitespace, and rounds each line's leading indentation to the nearest multiple of two. It also drops lines it judges to be garbage (anything two characters or shorter, or without a colon and not a list item or comment), rewrites bare empty inline collections so `key: {}` becomes `key:` and `key: []` stays as an empty array, prepends a `---` document separator when a multi-document marker is detected mid-file, and collapses three or more consecutive blank lines down to one. This is a best-effort heuristic cleaner, not a full reparse, so it can discard content it misclassifies as junk; the parser itself is run with default options, so it does not flag duplicate keys (the `yaml` library keeps the last value rather than erroring), and YAML's type-coercion footguns (unquoted no/off/yes parsing as booleans, leading-zero strings like ZIP codes, or HH:MM sexagesimal numbers) are resolved by the parser, not corrected by auto-fix.

How to use

  1. 1Paste your YAML content into the editor
  2. 2The formatter validates and re-indents it automatically
  3. 3Fix any reported errors
  4. 4Copy the formatted result

Key features

  • Automatic indentation and formatting
  • Validation with descriptive error messages
  • Detection of duplicate keys
  • Tab-to-space conversion (tabs are invalid in YAML)
  • JSON-to-YAML conversion option

When to reach for this

  • Editing Kubernetes manifests

    Format and validate Kubernetes YAML files to catch indentation errors before applying them to a cluster.

  • CI/CD pipeline configuration

    Clean up GitHub Actions, GitLab CI, or other pipeline configs where a single indentation mistake can break the build.

  • Docker Compose files

    Format docker-compose.yml files for readability and verify structure before running containers.

Frequently asked questions

Why are tabs not allowed in YAML?

The YAML specification explicitly forbids tab characters for indentation. Only spaces are permitted. This tool converts tabs to spaces automatically.

Can I convert between YAML and JSON?

Yes, the tool can convert JSON input to YAML format since both represent similar data structures.

Does it preserve comments?

Yes. YAML comments (lines starting with #) are preserved in the formatted output.

Related tools and how they differ

  • JSON Formatter & Validator: Goes deeper on JSON alone: tree view, JSONPath queries, diff, and schema validation; use it when you stay in JSON and want to explore or compare it.
  • XML Formatter & Tools: Formats XML and converts it to JSON; use it for angle-bracket markup with attributes and namespaces, which YAML and JSON parsers cannot read.
  • SQL Formatter: Formats SQL queries with dialect and comma options; use it for database code, not data serialization. It does not parse YAML or JSON structures.

Private by design

Your text is processed locally in the browser. Nothing you paste or open is transmitted or logged.