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.
Initializing in your browser…
Format, validate, minify JSON with JSONPath queries, tree view explorer, schema validation, diff comparison, and sort keys. Multiple indent styles
Format, validate XML with XPath queries, interactive tree view, XML-to-JSON conversion, and multiple color themes
Convert images between PNG, JPG, WebP, AVIF, BMP formats. Features quality control, transparency support, and batch conversion for efficient workflow.
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: makeResult
⚠ 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.
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.
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.
Format and validate Kubernetes YAML files to catch indentation errors before applying them to a cluster.
Clean up GitHub Actions, GitLab CI, or other pipeline configs where a single indentation mistake can break the build.
Format docker-compose.yml files for readability and verify structure before running containers.
The YAML specification explicitly forbids tab characters for indentation. Only spaces are permitted. This tool converts tabs to spaces automatically.
Yes, the tool can convert JSON input to YAML format since both represent similar data structures.
Yes. YAML comments (lines starting with #) are preserved in the formatted output.
Your text is processed locally in the browser. Nothing you paste or open is transmitted or logged.