格 千格 KiloCell

YAML Formatting Full Guide: Indent, Multi-document Interchange with JSON

Update 2026-08-08 About 12 minutes development tools How-to

K8s list failed, GitHub Actions reporting errors "mapping values are not allowed here" or a copy of a tab hybrid docker-compose sent by colleagues, the first thing to do is not change business fields, but put Yamal on the wrong page. Verify and level to flat indent。 This guide describes the differences between indentation and type traps, multi-document boundaries, YAML and JSON, gives actionable steps and error tables, and directly docks KiloCell of local YAML tools.

Use tools immediately YAML Formatting - Browser Embellish, Compress, Verify and JSON Interchange
Open tool →

The core sentence.

YAML expresses structure in indentation; The textual is likely to be misspaced.

First, it's decipherable, then beautification or compression; To convert to JSON when it is needed for application or API. Multi-document, anchor reference, low style and "a string that looks like a number" are the most common turning points. Below is the "Rules and JSON versus Zooming Error Sheet scene selection" which can be used to create a new format for the application of the error sheet. YAML Format Up against practice.

1. What exactly does YAML care about in the project?

YAML (YAML Ain't Markup Language) is a human-oriented data sequenced language that is widely found in:

  • Packagings and organization:docker-compose.yml、Kubernetes Deployment / Service
  • CI/CD: GitHub Actions, GitLab CI, Part Jenkins Configuration
  • Apply configuration: Spring application.yml、Ansible playbook、Helm values
  • Content and metadata: Some static station Frontmatter, OpenAPI YAML form

It's selling place. Readable: Indentable, annotated, and indentable. The price is... It's extremely sensitive to the blanks., and the same paragraph does not exactly agree on the "repeated key, anchor, type guess" on the different solvers (PyyamL, js-yaml, Go yaml.v3, SnakeYAML).

Capacity YAML usually has JSON, YOU KNOW, YOU KNOW, YOU'RE GONNA HAVE Pay attention when debugging
Comment # Yes. None And then you turn it on when it's beautiful. JSON will throw away the notes.
Multi-document --- Yes. None (single root value) One time, load. Maybe only the first part.
anchor & / Alien * Yes. None dump may be started or reported
String without quotation marks Yes. We have to add quotation marks. yes/on/1.0 Could be a boolean or a number.
Indentation Level I have to. Shit. {} [] Tab mixes with spaces is a classic accident

This station tool is based on the browser js-yaml: The input box is pasted and verified in real time; "Beautified Yaml" dump rewrite in 2 spaces; "Concentration" goes low style; And support Yaml↔json. Processing is done locally and the key configuration should be unsensitized before it is pasted.

Indentation, scale and list: rules that must be carved into muscle memory

Use only spaces, not Tab

YAML 1.1/1.2 In practice,Indentation should use spaces。 If the editor shows Tab as "looks aligned", the solver may still be misoriented or a hierarchy confused. The team should unify 2 spaces (common K8s/ GitHub Operations) or 4 spaces and open "Spacing instead of Tab" in the editor.

Align with peer, sub-level multi-indent one

# Legal:Same级KeysLeft缘Alignment,SonKeysMore 2 spaces
server:
  host: localhost
  port: 8080
  ssl:
    enabled: true

Here we go.Intentional unlawfulExample (child keys are left-side or same-graded than parent keys):

# Intentional unlawful
server:
host: localhost
  port: 8080

List Item - Location

- (a) A space after which normally; list to align the embedded map with the content column:

containers:
  - name: web
    image: nginx:1.25
  - name: sidecar
    image: busybox

When strings must be quoted

Situation Recommendations Reason
Ham : Back and Space Add quotes It's easy to be considered a "new key pair"
Here. { [ Text at the beginning Add quotes Easy to be used as a low collection
Looks like a boolean. Add quotes yes/no/true/null Could be a typology.
Version Number 1.10 View Parser Could be a floating spot. 1.1
Ham # line text Add quotes # Open Comment
# - Yes.险:某些Parsing器Yes.- Put it on. yes When?Done. true
feature_flag: yes

# More稳妥
feature_flag: "yes"
version: "1.10"
message: "error: not found"

Multi-document and document header

--- Split multiple documents;... Can end the document (less handwritten). A list in K8s often contains multiple resources and is composing it in a file with multiple documents.

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
---
apiVersion: v1
kind: Secret
metadata:
  name: app-secret

Tool boundary: Page Verify Usage jsyaml.loadYeah.Multi-document stringIt may only resolve the first paragraph or direct error, depending on the type of input. Multi-document list suggests that a break check be pasted or that you first confirm how your target is loaded when running (kubectl); Do not assume "webpage once = kubectl apply all documents".

3. YAML and JSON: Differences and Detriment Points

The two often rotate, but not the purely information equivalent.

Theme YAML JSON Swing
Comment Support Not supported YAML→JSON Comment Explosion
Key Order Most achieves the reservation insertion sequence Text ordered, semantic objects unordered It's generally acceptable.
Numbers and Strings Often guess Type determined by literally "01" / 01 It's easy to step on.
Multi-document Support Unit Turn JSON always only one root
Oscilloscope Merge Support None Dump often expands as a duplicate structure
null / ~ / Empty Multiwriting Just... null Turn back to the YamL style that may change

When to stay in Yaml: Configure read people, require comment and anchor reuse, organize and list CI. When did you turn it? Interface debugging, frontend JSON.parse, needs and needs JSON Format / Diff Tool Chain Interconnection. Special conversion page: If your main task is to repeat JSON↔YAML without emphasizing "YAML beautification" it is possible to use it. JSON ↔ YAML; This is the main tool forVerify + beautify + Compress + InterchangePut it on one screen, and leave the tab free when you are wrong.

Cross-check: Two ways of building the same structure

YAML:

user:
  id: 1001
  name: Ada
  roles:
    - admin
    - editor
  active: true

Equivalent

{
  "user": {
    "id": 1001,
    "name": "Ada",
    "roles": ["admin", "editor"],
    "active": true
  }
}

Put the Yaml in active: yes When converted to JSON, it could become true , not string "yes"– It's a type guess, not a formatted "bracked field name."

4. Processing in KiloCell of cells YAML: step by step

tools page:YAML Format。

  1. Open the page. Enter /tools/dev/yaml-formatter, "Input YAML/JSON" on the left, and "Process results" on the right.
  2. Paste content. The idea is to be able to "load examples" and get familiar with layouts. The real configuration should be removed, the password, Token, and the private key.
  3. Look at the status bar. When entering oninput Trigger verification: Successfully showed "YAML format correct" Failed to display error message for js-yaml (indent by line when containing line/column thread first).
  4. Beautify。 Dot "Beautification Yaml": In a position load Under the condition, use 2 spaces dump To Right (Present)lineWidth: -1、noRefs: true, avoid anchor reference to interfere with reading.
  5. Minify。 Point "Cressed YamL": To keep the gap as tight as possible in a low style, allowing comparison of "deconstructed structure" rather than reading.
  6. Turn on JSON. JSON after the output "YAML to JSON" output; It's more usable. JSON Format Do it again or compress.
  7. JSON THROUGH YAML. If it's JSON, do "JSON turns Yamal" on the left; Illegal JSON will report in status bar JSON.parse Error。
  8. Copy with empty. The input/result area can be "reproduced"; The "cleaning up" is both on both sides and in the state.

Capacity boundaries (relative to real pages)

  • Support: Syntaxual validation, beautification dump, low compression, Yaml→JSON, JSON→YAML, example to theme.
  • Unassured: (a) To retain the original note and original handwritten style; Multi-document one-time complete round-trip; All Yamal 1.1 Odd types are identical across languages and ecology.
  • Security: Browser local resolution; Still, no Secret explicits are attached to untrustworthy environments.

5. Common errors and treatments

phenomena Common causes What do we do?
mapping values are not allowed here A line. : Inline of a string that uses inappropriate quotation marks : (a) Quote the mark; Check if you have a new key written after the change.
bad indentation / Indentation Related Tab, peer mismatch, list embedded error (b) Unanimously transfer spaces after full selection; Press 2 to be re-aesthetic
The status bar is wrong but "looks good" Full-angle spaces, invisible characters, copy from Word/page (b) Re-advertise the plain text; You'll be a little more beautiful before you change business.
Only check the first paragraph. No trace of the resources. Multi-document --- (a) Sub-section verification; Or use the target CLI for authoritative checks.
The note is gone after the beauty. dump object-based tree Comments to be saved; Key notes for repository documents
yes/on ♪ Turn into true Brewer guess. Replace with "yes" Or real. true/false
Version 1.10 ♪ Turn into ♪ 1.1 Floating Point Parsing Force quote string
JSON Turn Yaml Failed The left side is actually YAML or the tail comma, JSON. Confirming the input; JSON First Formatting Tool
It's harder to read when it's compressed. The flow style is the tight shape of a human being's fold. Compression is used only for volume/pipes; Please beautify yourself.
anchor *anchor Behavior abnormal. noRefs Dump or parser difference Expand repeat blocks, or stationary team disable anchors

Suggested error order

  1. Whether to mix Tab / Full Angle Space.
  2. Near the wrong line. :、-, whether the quotation marks are paired.
  3. Type guesses whether the string is to be fed as a boolean/number.
  4. Whether the multiple documents only check a single paragraph.
  5. The last thing I doubt is that business field names are misspelled.

6. Real work scene

A:kubectl apply rejected, suspected indentation

Copy relevant clips (de-sensitization) from the failed list and post them. Change the status column by line number if it is directly misreported; If this is verified, then the API version, the mandatory fields or the RBAC - Formatting tool only proves that "this is a valid YamL object tree" and that "clusters accept the resource".

The B: GitHub Actions with: I don't know why.

run: Multi-script,with: Down : Strings are the easiest to blow. (a) To post the job clip into the tool to verify; Use quotes or block marks for messages with colons (in KiloCell of years)| / >)。 Admiral and then post the clip back to the workflow file, avoiding changing the full repository key on the web page.

Scenario C: Backend to JSON, Mission YAML values

A left-end interface sample is used by JSON to copy "JSON to YAML" to a Helm Values draft. Artificial restatement and environmental differences. If JSON is big, first JSON Format Confirms the legal and compressed field cognitive burden.

Scene D: Code Review "System, Different Styles"

Each of the two parties posted a YaML, which was beautified to 2 spaces and diff (editor or special diff). The government has also been working to reduce the interference of the "space war" with the logic review. Note: The beautification will lose the comment, the report comment needs to read the original document.

scene E: Spectacular configurations due to suspicious type

The same one is configured in Node and the Python service is not the same. Turn to JSON and look at each leaf of the JSON type; Adds a single quote to the version number, country code, starting with 0, to remove guesses from the source.

Scenario F: Teaching "Why can't you copy from chat software?"

Demonstration: Strange blanks from the copy of rich text failed to verify; Pure text or "load examples" successfully. The newer is a custom of "configuring only the code library and plain text".

7. Preparation of an inventory of collaborations

  • Base level uniform indent (2 or 4 spaces) and "prohibit Tab"
  • Perform a parse check of YAML before submitting (local tools or CI)
  • Secret, do not enter the explicit list and chat with a sealing mechanism or external key system
  • If an explanatory note is required, it is written in YaML; For programme consumption, provide additional JSON/schema
  • Multi-document file describes "Six-A-Fix-A-Resource" in README
  • All the things that are easily miscalculated are quoted.
  • The beautiful output goes back to the warehouse, goes through the business diff, avoids a frivolous large area re-allocation that could trigger a conflict.

FAQ

YAML must be better configured than JSON?

Not necessarily. YAML comforts when read more, comments, documents; Machine generation, strict type, JSON is simpler when HTTP API is in. Many of the teams are "Man Changed Yaml, Machine Export" JSON.

Why did my anchorage or note go after it was beautified?

Because the beautification path is load to object again. Comment is not part of the object tree; The anchor is here. noRefs The strategy will be launched. If you want to retain a handwritten style, only check, do not write back the dump result, or use a dedicated link to support the retention of comments.

Compressed Yaml and compressed JSON?

Not exactly. The compression bias of this tool towards the YamL blow style; JSON COMPUTER IS TO GO BLOCKED TICKER JSON. Give HTTP the usual direct YAML →JSON and press JSON.

Can multiple files be wond by one?

Page main path by single load/dump Design. Multidocument requests to undo a section or rely on kubectl/CI for authoritative authentication. Do not assume that web tools are 100% the same as cluster clients.

Tab, show me normal in my editor. Why fail?

Displays the width is not related to the resolution rule. YAML achieves desired space indentation; Moves the file to the Show White Character mode, which allows you to see the Tab tag and then to turn all the spaces.

K8s Secret will pass on to me at the online tool session?

Thousands of cells for the page to be processed in the browser with js-yaml. Still recommends that: Production of Secret do not stick to shared desktops or video presentations; - It's empty. Prioritize local file and sealing programs.

What difference does it make between `null ' , `~ ' and empty values?

It is often deconstructed to the nult in the YamL, but may be written in different styles. Teams should agree to use only one (e.g., visible) null) and indicate optional fields in schema.

Continue reading

First, you use the "load the example" to read "paint the tape" and "see the status bar to be beautiful and turn JSON" and then you take the real de-sensitization clip against the wrong table. Open JSON formatting when pure JSON is wrong; Open JSON↔AML when bridge conversion is required.