YAML Formatter
Format and validate YAML, or convert between YAML and JSON. Supports 2 and 4 space indentation. All processing is done locally in your browser using js-yaml — nothing is uploaded.
Why use our online YAML Formatter?
Format YAML files with consistent indentation, validate syntax, and convert between YAML and JSON in your browser. Useful for working with Kubernetes configs, GitHub Actions, and CI/CD pipelines.
How to use YAML Formatter
- 1Paste your YAML or JSON
Enter your content in the input field. For YAML formatting, paste any valid YAML. For conversion, you can paste either YAML or JSON depending on the selected tab.
- 2Choose the operation
Select Format YAML to clean up and re-indent your YAML, YAML → JSON to convert to JSON format, or JSON → YAML to convert JSON to YAML syntax.
- 3Set indent size
Choose 2 or 4 spaces for YAML indentation. The output updates automatically.
- 4Review errors
If your YAML or JSON has a syntax error, a red error banner appears with the parse error message to help you locate the problem.
- 5Copy or download
Use the Copy button to copy the output, or Download to save the result as a .yaml or .json file.
YAML syntax essentials — the parts that trip people up
YAML (YAML Ain't Markup Language) uses indentation instead of brackets to denote structure. This makes it human-readable but sensitive to whitespace errors. Understanding the indentation rules prevents the most common YAML bugs.
Indentation must be consistent within a block. YAML requires spaces (not tabs) for indentation — a tab character in YAML indentation is a parse error. Two spaces per level is the most common convention. You cannot mix two-space and four-space indentation within the same file.
Scalar values have implicit types. The string true, false, yes, no, on, off are interpreted as booleans in YAML 1.1 (and in many implementations). The string 0644 is interpreted as an octal integer. Strings that look like numbers or booleans must be quoted: '"true"' or "'yes'" to force string interpretation. This is a common source of bugs in Kubernetes and GitHub Actions configuration.
Multi-line strings use two block scalar indicators: the literal block scalar (|) preserves newlines; the folded block scalar (>) folds newlines into spaces. A trailing newline is added by default (strip it with |- or >-).
Anchors (&name) and aliases (*name) allow reuse: define a value once with an anchor and reference it elsewhere with an alias. The alias expands to a copy of the anchored value at parse time.
YAML in DevOps — where it appears and common pitfalls
YAML has become the dominant configuration format in the DevOps ecosystem, appearing across all major platforms.
Kubernetes: nearly all resource definitions (Pods, Deployments, Services, ConfigMaps, Secrets) are written in YAML. The indentation sensitivity causes frequent errors — a misaligned key changes a resource's field or produces a parse error that Kubernetes reports as a cryptic validation failure. Use kubectl apply --dry-run=client -f file.yaml to validate before applying.
GitHub Actions: workflow files (.github/workflows/*.yml) define CI/CD pipelines. YAML anchors are useful for reusing step sequences. The on: trigger key requires quoting in some YAML parsers (on is a boolean-like value in YAML 1.1). GitHub Actions uses a YAML 1.1-compatible parser.
Docker Compose: compose.yml files define multi-container applications. Version-specific field names (services, volumes, networks) use consistent two-space indentation. Environment variable values should be quoted to prevent type coercion.
Helm charts: Helm uses Go templating inside YAML files, creating a challenging combination — Go template expressions ({{ }}) must be syntactically valid when the template language is stripped. Multi-line values in Helm often use the | block scalar to preserve content that would otherwise need extensive escaping.
YAML to JSON and back — lossless vs lossy conversion
YAML is a superset of JSON, which means all valid JSON is valid YAML. This makes YAML → JSON conversion reliable and lossless for the JSON-compatible subset of YAML.
However, YAML features that have no JSON equivalent create conversion challenges. Comments are lost: JSON has no comment syntax, so all YAML comments are discarded during conversion. Anchors and aliases are expanded: the referenced value is inlined, and the anchor/alias relationship is lost. Multi-document streams (--- separators) cannot be represented in a single JSON object — only the first document can be converted.
YAML's additional scalar types (dates, timestamps, explicit type tags like !!binary) either map to JSON strings or fail conversion depending on the parser. The YAML date 2024-01-15 may become the JSON string "2024-01-15" — the semantic meaning is preserved in the string but the type information is not.
JSON → YAML conversion is fully lossless: JSON's subset of types (string, number, boolean, null, array, object) all have direct YAML equivalents. JSON objects become YAML mappings, JSON arrays become YAML sequences. The only transformation is formatting — JSON's brace syntax becomes YAML's indented block syntax.
Frequently Asked Questions
What is YAML and how is it different from JSON?
- YAML (YAML Ain't Markup Language) is a human-friendly data serialisation format. Unlike JSON, YAML uses indentation instead of braces and brackets, supports comments with #, and allows unquoted strings. YAML is a superset of JSON — all valid JSON is valid YAML. YAML is widely used for configuration files (Kubernetes, GitHub Actions, Docker Compose).
Can every YAML document be converted to JSON?
- Most YAML can be converted to JSON, but not all. YAML features that have no JSON equivalent include comments, anchors and aliases (&anchor / *alias), multi-document streams (---), and some special scalar types. The tool converts what it can and notes any unsupported features.
Does YAML formatting change my data?
- No. Formatting only changes whitespace and key ordering — it does not alter values, types, or structure. The formatted output represents the same data as the input.
Is my data sent to a server?
- No. All YAML parsing and formatting is done locally in your browser using the js-yaml library. Nothing is uploaded anywhere.
What YAML version is supported?
- The tool supports YAML 1.2 via the js-yaml library, which handles all common YAML constructs including multi-line strings, anchors, aliases, custom tags, and nested structures.
Related Tools
CI/CD Configuration Converter
Convert CI/CD pipelines between GitHub Actions, GitLab CI, CircleCI, and Bitbucket Pipelines. Parses workflows into a canonical IR and re-emits them with confidence-annotated audit, round-trip validation, and a Markdown audit report. 200+ component mappings (actions/checkout, setup-node, docker/build-push, AWS/GCP/Azure auth, CircleCI orbs, Bitbucket pipes). 100% in your browser.
JSON Formatter
Clean, minify, and validate JSON data structures.
XML Formatter
Format, minify, and validate XML. Convert XML to JSON with one click. Supports custom indent sizes.
JSON ↔ CSV Converter
Convert JSON arrays to CSV and CSV back to JSON. Custom delimiter, header row control, and one-click download.
SQL Formatter
Format, beautify, and minify SQL queries online. Supports MySQL, PostgreSQL, SQLite, and more SQL dialects.