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. Your files are processed in your browser and are never uploaded - no accounts required. A few network utilities (like What's My IP and Currency Converter) call public APIs to do their job and say so on their pages.

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 and validate YAML or convert between YAML and JSON as you type, keeping comments, anchors and exact numbers, with YAML 1.1 and 1.2 support.

Text processed locallyMore document & textJump to full guide

Initializing in your browser…

You might also like

JSON Formatter & Validator

Format, validate and minify JSON, JSONC or JSON5 as you paste, with exact numbers, precise error locations, a tree view, JSONPath queries and schema checks.

XML Formatter & Tools

Format, minify or convert XML to JSON as you type, with line-and-column error checks, a tree view and XPath queries that handle namespaces.

Image Format Converter

Convert images between PNG, JPEG, WebP, GIF and BMP (and AVIF where your browser supports it), one at a time or in a batch, and compare how big each format makes your picture.

YAML Formatter & Converter: a worked example

A deployment file was edited by several people with four-space indentation and needs to match the team's two-space style without losing its comment, anchor or values.

YAML (4-space indent)

# deploy settings
version: 1.0
defaults: &defaults
    retries: 3
    region: eu-west-1
production:
    <<: *defaults
    replicas: 4
countries:
- no
- se
What YAML Formatter & Converter produces

Formatted, 2 spaces, YAML 1.2

# deploy settings
version: 1.0
defaults: &defaults
  retries: 3
  region: eu-west-1
production:
  <<: *defaults
  replicas: 4
countries:
  - no
  - se

Only the indentation changed: the comment, the anchor &defaults, the merge key, version: 1.0 (not 1) and the unquoted no all stay as written, and list items are now indented under their key. Converting the same file to JSON shows why the YAML version matters: under 1.2, countries becomes ["no", "se"], while under 1.1 it becomes [false, "se"] and production picks up retries and region from the merged defaults.

What this converter does

Paste YAML to re-indent it cleanly, validate it, or convert it to JSON, and paste JSON to turn it into YAML. Comments, anchors, quoting, multi-line strings and the exact spelling of numbers are kept, and errors point to the line and column.

How it works

YAML is the configuration language of Docker Compose, Kubernetes, GitHub Actions, Ansible, OpenAPI and countless app settings files. It is readable, but whitespace matters, so a misplaced space or a tab can break a deployment. This tool formats YAML without rewriting it, checks that it parses, and converts between YAML and JSON in either direction, updating as you type.

Formatting that keeps your file. Many formatters load the YAML into data and write a brand new file from it, which throws away comments, renames anchors, turns 1.0 into 1 and 007 into 7, and fails on files that contain several documents separated by ---. This formatter works on the document itself. It normalises indentation to 2 or 4 spaces and can indent list items under their key or not, but keeps comments, anchor and alias names, block scalars (| and >), each document in a multi-document stream, and every number exactly as written, including identifiers longer than a standard double can hold. Quoting is left as it is unless you ask for plain, single or double quotes, and keys can optionally be sorted.

YAML 1.1 or 1.2. The two versions of YAML read some values differently. Under YAML 1.1, which many older parsers and CI tools still use, an unquoted no, off or y is a boolean and 012 is an octal number; under YAML 1.2 they are the string "no" and the number 12. This is the "Norway problem", named after the country code NO turning into false. Choose the version your software uses, and the conversion to JSON follows its rules. The << merge key, common in Docker Compose files for sharing settings, is part of YAML 1.1; read the file as 1.1 and JSON output expands it, with keys written in the mapping itself taking priority.

Clear errors and safe repairs. When the YAML cannot be read, you get the line and column, the line itself with a caret under the problem and a hint, such as a tab used for indentation or a missing space after a colon. A Repair button fixes the most common mistakes (tabs in indentation, key:value without a space, -item without a space, trailing whitespace) and lists every change with its line number. It never deletes a line or changes the nesting of your file.

Converting to and from JSON. YAML to JSON writes standard JSON and lists anything JSON cannot carry: comments, anchors (aliases are expanded into copies), documents after the first and keys that are not strings. JSON to YAML keeps numbers exactly as written, so 19.90 stays 19.90. Everything runs in your browser, which matters for configuration files that contain hostnames, credentials or internal URLs.

How to use

  1. 1Paste YAML or JSON, open a .yaml, .yml or .json file, or press Try an example.
  2. 2Set From and To: YAML to YAML formats, YAML to JSON or JSON to YAML converts.
  3. 3Choose 2 or 4 spaces. Under More options, pick the YAML version your software uses and the quoting, comment and sorting behaviour.
  4. 4If an error appears, use the line, column and hint to fix it, or press Repair for common mistakes.
  5. 5Copy the result or download it as .yaml or .json. The swap button reverses the direction and uses the result as input.

Key features

  • Live formatting with 2 or 4 space indentation and optional indented lists
  • Comments, anchors, aliases, block scalars and multi-document streams preserved
  • Numbers kept exactly as written, including long identifiers and trailing zeros
  • YAML 1.1 and YAML 1.2 interpretation, including the Norway problem
  • Merge keys (<<) expanded when converting YAML 1.1 to JSON
  • Errors with line, column, excerpt and a hint
  • One-click repair of tabs, missing spaces and trailing whitespace, with every change listed
  • YAML to JSON and JSON to YAML, with anything JSON cannot carry reported
  • Optional quoting normalisation and key sorting
  • Runs locally; files never leave your browser

When to reach for this

  • Fixing a CI or Kubernetes file

    Find the exact line where a GitHub Actions workflow or Kubernetes manifest stops parsing, and fix indentation without losing the comments.

  • Converting configuration for code

    Turn a YAML config into JSON for a JavaScript app or an API request, or turn JSON into YAML for a Helm chart or OpenAPI file.

  • Checking how a value will be read

    See whether country codes, yes/no flags or zero-padded numbers will be read as text, booleans or numbers by a YAML 1.1 or 1.2 parser.

  • Tidying a docker-compose.yml

    Re-indent a Compose file consistently while keeping its anchors and comments, and expand the << merges to see the final settings.

Tips & best practices

  • Quote strings that look like booleans or numbers, such as "yes", "off", "1.10" or "0755", if they must stay text.
  • Keep one indentation style across a repository; 2 spaces is the most common for Kubernetes and GitHub Actions.
  • Convert to JSON under YAML 1.1 to see exactly what a docker-compose.yml expands to after its << merges.
  • Fix the first reported error first; later errors are often caused by it.

Examples

  • Re-indenting a file with an anchor

    A file indented with four spaces, with defaults: &defaults and production: <<: *defaults, formats to two-space indentation with the comment, the anchor name, version: 1.0 and the list of country codes unchanged.

  • The Norway problem

    Converting countries: [no, se] to JSON gives ["no", "se"] under YAML 1.2 but [false, "se"] under YAML 1.1. Quoting the value ("no") makes it a string under both.

  • Expanding a merge key

    Under YAML 1.1, base: &base {retries: 3, region: eu} with prod: {<<: *base, retries: 5} converts to "prod": {"retries": 5, "region": "eu"}, because a key written in the mapping overrides a merged one.

Frequently asked questions

Will formatting remove my comments?

No. Comments stay where they are, along with anchors, aliases, block scalars and every document in the file. You can turn comments off under More options if you want a clean copy without them.

Which YAML version should I choose?

Use the version your software reads. Many tools built on PyYAML or older libraries, and some CI systems, use YAML 1.1. Newer libraries, such as the yaml package for JavaScript, default to 1.2. When in doubt, quote values like "no", "on" or "012" so they mean the same thing under both.

Why does my file fail with a tab error?

YAML does not allow tab characters in indentation; it requires spaces. Press Repair to replace indentation tabs with spaces. Tabs inside values or after the indentation are allowed and left alone.

What does the << merge key do?

It copies the keys of another mapping, usually an anchor such as &defaults, into the current one. It comes from YAML 1.1 and is widely used in Docker Compose and CI files. When you convert to JSON reading the file as YAML 1.1, the merge is expanded; under 1.2 it is treated as an ordinary key and the tool says so.

Are large numbers and version strings safe?

Yes. Numbers are written back exactly as they appear, so 1.0 stays 1.0, 007 stays 007, and a 20-digit ID is not rounded. When converting to JSON, a note lists any value that a program using standard doubles would read differently.

Is my configuration uploaded?

No. Parsing, formatting and conversion run in your browser, so secrets and internal hostnames in your files stay on your device. The share link stores only the settings.

Related tools and how they differ

  • JSON Formatter & Validator: Formats, validates and queries the JSON you get from a conversion.
  • XML Formatter & Tools: Formats and validates XML configuration files and converts them to JSON.
  • Text Diff & Compare Tool: Compares two versions of a config file line by line after formatting both the same way.

Private by design

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