LocalExcelTool
はじめる

YAML 整形

YAMLのインデントと空白を整理。設定ファイルをきれいに。

ブラウザ内で処理登録不要無料

YAML 整形とは

YAML整形とは、YAMLのインデントを2スペースに統一し、行末の空白を除いて可読性を高める処理です。設定ファイルの整理に便利です。

🔒 処理はすべてブラウザ内で完結し、データは送信されません。

このツールの前提

処理場所
このページのブラウザ内(JavaScript / Canvas)
アップロード
なし — ファイルは端末の外に出ません
オフライン
ページを開いた後は通信不要

Tabs are illegal, so they are converted

YAML forbids tab characters for indentation, and half the files that fail to parse fail for that reason. This formatter replaces leading tabs with two spaces and normalises trailing whitespace, which fixes the syntax without changing structure.

It re-indents by tracking the existing indentation levels rather than by parsing the document into a tree. That is safer for comments and anchors, which a full parse-and-reserialise would drop, but it means a file with genuinely inconsistent indentation will be made consistently wrong rather than corrected.

Values that change type without changing text

YAML 1.1 treats yes, no, on and off as booleans — the 'Norway problem', where the country code NO becomes false. Version numbers lose their second dot (1.10 becomes 1.1, a float), and unquoted 22:30 can be read as a sexagesimal integer by some parsers.

A formatter that only touches whitespace does not change these, but a round trip through a parser does. If a field must stay a string, quote it in the source; formatting will not protect you from a consumer that applies its own type resolution.

Multi-document files and block scalars

Documents separated by --- and terminated by ... are supported as separate blocks, and each is indented independently. Block scalars (| and >) are the fragile part: their content is defined by indentation relative to the parent key, so re-indenting the parent changes the string.

Check any indented multi-line value after formatting — a shell script or SQL embedded as a block scalar is the usual casualty. If the value matters, compare its content after parsing rather than eyeballing the indentation.

使い方

  1. 1.YAMLを貼り付け
  2. 2.「整形する」をクリック
  3. 3.結果をコピー

YAML 整形の仕組み

整形ツールは入力を構造として解析し、一貫したインデントで再出力します。構文エラーが見つかるのも同じ理由です。解析できなければ出力もできません。

  1. 1

    木構造へ解析

    JSON は JSON.parse、YAML・XML・CSS・SQL はそれぞれのパーサを使います。解析は構造を返すか、行と列を指して失敗するかのどちらかです。

  2. 2

    固定した様式で再出力

    インデント幅・キー順・引用の扱いを決定的に適用するため、同じ入力を 2 回整形しても同じバイト列になります。

  3. 3

    エラー位置を示す

    解析に失敗したときは位置を含むメッセージを出すので、当て推量ではなく明確に修正できます。

  4. 処理の流れ

整形は検証ではない

整形が証明するのは「構文として解析できる」ことだけです。スキーマに対する妥当性や業務ルールは検証しません。重複キーを持つ JSON は正常に解析され、最後の値が黙って採用されます。

何が正規化されるか

コメントは CSS と SQL では保持されますが、コメント構文の無い JSON では失われます。YAML のアンカーは展開され、引用符の種類が変わることがあります。署名対象などバイト配置が重要な場合は元ファイルを保管してください。

自分で確かめる

整形は決定的かつローカルです。2 回実行して比較してください。

  1. 1.このページで DevTools を開き、Network タブを選ぶ
  2. 2.フィルタを Fetch/XHR に設定したままツールを実行する
  3. 3.ファイルの中身を含むリクエストが 1 件も無いことを確認する(ページの読み込みとフォントだけが表示されます)

よくある質問

YAML整形とは?

インデントや空白を整理してYAMLを見やすくします。

値は変わりますか?

構造は変えず、見た目の空白だけを整えます。

この変換で失われるもの

フォーマッタは入力を構文木に解析し、一貫したインデントで出力します。入力が不正なら、黙って壊れたファイルを返すのではなく、パーサのエラー位置を表示します。壊れた JSON は「修復」されず、そのまま壊れたまま示されます。

その他のフォーマット