LocalExcelTool
はじめる

XML 整形

XML/HTMLを整形。タグの階層に合わせてインデント。

XML 整形とは

XML整形とは、XMLやHTMLのタグ階層に合わせて改行とインデントを追加し、構造を読みやすくする処理です。

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

このツールの前提

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

Whitespace between tags is not always insignificant

The formatter collapses runs of whitespace that sit between a closing angle bracket and an opening one, then re-indents by element depth. For machine-generated XML that is exactly right: the whitespace was inserted by an earlier pretty-printer and carries no meaning.

For hand-written XML it can be wrong. In mixed content — <p>hello <b>world</b> again</p> — the space before <b> is part of the text, and an aggressive pass can normalise two spaces to one or move text to its own line. The document still parses, but the rendered sentence changes.

Constructs that must be left alone

CDATA sections, xml:space="preserve" subtrees, and element content in XHTML must keep their internal whitespace exactly. A formatter that treats CDATA inner text as ordinary content will alter code samples or embedded scripts.

Attribute order is also worth noting: formatting should preserve it, because while XML says attribute order is insignificant, plenty of real systems diff attribute order and some signing schemes canonicalise it. Reordering attributes can invalidate an XML signature even though the document is logically identical.

Valid versus well-formed

This tool checks balance and structure, which is well-formedness. It cannot tell you whether the document matches a DTD or an XSD — that requires the schema, and it is the check that matters when an integration rejects a payload that looks perfect.

The common real-world failure is an unescaped ampersand in a URL query inside an attribute. & starts an entity reference, so ?a=1&b=2 is not well-formed; it must be written &amp;. Errors like that produce a parse failure pointing at a character that looks completely ordinary.

使い方

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

他の方法との比較

同じ変換をする方法は 3 つあります。ブラウザ内(このページ)、サーバー側の変換サービス、デスクトップアプリ。差がつくのは速度ではなく、ファイルがどこへ行くかと、無料でどこまでできるかです。

観点このツールサーバー側の変換サービス
ファイルの処理場所このページのブラウザ内ベンダーのサーバー(アップロード後)
アカウント不要多くの場合必要(無料枠の制限解除に登録を求める)
無料で扱えるサイズサイズ制限なし(回数制限もなし)数ファイル/時間、または 5〜10MB 程度で課金 wall
料金無料。Pro は月 $9(大きいファイルと AI 機能のみ)サブスクが一般的。おおむね月 $7〜15(2026 年 11 月時点)
オフライン一度開けば通信不要不可
20MB を処理し始めるまで待ち時間なし(アップロードが無い)アップロードが支配的(10Mbps 上りで約 16 秒)
保証できないこと不正な入力は「修復」せず、パーサのエラー位置を返します同じ(変換の原理は変わらない)

サーバー側のサービスが優れている点は明確にあります。巨大なファイル、チームでの共有、変換履歴の管理、スクリプトからの自動化。逆に「1 回だけ、手元のファイルを別形式にしたい」という今回の用途では、アップロードの待ち時間と登録の手間だけが増えます。

よくある質問

XML整形とは?

タグの入れ子に合わせてインデントし、構造を明確にします。

HTMLも使えますか?

はい、XML形式のHTMLも整形できます。

この変換で失われるもの

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

その他のフォーマット