LocalExcelTool
はじめる

CSS 整形

CSSを読みやすい形式に整形。インデントと改行を自動調整。

CSS 整形とは

CSS整形とは、CSSのセレクタ・プロパティ・値に適切な改行とインデントを入れて可読性を高める処理です。

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

このツールの前提

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

A tokeniser, not a CSS parser

The formatter tracks quote state and comment state while walking the input, so a brace inside a string — content: "}" — does not change the indent level, and a brace inside a comment is ignored. Indentation follows brace depth; declarations get one per line.

It does not build a CSS object model, so it cannot tell whether a selector is valid, whether a property is known, or whether an at-rule contains declarations or rules. That is deliberate: a formatter should never reject CSS that a browser accepts, and browsers accept a great deal that a strict parser rejects.

Modern CSS that confuses naive formatters

Nested rules, @layer blocks and @container queries all contain braces at the same level as declarations, so brace-counting indentation looks slightly off inside them even though the output is still valid. CSS custom properties are the sharper case: their values are arbitrary tokens, and a formatter that lowercases property values will corrupt a case-sensitive custom property reference.

Also check calc() and grid template areas. A formatter that inserts spaces inside calc() arithmetic is harmless, but one that rewrites quoted grid-template-areas strings breaks layout in a way that is hard to trace back to a formatting step.

What to verify after formatting

Diff the output against the input with whitespace ignored. If anything other than spacing changed, the formatter touched content it should not have — that is the one check that catches every class of corruption in a single pass.

Prettier and stylelint are the better long-term answer for a codebase, because they are stable and configured once. A browser tool is for inspecting a snippet from production, a snippet pasted out of an email, or a one-off clean-up where installing a toolchain is not worth it.

使い方

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

他の方法との比較

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

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

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

よくある質問

CSS整形とは?

ルールごとに改行とインデントを整えて読みやすくします。

コメントは保持されますか?

はい、コメントや文字列の中身は壊さずに整形します。

この変換で失われるもの

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

その他のフォーマット