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 YAML without rewriting it: comments, anchors, quoting, block scalars, multi-document streams and the exact spelling of every number all survive, with YAML 1.1 and 1.2 both offered because the same file means different things under each

Text processed locallyMore document & textJump to full guide

Initializing in your browser…

You might also like

JSON Formatter & Validator

Format, validate and minify JSON, JSON with comments and JSON5, without changing a single value: every number is written back as the document spelled it. Errors carry a line, a column and the offending line. JSONPath queries, tree view, schema checks and diff

XML Formatter & Tools

Format and validate XML without changing the document: CDATA, xml:space="preserve" and mixed content all survive, with errors carrying a line, a caret and a next step, plus XPath queries, a tree view and JSON conversion that names what JSON cannot carry

Image Format Converter

Convert between the formats a browser can really write, then open the output and name the format its first bytes say it is. AVIF, BMP and GIF are disabled because a canvas returns a PNG for all three.

YAML Formatter & Converter: a worked example

You reformat a config file and want it to come back as the same file: the same comments, the same anchors, and the same numbers.

Input

# why this is 30
timeout: 30
version: 1.0
build: 007
orderId: 12345678901234567890
defaults: &defaults
  retries: 3
What YAML Formatter & Converter produces

Formatted

# why this is 30
timeout: 30
version: 1.0
build: 007
orderId: 12345678901234567890
defaults: &defaults
  retries: 3

$.orderId is beyond what a double holds; a reader using one would see 12345678901234567000

The version this replaces gave back `version: 1`, `build: 7`, `orderId: 12345678901234567000`, `&a1` instead of `&defaults`, and no comment at all, because it formatted by reading the VALUES and writing a new document from them. This one reads the document and writes every scalar back as the file spelled it, and says out loud which numbers a reader using a 64-bit double would round. Scored as a round trip through PyYAML, 20 of 20 corpus documents keep their meaning where 15 did before.

What this converter does

Formatting a YAML document should change its whitespace and nothing else. The usual implementation breaks that immediately: `YAML.stringify(YAML.parse(text))` keeps the VALUES and writes a new document from them, and a value has forgotten how it was spelled. Measured on 2026-09-03 against the version this replaces, using the same library this one uses: `1.0` came back as `1`, `007` as `7`, a twenty digit order identifier as `12345678901234567000`, `"quoted"` as `quoted`, `0x1F` as `0x1f`, `1e3` as `1e+3`, `~` as `null`, every anchor renamed from `&defaults` to `&a1`, every comment deleted, and a two-document stream threw an exception and produced nothing at all. This one reads the DOCUMENT rather than the values, and writes back every scalar as the text the file held whenever re-reading that text gives the same value. Scored as a round trip through PyYAML, which is a separate implementation in another language: 20 of 20 corpus documents keep their meaning and 20 of 20 keep every character stated, against 15 and 10 before.

How it works

A YAML file is usually a configuration file, and a configuration file is mostly comments. The comment saying WHY the timeout is 30 seconds is the most valuable line in it, and a formatter built on the value API deletes every one, because comments are not values. The same goes for an anchor name: `&defaults` says what the block is for and `&a1` says nothing. Both survive here.

Numbers are the quiet half. A twenty digit identifier goes through a 64-bit double and comes back with its last three digits replaced by zeros, which is a changed value in a file somebody will deploy. `1.0` and `1` are the same number and a different document, and so are `0x1F` and `31`. Every one of them is written back as the file had it. Where a number genuinely cannot be held exactly by a double, the page says so and shows what a reader using one would get, rather than silently producing it.

**The version matters and the page says which one is in force.** YAML 1.1 and YAML 1.2 resolve plain scalars differently, and the gap between them is known as the Norway problem: under 1.1 the plain scalar `no` is the boolean false, `yes` and `on` are true, `012` is octal ten, and `1:30` is ninety. Under 1.2 they are the strings "no", "yes" and "on", the number twelve, and the string "1:30". The specification has said 1.2 since 2009 and this tool defaults to it, but PyYAML and a great many other readers still implement 1.1, so a file can mean one thing here and another in production. Both are offered and the banner names the one that was used.

A stream of several documents, which is what nearly every Kubernetes manifest is, is read whole and written whole. The Repair button applies four changes and no others: a tab in the indentation becomes two spaces (YAML forbids tabs there, specification section 6.1), a missing space after a colon or after a sequence dash is inserted, and trailing whitespace goes. Every one is reported with the line it happened on. The version this replaces had nine repairs and one of them removed any line it judged to be junk, silently, from the file you had just pasted; another rounded every indent to the nearest multiple of two, which changes a document's structure rather than its formatting. Neither exists now.

Converting to JSON names what JSON cannot carry rather than dropping it quietly: the comments, the aliases (a shared node becomes two copies), the documents after the first, and any number JSON has no way to spell, such as `007`. Numbers that JSON CAN spell keep their exact token, so `1.0`, `1e3` and a twenty digit identifier all survive the conversion, which they do not through `JSON.stringify`.

How to use

  1. 1Paste your YAML, or press Load Example for a document that exercises everything a formatter has to keep
  2. 2The output updates as you type; errors carry a line, a column, the offending line with a caret and a next step
  3. 3Open Settings to choose the YAML version, the indentation, whether to keep comments and whether to sort keys
  4. 4Switch Out to JSON for a conversion that names everything JSON cannot carry
  5. 5Press Repair when a document will not parse; it reports every line it changed and removes none

Key features

  • Comments, anchor and alias names, quoting style and block scalars all survive a format
  • Every number written back as the file spelled it: 1.0, 007, 0x1F, 1e3 and twenty digits
  • A number beyond what a double holds is reported with what a double-based reader would make of it
  • Multi-document streams read and written whole, which is what a Kubernetes manifest is
  • YAML 1.1 and 1.2 both offered, with the Norway problem stated and the version in force named
  • Errors with a line, a column, the offending line with a caret and a concrete next step
  • Repair that changes only what a YAML reader calls an error, reports every line, and removes none
  • YAML to JSON that names the comments, aliases and documents JSON cannot carry
  • Scored as a round trip through PyYAML: 20 of 20 documents keep their meaning

When to reach for this

  • Editing Kubernetes manifests

    Format a multi-document manifest without losing the second document, the comments explaining each field, or the anchors the file uses to share defaults.

  • Tidying a CI configuration

    Re-indent a workflow file while keeping every comment that says why a step exists, and see which numbers a reader using doubles would round.

  • Checking what a file really means

    Switch between YAML 1.1 and 1.2 to see whether a plain `no` in your file is the string "no" or the boolean false, which depends entirely on what reads it.

Frequently asked questions

Why did my comments disappear in the old version?

Because it formatted with the value API: it read the document into plain values and wrote a new document from those. A comment is not a value, so there was nothing left to write. This version reads the document itself, so the comments, the anchor names, the quoting and the block scalars all come back.

Why does my number look different after formatting?

It should not, and here it does not. Every scalar is written back as the text the file held, whenever re-reading that text gives the same value: `1.0` stays `1.0`, `007` stays `007`, `0x1F` keeps its capital F. If a number is beyond what a 64-bit double can hold exactly, the page says so and shows what a reader using one would get.

What is the Norway problem?

Under YAML 1.1 the plain scalar `no` is the boolean false, so a list of country codes containing Norway becomes a list containing false. Under YAML 1.2 it is the string "no". The specification moved to 1.2 in 2009 but many readers, PyYAML among them, still implement 1.1. This tool defaults to 1.2, offers 1.1, and always says which one it read under. Quoting the value settles it either way.

Does it handle a file with several documents in it?

Yes, and that is a change: the version this replaces called a function that throws on one, so a Kubernetes manifest produced nothing at all. Every document in the stream is read, formatted and written back, separated by ---.

What does Repair actually do?

Four things, each reported with the line it happened on: a tab in the indentation becomes two spaces, a missing space after a colon or a sequence dash is inserted, and trailing whitespace is removed. It never removes a line and never changes an indent level. The version this replaces did both.

What is lost converting YAML to JSON?

Comments, because JSON has none; aliases, because JSON has none and a shared node becomes two copies; every document after the first, because JSON carries one; and any number JSON has no way to spell, such as 007. All four are listed on the page rather than dropped quietly.

Does it support TOML?

No. The component file is named YamlTomlFormatter for historical reasons and no TOML code has ever existed in it. The two formats offered are YAML and JSON.

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.