YAML Lint: Validate & Format YAML

Checks as you type, with the exact line and column of every error and how to fix it. Converts YAML to JSON and back. Nothing is uploaded.

Tab inserts two spaces. To move on with the keyboard, press Esc and then Tab.

Result

Paste YAML on the left (or pick an example) and the result appears here as you type.

    Why lint YAML before you use it?

    YAML drives CI pipelines, Kubernetes manifests, Docker Compose files, Ansible playbooks and countless app configs, and its indentation-based syntax breaks in ways that are hard to spot by eye: a tab, a stray colon, a key one space too deep. Worse, some mistakes aren't errors at all: version: 3.10 quietly becomes 3.1 and country: no can become false. This linter parses your YAML as you type, explains each error in plain English with its exact position, and flags those silent surprises. Nothing is uploaded, so configs that contain secrets stay on your device.

    How to validate YAML

    1. Paste YAML, drop a .yaml/.yml file on the editor, or load an example. The check runs as you type.
    2. Valid means every document parsed; the report lists each document. Invalid shows the parser's message, the lines around the problem with a caret under the column, and what it usually means. Jump to line puts your cursor there.
    3. Read the warnings: values that parse but may not mean what you think, plus style notes such as trailing spaces.
    4. Press Format for consistent 2- or 4-space indentation (JSON input becomes YAML), or switch to JSON to copy or download the converted data.

    Common YAML errors and how to fix them

    Each snippet below was run through this linter. The red line is exactly what it reports, with the line and column in parentheses, followed by the explanation it shows.

    Tabs used for indentation

    server:
    	port: 8080

    ✗ tab characters must not be used in indentation (line 2, column 1)

    YAML indentation must use spaces, never tabs. Replace the tab at the start of this line with spaces (Format can't run until it parses).

    YAML allows only spaces for indentation; the second line here starts with a tab. Replace tabs with spaces. In this editor, the Tab key inserts two spaces for you.

    Indentation that doesn't line up

    app:
      name: demo
       port: 8080

    ✗ bad indentation of a mapping entry (line 3, column 8)

    This key doesn't line up with the keys around it. Keys at the same level must start in exactly the same column; check for one space too many or too few, here or on the line above.

    Keys at the same level must start in exactly the same column. One extra space puts port deeper than name, and the parser can't tell what it belongs to. The same message appears when a list item and a key are mixed at one level.

    A colon and space inside a value

    title: Note: read this

    ✗ bad indentation of a mapping entry (line 1, column 12)

    This value contains ': ' (a colon followed by a space), which YAML reads as the start of another key. Put the whole value in quotes.

    A colon followed by a space starts a new key, so this value needs quotes: title: "Note: read this". A colon with no space after it, as in image: nginx:alpine or a URL, is fine.

    A missing space after a colon

    name: api
    port:8080
    host: example.com

    ✗ can not read a block mapping entry; a multiline key may not be an implicit key (line 3, column 5)

    A key seems to be missing the space after its colon (key:value instead of key: value), so YAML reads it as plain text. Add a space after the colon.

    port:8080 is read as plain text rather than a key, and plain text can't sit among mapping entries. Always put a space after the colon that ends a key.

    Duplicate keys

    name: api
    name: web

    ✗ duplicated mapping key (line 2, column 1)

    The same key appears twice in one mapping. Many parsers silently keep only the last one, so one of the values would be lost. Rename or remove one of them.

    Some parsers quietly keep the last value, so the first one disappears without warning. This linter stops at the second key so you can decide which one you meant.

    An unclosed quote

    message: "Hello
    next: 1

    ✗ unexpected end of the stream within a double quoted scalar (line 3, column 1)

    A quoted string is never closed. Find the opening quote on or above this line and add its closing quote. Inside single quotes, write an apostrophe as two (''); inside double quotes, escape a quote as \".

    The string that opens on line 1 never closes, so the parser reads to the end of the file looking for the quote. Add the closing quote. Inside single quotes write an apostrophe as two ('it''s').

    Valid YAML that doesn't mean what you think

    These lines are all valid, so a syntax check alone passes them. But unquoted values are typed, and parsers that follow the older YAML 1.1 rules type them differently from YAML 1.2. The middle column is what this linter (js-yaml, YAML 1.2) produced for each line; the linter flags every one of them with a warning.

    You writeYAML 1.2 readsYAML 1.1 (PyYAML, Ansible…) reads
    country: no"no" (text)false (boolean)
    feature: on"on" (text)true (boolean)
    version: 3.103.1 (number)3.1 (number)
    zip: 012341234 (number)668 (octal number)
    mode: 0755755 (number)493 (octal number)
    port: 22:22"22:22" (text)1342 (base-60 number)
    color: #ff0000null (a comment)null (a comment)
    date: 2024-01-15a date (timestamp)a date

    The fix is the same for all of them: quote values that must stay text (country: "no", version: "3.10",port: "22:22") and write booleans as true and false. GitHub Actions' python-version: 3.10, which installs Python 3.1, and Kubernetes environment variables set to yes are the classic real-world examples.

    Which parsers follow YAML 1.1 or 1.2?

    ParserUsed byyes / no / on / off
    js-yaml 4 (this linter)Node.js tools, many web appsText (YAML 1.2)
    ruamel.yamlPython tools that need 1.2 or round-trippingText (YAML 1.2 by default)
    PyYAMLPython scripts, AnsibleBooleans (YAML 1.1)
    Go yaml.v2Older Go tools; Kubernetes' YAML library is built on itBooleans (YAML 1.1)
    Go yaml.v3Newer Go toolsText, except when decoded into a bool field
    SnakeYAMLJava, Spring BootBooleans (YAML 1.1)
    PsychRuby, RailsBooleans (YAML 1.1)

    Because one file is often read by several of these, the safest YAML is the kind every parser agrees on: quoted text, true/false booleans, and no leading zeros on numbers.

    Converting YAML to JSON (and back)

    YAML is a superset of JSON, so the conversion is exact for data: mappings become objects, sequences become arrays, ~ and empty values become null. A few YAML features have no JSON equivalent and are converted like this:

    • Several documents become one JSON array, in order.
    • Anchors and aliases (&defaults, *defaults, <<: *defaults) are expanded into full copies.
    • Dates and timestamps become ISO 8601 strings, such as 2024-01-15T00:00:00.000Z.
    • Comments are dropped, because JSON has none.
    • CloudFormation short forms become the long forms used in JSON templates: !Ref Bucket becomes {"Ref": "Bucket"} and !GetAtt Bucket.Arn becomes {"Fn::GetAtt": ["Bucket", "Arn"]}. Other tags become {"!tag": value}.

    To go from JSON to YAML, paste the JSON and press Format. For heavy JSON work (validation with exact positions, a tree view, JSONPath search) use the JSON formatter, and to compare two versions of a config line by line, tryText Diff (format both first so only real changes show). Kubernetes Secret values are Base64, which the Base64 decoder turns back into text, and a list of records can go to a spreadsheet throughJSON to CSV.

    Frequently asked questions

    How do I validate a YAML file online?

    Paste the YAML into the editor, drop a .yaml or .yml file on it, or tap Upload. It is checked as you type: the badge says Valid or Invalid, an error shows its exact line and column with the surrounding lines and a caret under the problem, and Jump to line puts the cursor there. Warnings for valid-but-risky values are listed below the result.

    What does this YAML linter check?

    Syntax, by parsing the whole file with js-yaml under YAML 1.2 rules: indentation, tabs, unclosed quotes and brackets, colons inside unquoted values, duplicate keys, undefined aliases and bad tags. It also warns about YAML that parses but may not mean what you intended (yes/no/on/off, 3.10, 0755, 22:22, a # that turns a value into a comment, a missing space after a colon) and notes trailing spaces and inconsistent indentation.

    Why is my YAML invalid?

    The usual causes are a tab used for indentation, a key indented one space more or less than its siblings, a value containing ': ' or starting with a character like @, * or & that needs quotes, a quote that is never closed, or the same key twice. Each error here comes with a plain-English explanation of what that parser message usually means and how to fix it.

    Does this tool upload my YAML anywhere?

    No. Parsing, linting, formatting and conversion run in your browser with the js-yaml library bundled into this page, so configs containing passwords or tokens never leave your device. Your current text is kept in this tab's session storage so it survives navigating away and back; closing the tab clears it.

    How do I convert YAML to JSON?

    Paste the YAML and switch the result panel to JSON. You get the parsed data as indented JSON, ready to copy or download as a .json file. Several documents become a JSON array, dates become ISO 8601 strings, aliases are expanded, and CloudFormation short forms such as !Ref and !GetAtt become their JSON long forms (Ref, Fn::GetAtt).

    How do I convert JSON to YAML?

    Paste the JSON into the editor and press Format. JSON is valid YAML, so it parses, and Format writes it back out as block-style YAML with 2- or 4-space indentation. Undo Format brings the original back.

    Does it support multi-document YAML, such as several Kubernetes manifests?

    Yes. A line of --- starts a new document. Every document is checked in one pass, the result lists each one with its starting line and a summary (for Kubernetes, its kind and name, such as Deployment "web"), the JSON view shows them as an array, and Format tidies each one while keeping the separators.

    Why is 'no' a string here but a boolean in my app?

    This linter follows YAML 1.2, where only true and false are booleans. YAML 1.1 parsers, including PyYAML (and so Ansible), Ruby's Psych, Java's SnakeYAML and Go's yaml.v2, also read yes, no, on and off as booleans, which famously turns Norway's country code NO into false. The linter flags these values; quote them ('no') so every parser treats them as text.

    Does it work with CloudFormation tags like !Ref and !Sub?

    Yes. Application tags with a single ! (CloudFormation's !Ref, !Sub, !GetAtt and !If, GitLab CI's !reference, Home Assistant's !include and !secret) are accepted and listed, Format keeps them, and the JSON view turns CloudFormation short forms into the long forms CloudFormation's JSON templates use. Only !! tags must be standard YAML types.

    Does Format keep my comments and anchors?

    No. Format loads the YAML into data and writes it back out, so comments are dropped, anchors and aliases are expanded into full copies, and quoting style may change. Values, key order (unless you tick Sort keys) and tags are kept. When something was lost, a notice says so and Undo Format restores your original text.

    Does it check Kubernetes, Docker Compose, or GitHub Actions rules?

    It checks YAML syntax and common value gotchas, not the schema of a particular tool. A misspelled key such as 'imgae:' or a number where a string is required is still valid YAML, so it passes here. Use the target tool's own validator for schema checks, such as kubectl apply --dry-run=server, docker compose config, or actionlint.

    Why does the JSON view show my date as a timestamp?

    Unquoted values like 2024-01-15 match YAML's timestamp type, so they're parsed as dates and shown in JSON as full timestamps such as 2024-01-15T00:00:00.000Z. If the value should stay plain text, put it in quotes.

    Advertisement