LocalExcelTool
はじめる

HTML フォーマッター

HTML を整形(インデント)または圧縮(ミニファイ)。

HTML フォーマッターとは

HTML フォーマッターは、HTML を 2 スペースインデントで整形、または余分な空白とコメントを除去して圧縮する無料ツールです。script/style ブロックの中身は壊さずそのまま保持します。ブラウザ内で完結し、コードは送信されません。

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

このツールの前提

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

Format or minify, with different risks

Format mode re-indents by tag depth and puts attributes on the opening tag line. Minify mode removes whitespace between tags and collapses runs inside text. The input limit is 2 MB, which is roughly a large single page and well beyond anything hand-edited.

Minifying HTML is riskier than minifying JSON, because in HTML whitespace is sometimes content. Inline elements separated by a space — <b>a</b> <i>b</i> — rely on that space to render apart; removing it joins the words. Block-level structures are safe, inline ones are not.

Content that must not be reindented

<pre>, <textarea> and <script> hold whitespace-sensitive content. Re-indenting inside <pre> changes how code samples render; collapsing whitespace inside <textarea> changes the default value the user sees. A formatter that treats them like ordinary elements quietly alters the page.

Inline SVG has the same character: an extra space between <text> and <tspan> can shift baseline alignment. For SVG, prefer formatting the file as XML and checking the rendering afterwards.

The check that catches everything

Render both versions and compare screenshots, or at minimum diff the extracted text content. A byte diff will show hundreds of changes that do not matter; a text-content diff shows only the ones that do.

Also remember that formatted HTML and well-formed HTML are different claims. Unclosed <p> and <li> tags are legal in HTML5 and a strict XML-style formatter will either reject them or insert closing tags that change the DOM tree.

使い方

  1. 1.HTML を貼り付け
  2. 2.Format / Minify を選ぶ
  3. 3.実行して結果をコピー

他の方法との比較

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

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

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

よくある質問

script/style の中身は壊れない?

整形・圧縮のどちらでも <script> と <style> の中身はそのまま保持されます。

圧縮で消えるものは?

HTML コメント(IE 条件コメントは残す)とタグ間の余分な空白のみです。属性値は変更しません。

この変換で失われるもの

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

その他のフォーマット