YAML Formatter for Clean, Valid Configuration Files

YAML is the format behind Kubernetes manifests, CI pipelines, GitHub Actions workflows, and a long list of config files that ship with applications. Hand-edited files drift: indentation mixes two, three, and four spaces, quoting rules get skipped, and keys end up scattered after several people edit the same block. This page parses the document you paste, rebuilds it with one indentation width and consistent quoting, and reports every line the parser could not read.

The formatter runs entirely in this browser tab. Your config, tokens, and internal hostnames are never sent over the network, which makes the page fit for production manifests that hold secrets. Pick an indentation width, decide whether keys are sorted, and choose whether every value is quoted or only the ones YAML requires.

Format YAML Cleanly

Indentation, key order, and quoting The YAML stays in this tab.

YAML input

Paste a document, or edit the loaded sample. Comments are dropped when the file is rebuilt.

Format options

Key order

    Formatted output

    How It Works

    1. Paste the YAML. Drop your config into the input box, or edit the small messy sample that loads with the page. The sample is there so you can see the shape of the result before touching your own file.
    2. Set indentation, key order, and quoting. Two spaces is the common default, while four spaces reads better in deeply nested manifests. Sort keys reorders every mapping from A to Z, and the quote switch decides between quoting only ambiguous values and quoting everything.
    3. Press Format YAML. The document is parsed in the tab and rebuilt from the parsed structure, not from the original text, so spacing becomes uniform at every level. When a line cannot be read, the issue list shows the parser message with the line number to fix.
    4. Copy the result. The formatted document lands in the output box, and the summary reports the line count, the root type, and how many top-level entries the file holds. Change an option and the page formats again without another click.

    Before and After

    Before (mixed indentation widths, sloppy quoting)
    service:
       name: checkout-api
       port: 8080
    on: true
    credentials:
        username: "0123"
        token: abc#123
    flags:
      - verbose
    tasks:
        - id: 1
          name: build
        - id: 2
          name: deploy
    After (2-space indent, quoting applied)
    service:
      name: checkout-api
      port: 8080
    "on": true
    credentials:
      username: "0123"
      token: "abc#123"
    flags:
      - verbose
    tasks:
      - id: 1
        name: build
      - id: 2
        name: deploy
    Before (tab characters from an editor)
    server:
    	port: 8080
    After (the reported issue)
    Tabs are not allowed for indentation; use spaces (line 2)

    Use Cases

    Developer Production Workflow
    CI pipeline config pasted from chat Release manifest tidied before a commit Config copied out of a wiki page
    Indentation normalized to 2 spaces Keys sorted so review diffs line up Quoting applied to version strings
    Broken lines reported with numbers Secrets stay inside the laptop Sample document loaded on arrival
    Copy button for the tidy block Quote switch set to always for strict readers Summary shows root type and entry count

    Common Mistakes

    • Mixing indentation widths inside one block. Sibling lines must share one width; a line indented one space differently closes the block early, and the lines after it either join the wrong key or end the parse.
    • Expecting comments to survive. Comments are stripped while parsing, so anything written after a # marker stays behind when the document is rebuilt. Keep the original file when the comments carry instructions for the team.
    • Leaving tab characters in the paste. YAML treats tabs as invalid indentation, and the issue list names the exact line so you can replace them with spaces and run the format again.
    • Duplicate keys in one mapping. The parser refuses them and reports the line, because the meaning of the file would otherwise depend on which of the two values a reader picks.

    Best Practices

    • Match the width your consumer expects. Two spaces covers most tooling, while four spaces is common in Python-heavy projects; switch between them here and compare before committing the file.
    • Quote strings that look like other types. Values such as 0123, yes, or 1e5 carry meaning in some parsers, and the formatter keeps quoted input quoted so the string form survives the round trip.
    • Leave Sort keys off when order carries meaning. Override lists and priority stacks read in sequence, so sorting them changes behavior even though every key is still present afterwards.
    • Read the issue list from the top down. Parse errors name a line, and one broken line can hide the problems behind it, so fix the first entry and rerun until the list stays empty.

    Frequently Asked Questions

    Does formatting change my data values?

    No. The document is parsed into its values first and printed back from that structure, so numbers, booleans, null markers, and text keep their meaning. The formatter does change layout details: indentation width, spacing after colons, and which values carry quotes. Comments and blank-line patterns are not kept, since the parse step reads structure only.

    Why does indentation with tabs break YAML?

    YAML reserves tabs for its own use and requires spaces for indentation, so most parsers refuse a tab before a key. This page reports the offending line in the issue list, for example line 2 of a file whose second line was pasted from an editor that indents with tabs. Replace the tabs with spaces in your editor, then paste the document again.

    How are yes, no, on, and off treated?

    YAML 1.1 counts yes, no, on, and off as booleans, while YAML 1.2 counts only true and false. This parser follows the 1.1 side for true and false, so the sample line on: true comes back with the key quoted as "on" and the value printed as a boolean. Words like yes and no pass through as plain strings. Quote the words you need to keep as text and they stay quoted in the output.

    Why do some numbers stay quoted?

    Values with a leading zero such as "0123", octal-looking strings, hex forms, and words like .inf carry numeric meaning in some YAML flavors, so the formatter wraps them in quotes to keep them text. Plain integers and decimals such as 8080 or 12.5 stay unquoted. Set the quote switch to always when the receiving system expects every scalar quoted.

    Is sorting keys safe?

    For almost every config, yes. Each key keeps its value and its nesting depth, and only the order inside its mapping changes. Leave the checkbox off for documents where order is behavior, such as priority lists or override chains that apply in sequence. The sample on this page leaves sorting off, which is why the output keeps the original key order.

    What happens with multiple documents separated by ---?

    Only the first document in the paste is parsed and formatted; everything after the second --- marker is left out of the output. Split multi-document files, run each document on its own, then paste the pieces back together. A single --- marker that leads the file is treated as a document start and skipped.

    Is my YAML sent to a server?

    No. The parse and print steps run in this tab with ordinary JavaScript, and the page makes no request that carries your text. Closing the tab discards everything, and nothing is stored between visits. That property is what makes the page usable for manifests that hold internal hostnames or tokens.